Flutter Engine
The 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
9
10namespace 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
34 surface, [this](VkSurfaceKHR surface) {
35 vk.DestroySurfaceKHR(application_.GetInstance(), surface, nullptr);
36 }};
37
38 valid_ = true;
39}
40
42
44 return valid_;
45}
46
48 return surface_;
49}
50
52 return *native_surface_;
53}
54
56 return valid_ ? native_surface_->GetSize() : SkISize::Make(0, 0);
57}
58
59} // namespace vulkan
const VulkanHandle< VkInstance > & GetInstance() const
SkISize GetSize() const
Returns the current size of the surface or (0, 0) if invalid.
const VulkanNativeSurface & GetNativeSurface() const
const VulkanHandle< VkSurfaceKHR > & Handle() const
VulkanSurface(VulkanProcTable &vk, VulkanApplication &application, std::unique_ptr< VulkanNativeSurface > native_surface)
VkSurfaceKHR surface
Definition: main.cc:49
#define FML_DLOG(severity)
Definition: logging.h:102
vk
Definition: malisc.py:42
Definition: ref_ptr.h:256
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46