#include <surface_mtl.h>
Definition at line 17 of file surface_mtl.h.
◆ ~SurfaceMTL()
| impeller::SurfaceMTL::~SurfaceMTL |
( |
| ) |
|
|
overridedefault |
◆ coverage()
| IRect impeller::SurfaceMTL::coverage |
( |
| ) |
const |
◆ drawable()
| id<MTLDrawable> impeller::SurfaceMTL::drawable |
( |
| ) |
const |
|
inline |
◆ GetMetalDrawableAndValidate()
| id< CAMetalDrawable > impeller::SurfaceMTL::GetMetalDrawableAndValidate |
( |
const std::shared_ptr< Context > & |
context, |
|
|
CAMetalLayer * |
layer |
|
) |
| |
|
static |
Wraps the current drawable of the given Metal layer to create a surface Impeller can render to. The surface must be created as late as possible and discarded immediately after rendering to it.
- Parameters
-
| [in] | context | The context |
| [in] | layer | The layer whose current drawable to wrap to create a surface. |
- Returns
- A pointer to the wrapped surface or null.
Definition at line 21 of file surface_mtl.mm.
24 TRACE_EVENT0(
"impeller",
"SurfaceMTL::WrapCurrentMetalLayerDrawable");
26 if (context ==
nullptr || !context->IsValid() || layer == nil) {
30 id<CAMetalDrawable> current_drawable = nil;
32 TRACE_EVENT0(
"impeller",
"WaitForNextDrawable");
33 current_drawable = [layer nextDrawable];
36 if (!current_drawable) {
40 return current_drawable;
References VALIDATION_LOG.
◆ MakeFromMetalLayerDrawable()
| std::unique_ptr< SurfaceMTL > impeller::SurfaceMTL::MakeFromMetalLayerDrawable |
( |
const std::shared_ptr< Context > & |
context, |
|
|
id< CAMetalDrawable > |
drawable, |
|
|
std::optional< IRect > |
clip_rect = std::nullopt |
|
) |
| |
|
static |
◆ MakeFromTexture()
| std::unique_ptr< SurfaceMTL > impeller::SurfaceMTL::MakeFromTexture |
( |
const std::shared_ptr< Context > & |
context, |
|
|
id< MTLTexture > |
texture, |
|
|
std::optional< IRect > |
clip_rect, |
|
|
id< CAMetalDrawable > |
drawable = nil |
|
) |
| |
|
static |
Definition at line 127 of file surface_mtl.mm.
132 bool partial_repaint_blit_required = ShouldPerformPartialRepaint(clip_rect);
139 partial_repaint_blit_required, clip_rect);
140 if (!render_target) {
147 auto source_texture = partial_repaint_blit_required
148 ? render_target->GetRenderTargetTexture()
153 std::shared_ptr<Texture> destination_texture;
154 if (partial_repaint_blit_required) {
158 auto destination_descriptor =
159 render_target->GetRenderTargetTexture()->GetTextureDescriptor();
160 destination_descriptor.size = {
static_cast<ISize::Type>(texture.width),
166 destination_texture = render_target->GetRenderTargetTexture();
169 return std::unique_ptr<SurfaceMTL>(
new SurfaceMTL(
172 render_target->GetRenderTargetTexture(),
176 partial_repaint_blit_required,
References drawable(), impeller::TextureMTL::Wrapper(), and impeller::WrapTextureWithRenderTarget().
Referenced by MakeFromMetalLayerDrawable().
◆ Present()
| bool impeller::SurfaceMTL::Present |
( |
| ) |
const |
|
overridevirtual |
Reimplemented from impeller::Surface.
Definition at line 222 of file surface_mtl.mm.
223 auto context = context_.lock();
228 if (requires_blit_) {
229 if (!(source_texture_ && destination_texture_)) {
233 auto blit_command_buffer = context->CreateCommandBuffer();
234 if (!blit_command_buffer) {
237 auto blit_pass = blit_command_buffer->CreateBlitPass();
238 if (!clip_rect_.has_value()) {
242 blit_pass->AddCopy(source_texture_, destination_texture_, std::nullopt,
244 blit_pass->EncodeCommands(context->GetResourceAllocator());
245 if (!blit_command_buffer->SubmitCommands()) {
251 id<MTLCommandBuffer> command_buffer =
257 if ([[NSThread currentThread] isMainThread] ||
258 [[MTLCaptureManager sharedCaptureManager] isCapturing]) {
259 TRACE_EVENT0(
"flutter",
"waitUntilScheduled");
260 [command_buffer commit];
261 [command_buffer waitUntilScheduled];
264 [command_buffer presentDrawable:drawable_];
265 [command_buffer commit];
References impeller::BackendCast< ContextMTL, Context >::Cast(), impeller::ContextMTL::CreateMTLCommandBuffer(), and VALIDATION_LOG.
The documentation for this class was generated from the following files: