Flutter Engine
gpu_surface_vulkan.h
Go to the documentation of this file.
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 #include "include/core/SkRefCnt.h"
17 
18 namespace flutter {
19 
20 class GPUSurfaceVulkan : public Surface {
21  public:
22  //------------------------------------------------------------------------------
23  /// @brief Create a GPUSurfaceVulkan which implicitly creates its own
24  /// GrDirectContext for Skia.
25  ///
27  std::unique_ptr<vulkan::VulkanNativeSurface> native_surface,
28  bool render_to_surface);
29 
30  //------------------------------------------------------------------------------
31  /// @brief Create a GPUSurfaceVulkan while letting it reuse an existing
32  /// GrDirectContext.
33  ///
34  GPUSurfaceVulkan(const sk_sp<GrDirectContext>& context,
35  GPUSurfaceVulkanDelegate* delegate,
36  std::unique_ptr<vulkan::VulkanNativeSurface> native_surface,
37  bool render_to_surface);
38 
39  ~GPUSurfaceVulkan() override;
40 
41  // |Surface|
42  bool IsValid() override;
43 
44  // |Surface|
45  std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override;
46 
47  // |Surface|
48  SkMatrix GetRootTransformation() const override;
49 
50  // |Surface|
51  GrDirectContext* GetContext() override;
52 
53  private:
54  vulkan::VulkanWindow window_;
55  const bool render_to_surface_;
56 
58 
59  FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceVulkan);
60 };
61 
62 } // namespace flutter
63 
64 #endif // SHELL_GPU_GPU_SURFACE_VULKAN_H_
std::unique_ptr< SurfaceFrame > AcquireFrame(const SkISize &size) override
GPUSurfaceVulkan(GPUSurfaceVulkanDelegate *delegate, std::unique_ptr< vulkan::VulkanNativeSurface > native_surface, bool render_to_surface)
Create a GPUSurfaceVulkan which implicitly creates its own GrDirectContext for Skia.
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
Abstract Base Class that represents where we will be rendering content.
Definition: surface.h:18
GrDirectContext * GetContext() override
SkMatrix GetRootTransformation() const override