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"
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.
26  public:
27  explicit SwapchainTransientsMTL(const std::shared_ptr<Allocator>& allocator);
28 
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};
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_
A cache for the onscreen texture attachments used in surface_mtl.
SwapchainTransientsMTL(const std::shared_ptr< Allocator > &allocator)
std::shared_ptr< Texture > GetResolveTexture()
Retrieve the resolve texture, creating one if needed.
void SetSizeAndFormat(ISize size, PixelFormat format)
Update the size and pixel format of the onscreens.
std::shared_ptr< Texture > GetMSAATexture()
Retrieve the MSAA texture, creating one if needed.
std::shared_ptr< Texture > GetDepthStencilTexture()
Retrieve the depth+stencil texture, creating one if needed.
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99