| Flutter Impeller |

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_image_vk.h"
6
7 namespace impeller {
8
9 SwapchainImageVK::SwapchainImageVK(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 SwapchainImageVK::~SwapchainImageVK() = default;
33
34 bool SwapchainImageVK::IsValid() const {
35 return is_valid_;
36 }
37
38 std::shared_ptr<Texture> SwapchainImageVK::GetMSAATexture() const {
39 return msaa_tex_;
40 }
41
42 bool SwapchainImageVK::HasMSAATexture() const {
43 return msaa_tex_ != nullptr;
44 }
45
46 void SwapchainImageVK::SetMSAATexture(std::shared_ptr<Texture> msaa_tex) {
47 msaa_tex_ = std::move(msaa_tex);
48 }
49
50 PixelFormat SwapchainImageVK::GetPixelFormat() const {
51 return desc_.format;
52 }
53
54 ISize SwapchainImageVK::GetSize() const {
55 return desc_.size;
56 }
57
58 // |TextureSourceVK|
59 vk::Image SwapchainImageVK::GetImage() const {
60 return image_;
61 }
62
63 // |TextureSourceVK|
64 vk::ImageView SwapchainImageVK::GetImageView() const {
65 return image_view_.get();
66 }
67
68 } // namespace impeller
impeller::TextureSourceVK
Definition: texture_source_vk.h:22
impeller::SwapchainImageVK::SetMSAATexture
void SetMSAATexture(std::shared_ptr< Texture > msaa_tex)
Definition: swapchain_image_vk.cc:46
impeller::SwapchainImageVK::IsValid
bool IsValid() const
Definition: swapchain_image_vk.cc:34
impeller::SwapchainImageVK::GetImage
vk::Image GetImage() const override
Definition: swapchain_image_vk.cc:59
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:40
impeller::ToArrayLayerCount
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:594
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:42
impeller::SwapchainImageVK::GetPixelFormat
PixelFormat GetPixelFormat() const
Definition: swapchain_image_vk.cc:50
impeller::SwapchainImageVK::HasMSAATexture
bool HasMSAATexture() const
Definition: swapchain_image_vk.cc:42
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:94
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:39
impeller::TextureSourceVK::desc_
const TextureDescriptor desc_
Definition: texture_source_vk.h:55
impeller::TSize< int64_t >
impeller::ToVKImageFormat
constexpr vk::Format ToVKImageFormat(PixelFormat format)
Definition: formats_vk.h:136
impeller::SwapchainImageVK::GetMSAATexture
std::shared_ptr< Texture > GetMSAATexture() const
Definition: swapchain_image_vk.cc:38
impeller::SwapchainImageVK::GetSize
ISize GetSize() const
Definition: swapchain_image_vk.cc:54
impeller::TextureDescriptor::size
ISize size
Definition: texture_descriptor.h:41
impeller::SwapchainImageVK::~SwapchainImageVK
~SwapchainImageVK() override
swapchain_image_vk.h
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
impeller::SwapchainImageVK::GetImageView
vk::ImageView GetImageView() const override
Definition: swapchain_image_vk.cc:64
impeller
Definition: aiks_context.cc:10
impeller::SwapchainImageVK::SwapchainImageVK
SwapchainImageVK(TextureDescriptor desc, const vk::Device &device, vk::Image image)
Definition: swapchain_image_vk.cc:9