| Flutter Impeller |

khr_swapchain_image_vk.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 "impeller/renderer/backend/vulkan/swapchain/khr/khr_swapchain_image_vk.h"
6
7 namespace impeller {
8
9 KHRSwapchainImageVK::KHRSwapchainImageVK(TextureDescriptor desc,
10 const vk::Device& device,
11 vk::Image image)
12 : TextureSourceVK(desc), image_(image) {
13 vk::ImageViewCreateInfo view_info;
14 view_info.image = image_;
15 view_info.viewType = vk::ImageViewType::e2D;
16 view_info.format = ToVKImageFormat(desc.format);
17 view_info.subresourceRange.aspectMask = vk::ImageAspectFlagBits::eColor;
18 view_info.subresourceRange.baseMipLevel = 0u;
19 view_info.subresourceRange.baseArrayLayer = 0u;
20 view_info.subresourceRange.levelCount = desc.mip_count;
21 view_info.subresourceRange.layerCount = ToArrayLayerCount(desc.type);
22
23 auto [view_result, view] = device.createImageViewUnique(view_info);
24 if (view_result != vk::Result::eSuccess) {
25 return;
26 }
27
28 image_view_ = std::move(view);
29 is_valid_ = true;
30 }
31
32 KHRSwapchainImageVK::~KHRSwapchainImageVK() = default;
33
34 bool KHRSwapchainImageVK::IsValid() const {
35 return is_valid_;
36 }
37
38 // |TextureSourceVK|
39 vk::Image KHRSwapchainImageVK::GetImage() const {
40 return image_;
41 }
42
43 // |TextureSourceVK|
44 vk::ImageView KHRSwapchainImageVK::GetImageView() const {
45 return image_view_.get();
46 }
47
48 // |TextureSourceVK|
49 vk::ImageView KHRSwapchainImageVK::GetRenderTargetView() const {
50 return image_view_.get();
51 }
52
53 // |TextureSourceVK|
54 bool KHRSwapchainImageVK::IsSwapchainImage() const {
55 return true;
56 }
57
58 } // namespace impeller
impeller::KHRSwapchainImageVK::KHRSwapchainImageVK
KHRSwapchainImageVK(TextureDescriptor desc, const vk::Device &device, vk::Image image)
Definition: khr_swapchain_image_vk.cc:9
impeller::KHRSwapchainImageVK::IsValid
bool IsValid() const
Definition: khr_swapchain_image_vk.cc:34
impeller::KHRSwapchainImageVK::GetImage
vk::Image GetImage() const override
Get the image handle for this texture source.
Definition: khr_swapchain_image_vk.cc:39
impeller::KHRSwapchainImageVK::GetImageView
vk::ImageView GetImageView() const override
Retrieve the image view used for sampling/blitting/compute with this texture source.
Definition: khr_swapchain_image_vk.cc:44
impeller::KHRSwapchainImageVK::IsSwapchainImage
bool IsSwapchainImage() const override
Determines if swapchain image. That is, an image used as the root render target.
Definition: khr_swapchain_image_vk.cc:54
impeller::KHRSwapchainImageVK::~KHRSwapchainImageVK
~KHRSwapchainImageVK() override
impeller::KHRSwapchainImageVK::GetRenderTargetView
vk::ImageView GetRenderTargetView() const override
Retrieve the image view used for render target attachments with this texture source.
Definition: khr_swapchain_image_vk.cc:49
impeller::TextureSourceVK
Abstract base class that represents a vkImage and an vkImageView.
Definition: texture_source_vk.h:33
khr_swapchain_image_vk.h
impeller
Definition: allocation.cc:12
impeller::ToArrayLayerCount
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:543
impeller::ToVKImageFormat
constexpr vk::Format ToVKImageFormat(PixelFormat format)
Definition: formats_vk.h:146
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:38
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:40
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:43
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:41