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 FLUTTER_VULKAN_VULKAN_WINDOW_H_ 6 #define FLUTTER_VULKAN_VULKAN_WINDOW_H_ 7 8 #include <memory> 9 #include <tuple> 10 #include <utility> 11 #include <vector> 12 13 #include "flutter/fml/compiler_specific.h" 14 #include "flutter/fml/macros.h" 15 #include "flutter/vulkan/vulkan_proc_table.h" 16 #include "third_party/skia/include/core/SkRefCnt.h" 17 #include "third_party/skia/include/core/SkSize.h" 18 #include "third_party/skia/include/core/SkSurface.h" 19 #include "third_party/skia/include/gpu/GrContext.h" 20 #include "third_party/skia/include/gpu/vk/GrVkBackendContext.h" 21 22 namespace vulkan { 23 24 class VulkanNativeSurface; 25 class VulkanDevice; 26 class VulkanSurface; 27 class VulkanSwapchain; 28 class VulkanImage; 29 class VulkanApplication; 30 class VulkanBackbuffer; 31 32 class VulkanWindow { 33 public: 34 VulkanWindow(fml::RefPtr<VulkanProcTable> proc_table, 35 std::unique_ptr<VulkanNativeSurface> native_surface); 36 37 ~VulkanWindow(); 38 39 bool IsValid() const; 40 41 GrContext* GetSkiaGrContext(); 42 43 sk_sp<SkSurface> AcquireSurface(); 44 45 bool SwapBuffers(); 46 47 private: 48 bool valid_; 49 fml::RefPtr<VulkanProcTable> vk; 50 std::unique_ptr<VulkanApplication> application_; 51 std::unique_ptr<VulkanDevice> logical_device_; 52 std::unique_ptr<VulkanSurface> surface_; 53 std::unique_ptr<VulkanSwapchain> swapchain_; 54 sk_sp<GrContext> skia_gr_context_; 55 56 bool CreateSkiaGrContext(); 57 58 bool CreateSkiaBackendContext(GrVkBackendContext* context); 59 60 FML_WARN_UNUSED_RESULT 61 bool RecreateSwapchain(); 62 63 FML_DISALLOW_COPY_AND_ASSIGN(VulkanWindow); 64 }; 65 66 } // namespace vulkan 67 68 #endif // FLUTTER_VULKAN_VULKAN_WINDOW_H_ 69