Flutter Engine
vulkan_surface.cc
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 #include "vulkan_surface.h"
6 
7 #include "vulkan_application.h"
9 
10 namespace vulkan {
11 
13  VulkanProcTable& p_vk, // NOLINT
14  VulkanApplication& application, // NOLINT
15  std::unique_ptr<VulkanNativeSurface> native_surface)
16  : vk(p_vk),
17  application_(application),
18  native_surface_(std::move(native_surface)),
19  valid_(false) {
20  if (native_surface_ == nullptr || !native_surface_->IsValid()) {
21  FML_DLOG(INFO) << "Native surface was invalid.";
22  return;
23  }
24 
25  VkSurfaceKHR surface =
26  native_surface_->CreateSurfaceHandle(vk, application.GetInstance());
27 
28  if (surface == VK_NULL_HANDLE) {
29  FML_DLOG(INFO) << "Could not create the surface handle.";
30  return;
31  }
32 
33  surface_ = {surface, [this](VkSurfaceKHR surface) {
34  vk.DestroySurfaceKHR(application_.GetInstance(), surface,
35  nullptr);
36  }};
37 
38  valid_ = true;
39 }
40 
42 
43 bool VulkanSurface::IsValid() const {
44  return valid_;
45 }
46 
48  return surface_;
49 }
50 
52  return *native_surface_;
53 }
54 
55 SkISize VulkanSurface::GetSize() const {
56  return valid_ ? native_surface_->GetSize() : SkISize::Make(0, 0);
57 }
58 
59 } // namespace vulkan
Definition: ref_ptr.h:252
const VulkanHandle< VkSurfaceKHR > & Handle() const
SkISize GetSize() const
Returns the current size of the surface or (0, 0) if invalid.
const VulkanNativeSurface & GetNativeSurface() const
VulkanSurface(VulkanProcTable &vk, VulkanApplication &application, std::unique_ptr< VulkanNativeSurface > native_surface)
#define FML_DLOG(severity)
Definition: logging.h:85
const VulkanHandle< VkInstance > & GetInstance() const