Flutter Impeller
texture_vk.h
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 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_VK_H_
7 
16 
17 namespace impeller {
18 
19 class TextureVK final : public Texture, public BackendCast<TextureVK, Texture> {
20  public:
21  TextureVK(std::weak_ptr<Context> context,
22  std::shared_ptr<TextureSourceVK> source);
23 
24  // |Texture|
25  ~TextureVK() override;
26 
27  vk::Image GetImage() const;
28 
29  vk::ImageView GetImageView() const;
30 
31  vk::ImageView GetRenderTargetView() const;
32 
33  bool SetLayout(const BarrierVK& barrier) const;
34 
35  vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const;
36 
37  vk::ImageLayout GetLayout() const;
38 
39  std::shared_ptr<const TextureSourceVK> GetTextureSource() const;
40 
41  // |Texture|
42  ISize GetSize() const override;
43 
44  void SetMipMapGenerated();
45 
46  bool IsSwapchainImage() const;
47 
48  std::shared_ptr<SamplerVK> GetImmutableSamplerVariant(
49  const SamplerVK& sampler) const;
50 
51  // These methods should only be used by render_pass_vk.h
52 
53  /// Store the last framebuffer object used with this texture.
54  ///
55  /// This field is only set if this texture is used as the resolve texture
56  /// of a render pass. By construction, this framebuffer should be compatible
57  /// with any future render passes.
59 
60  /// Store the last render pass object used with this texture.
61  ///
62  /// This field is only set if this texture is used as the resolve texture
63  /// of a render pass. By construction, this framebuffer should be compatible
64  /// with any future render passes.
65  void SetCachedRenderPass(const SharedHandleVK<vk::RenderPass>& render_pass);
66 
67  /// Retrieve the last framebuffer object used with this texture.
68  ///
69  /// May be nullptr if no previous framebuffer existed.
71 
72  /// Retrieve the last render pass object used with this texture.
73  ///
74  /// May be nullptr if no previous render pass existed.
76 
77  private:
78  std::weak_ptr<Context> context_;
79  std::shared_ptr<TextureSourceVK> source_;
80 
81  // |Texture|
82  void SetLabel(std::string_view label) override;
83 
84  // |Texture|
85  bool OnSetContents(const uint8_t* contents,
86  size_t length,
87  size_t slice) override;
88 
89  // |Texture|
90  bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
91  size_t slice) override;
92 
93  // |Texture|
94  bool IsValid() const override;
95 
96  TextureVK(const TextureVK&) = delete;
97 
98  TextureVK& operator=(const TextureVK&) = delete;
99 };
100 
101 } // namespace impeller
102 
103 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_VK_H_
impeller::TextureVK::GetCachedFramebuffer
SharedHandleVK< vk::Framebuffer > GetCachedFramebuffer() const
Definition: texture_vk.cc:187
texture_source_vk.h
impeller::TextureVK::SetMipMapGenerated
void SetMipMapGenerated()
Definition: texture_vk.cc:195
formats_vk.h
impeller::SamplerVK
Definition: sampler_vk.h:19
impeller::TextureVK::GetTextureSource
std::shared_ptr< const TextureSourceVK > GetTextureSource() const
Definition: texture_vk.cc:155
vk.h
impeller::TextureVK::SetLayout
bool SetLayout(const BarrierVK &barrier) const
Definition: texture_vk.cc:159
impeller::Texture
Definition: texture.h:17
impeller::TSize< int64_t >
impeller::TextureVK::GetImage
vk::Image GetImage() const
Definition: texture_vk.cc:147
impeller::BarrierVK
Defines an operations and memory access barrier on a resource.
Definition: barrier_vk.h:28
impeller::TextureVK::IsSwapchainImage
bool IsSwapchainImage() const
Definition: texture_vk.cc:199
impeller::TextureVK::GetImageView
vk::ImageView GetImageView() const
Definition: texture_vk.cc:151
impeller::TextureVK::GetRenderTargetView
vk::ImageView GetRenderTargetView() const
Definition: texture_vk.cc:173
impeller::TextureVK::SetCachedFramebuffer
void SetCachedFramebuffer(const SharedHandleVK< vk::Framebuffer > &framebuffer)
Definition: texture_vk.cc:177
impeller::TextureVK::~TextureVK
~TextureVK() override
backend_cast.h
impeller::TextureVK::GetLayout
vk::ImageLayout GetLayout() const
Definition: texture_vk.cc:169
impeller::TextureVK
Definition: texture_vk.h:19
impeller::TextureVK::GetSize
ISize GetSize() const override
Definition: texture_vk.cc:143
impeller::BackendCast
Definition: backend_cast.h:11
impeller::SharedHandleVK
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Definition: shared_object_vk.h:52
device_buffer_vk.h
impeller::TextureVK::GetCachedRenderPass
SharedHandleVK< vk::RenderPass > GetCachedRenderPass() const
Definition: texture_vk.cc:191
texture.h
sampler_vk.h
impeller::TextureVK::SetLayoutWithoutEncoding
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Definition: texture_vk.cc:163
impeller::TextureVK::GetImmutableSamplerVariant
std::shared_ptr< SamplerVK > GetImmutableSamplerVariant(const SamplerVK &sampler) const
Definition: texture_vk.cc:203
context_vk.h
impeller::TextureVK::TextureVK
TextureVK(std::weak_ptr< Context > context, std::shared_ptr< TextureSourceVK > source)
Definition: texture_vk.cc:14
impeller
Definition: aiks_blur_unittests.cc:20
impeller::TextureVK::SetCachedRenderPass
void SetCachedRenderPass(const SharedHandleVK< vk::RenderPass > &render_pass)
Definition: texture_vk.cc:182