| Flutter Impeller |

swapchain_transients_mtl.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_METAL_SWAPCHAIN_TRANSIENTS_MTL_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_SWAPCHAIN_TRANSIENTS_MTL_H_
7
8 #include <memory>
9
10 #include "impeller/core/formats.h"
11 #include "impeller/geometry/rect.h"
12 #include "impeller/geometry/size.h"
13 #include "impeller/renderer/context.h"
14 #include "impeller/renderer/surface.h"
15
16 namespace impeller {
17
18 /// @brief A cache for the onscreen texture attachments used in surface_mtl.
19 ///
20 /// Typically the onscreen resolve texture is created from a Metal drawable and
21 /// this cache is only used for the MSAA texture and the depth+stencil
22 /// attachment. When partial repaint is active, this class also provides a cache
23 /// for an offscreen resolve texture that is blitted to the real onscreen during
24 /// present.
25 class SwapchainTransientsMTL {
26 public:
27 explicit SwapchainTransientsMTL(const std::shared_ptr<Allocator>& allocator);
28
29 ~SwapchainTransientsMTL();
30
31 /// @brief Update the size and pixel format of the onscreens.
32 ///
33 /// Note: this will invalidate any cached textures if either property changes.
34 void SetSizeAndFormat(ISize size, PixelFormat format);
35
36 /// @brief Retrieve the resolve texture, creating one if needed.
37 std::shared_ptr<Texture> GetResolveTexture();
38
39 /// @brief Retrieve the MSAA texture, creating one if needed.
40 std::shared_ptr<Texture> GetMSAATexture();
41
42 /// @brief Retrieve the depth+stencil texture, creating one if needed.
43 std::shared_ptr<Texture> GetDepthStencilTexture();
44
45 private:
46 std::shared_ptr<Allocator> allocator_;
47 ISize size_ = {0, 0};
48 PixelFormat format_ = PixelFormat::kUnknown;
49 std::shared_ptr<Texture> resolve_tex_;
50 std::shared_ptr<Texture> msaa_tex_;
51 std::shared_ptr<Texture> depth_stencil_tex_;
52 };
53
54 } // namespace impeller
55
56 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_SWAPCHAIN_TRANSIENTS_MTL_H_
impeller::SwapchainTransientsMTL
A cache for the onscreen texture attachments used in surface_mtl.
Definition: swapchain_transients_mtl.h:25
impeller::SwapchainTransientsMTL::SwapchainTransientsMTL
SwapchainTransientsMTL(const std::shared_ptr< Allocator > &allocator)
Definition: swapchain_transients_mtl.mm:12
impeller::SwapchainTransientsMTL::~SwapchainTransientsMTL
~SwapchainTransientsMTL()
impeller::SwapchainTransientsMTL::GetResolveTexture
std::shared_ptr< Texture > GetResolveTexture()
Retrieve the resolve texture, creating one if needed.
Definition: swapchain_transients_mtl.mm:28
impeller::SwapchainTransientsMTL::SetSizeAndFormat
void SetSizeAndFormat(ISize size, PixelFormat format)
Update the size and pixel format of the onscreens.
Definition: swapchain_transients_mtl.mm:18
impeller::SwapchainTransientsMTL::GetMSAATexture
std::shared_ptr< Texture > GetMSAATexture()
Retrieve the MSAA texture, creating one if needed.
Definition: swapchain_transients_mtl.mm:50
impeller::SwapchainTransientsMTL::GetDepthStencilTexture
std::shared_ptr< Texture > GetDepthStencilTexture()
Retrieve the depth+stencil texture, creating one if needed.
Definition: swapchain_transients_mtl.mm:71
formats.h
impeller
Definition: allocation.cc:12
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
impeller::PixelFormat::kUnknown
@ kUnknown
rect.h
context.h
surface.h
size.h
impeller::TSize
Definition: size.h:25