1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHELL_GPU_GPU_SURFACE_VULKAN_H_
6#define SHELL_GPU_GPU_SURFACE_VULKAN_H_
7
8#include <memory>
9
10#include "flutter/flow/surface.h"
11#include "flutter/fml/macros.h"
12#include "flutter/fml/memory/weak_ptr.h"
13#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h"
14#include "flutter/vulkan/vulkan_native_surface.h"
15#include "flutter/vulkan/vulkan_window.h"
16
17namespace flutter {
18
19class GPUSurfaceVulkan : public Surface {
20 public:
21 GPUSurfaceVulkan(GPUSurfaceVulkanDelegate* delegate,
22 std::unique_ptr<vulkan::VulkanNativeSurface> native_surface,
23 bool render_to_surface);
24
25 ~GPUSurfaceVulkan() override;
26
27 // |Surface|
28 bool IsValid() override;
29
30 // |Surface|
31 std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override;
32
33 // |Surface|
34 SkMatrix GetRootTransformation() const override;
35
36 // |Surface|
37 GrDirectContext* GetContext() override;
38
39 // |Surface|
40 flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;
41
42 private:
43 vulkan::VulkanWindow window_;
44 GPUSurfaceVulkanDelegate* delegate_;
45 const bool render_to_surface_;
46
47 fml::WeakPtrFactory<GPUSurfaceVulkan> weak_factory_;
48
49 FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceVulkan);
50};
51
52} // namespace flutter
53
54#endif // SHELL_GPU_GPU_SURFACE_VULKAN_H_
55