5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_SURFACE_MTL_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_SURFACE_MTL_H_
8 #include <QuartzCore/CAMetalLayer.h>
20 #pragma GCC diagnostic push
25 #pragma GCC diagnostic ignored "-Wunguarded-availability-new"
39 const std::shared_ptr<Context>& context,
43 const std::shared_ptr<Context>& context,
45 const std::shared_ptr<SwapchainTransientsMTL>& transients,
46 std::optional<IRect> clip_rect = std::nullopt);
49 const std::shared_ptr<Context>& context,
50 id<MTLTexture> texture,
51 const std::shared_ptr<SwapchainTransientsMTL>& transients,
52 std::optional<IRect> clip_rect,
54 #pragma GCC diagnostic pop
59 id<MTLDrawable>
drawable()
const {
return drawable_; }
68 present_with_transaction_ = present_with_transaction;
78 frame_boundary_ = frame_boundary;
82 std::weak_ptr<Context> context_;
83 std::shared_ptr<Texture> resolve_texture_;
84 id<CAMetalDrawable> drawable_ = nil;
85 std::shared_ptr<Texture> source_texture_;
86 std::shared_ptr<Texture> destination_texture_;
87 bool requires_blit_ =
false;
88 std::optional<IRect> clip_rect_;
89 bool frame_boundary_ =
false;
90 bool present_with_transaction_ =
false;
91 mutable bool prepared_ =
false;
93 static bool ShouldPerformPartialRepaint(std::optional<IRect> damage_rect);
95 SurfaceMTL(
const std::weak_ptr<Context>& context,
97 std::shared_ptr<Texture> resolve_texture,
99 std::shared_ptr<Texture> source_texture,
100 std::shared_ptr<Texture> destination_texture,
102 std::optional<IRect> clip_rect);
bool Present() const override
static std::unique_ptr< SurfaceMTL > MakeFromMetalLayerDrawable(const std::shared_ptr< Context > &context, id< CAMetalDrawable > drawable, const std::shared_ptr< SwapchainTransientsMTL > &transients, std::optional< IRect > clip_rect=std::nullopt)
static id< CAMetalDrawable > GetMetalDrawableAndValidate(const std::shared_ptr< Context > &context, CAMetalLayer *layer)
Wraps the current drawable of the given Metal layer to create a surface Impeller can render to....
void PresentWithTransaction(bool present_with_transaction)
void SetFrameBoundary(bool frame_boundary)
bool PreparePresent() const
Perform the final blit and trigger end of frame workloads.
static std::unique_ptr< SurfaceMTL > MakeFromTexture(const std::shared_ptr< Context > &context, id< MTLTexture > texture, const std::shared_ptr< SwapchainTransientsMTL > &transients, std::optional< IRect > clip_rect, id< CAMetalDrawable > drawable=nil)
id< MTLDrawable > drawable() const