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_backbuffer.h"
15#include "flutter/vulkan/vulkan_native_surface.h"
16#include "flutter/vulkan/vulkan_window.h"
17
18#include "third_party/skia/include/core/SkRefCnt.h"
19#include "third_party/skia/include/core/SkSurface.h"
20
21namespace flutter {
22
23//------------------------------------------------------------------------------
24/// @brief A GPU surface backed by VkImages provided by a
25/// GPUSurfaceVulkanDelegate.
26///
27class GPUSurfaceVulkan : public Surface {
28 public:
29 //------------------------------------------------------------------------------
30 /// @brief Create a GPUSurfaceVulkan while letting it reuse an existing
31 /// GrDirectContext.
32 ///
33 GPUSurfaceVulkan(GPUSurfaceVulkanDelegate* delegate,
34 const sk_sp<GrDirectContext>& context,
35 bool render_to_surface);
36
37 ~GPUSurfaceVulkan() override;
38
39 // |Surface|
40 bool IsValid() override;
41
42 // |Surface|
43 std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override;
44
45 // |Surface|
46 SkMatrix GetRootTransformation() const override;
47
48 // |Surface|
49 GrDirectContext* GetContext() override;
50
51 static SkColorType ColorTypeFromFormat(const VkFormat format);
52
53 private:
54 GPUSurfaceVulkanDelegate* delegate_;
55 sk_sp<GrDirectContext> skia_context_;
56 bool render_to_surface_;
57
58 fml::WeakPtrFactory<GPUSurfaceVulkan> weak_factory_;
59
60 sk_sp<SkSurface> CreateSurfaceFromVulkanImage(const VkImage image,
61 const VkFormat format,
62 const SkISize& size);
63
64 FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceVulkan);
65};
66
67} // namespace flutter
68
69#endif // SHELL_GPU_GPU_SURFACE_VULKAN_H_
70

source code of flutter_engine/flutter/shell/gpu/gpu_surface_vulkan.h

Morty Proxy This is a proxified and sanitized view of the page, visit original site.