diff --git a/engine/src/flutter/impeller/display_list/canvas.cc b/engine/src/flutter/impeller/display_list/canvas.cc index be12b9a220..aa7cbd2985 100644 --- a/engine/src/flutter/impeller/display_list/canvas.cc +++ b/engine/src/flutter/impeller/display_list/canvas.cc @@ -1681,6 +1681,14 @@ std::shared_ptr Canvas::FlipBackdrop(Point global_pass_position, return input_texture; } +bool Canvas::SupportsBlitToOnscreen() const { + return renderer_.GetContext() + ->GetCapabilities() + ->SupportsTextureToTextureBlits() && + renderer_.GetContext()->GetBackendType() != + Context::BackendType::kOpenGLES; +} + bool Canvas::BlitToOnscreen(bool is_onscreen) { auto command_buffer = renderer_.GetContext()->CreateCommandBuffer(); command_buffer->SetLabel("EntityPass Root Command Buffer"); @@ -1688,9 +1696,7 @@ bool Canvas::BlitToOnscreen(bool is_onscreen) { .inline_pass_context->GetPassTarget() .GetRenderTarget(); - if (renderer_.GetContext() - ->GetCapabilities() - ->SupportsTextureToTextureBlits()) { + if (SupportsBlitToOnscreen()) { auto blit_pass = command_buffer->CreateBlitPass(); blit_pass->AddCopy(offscreen_target.GetRenderTargetTexture(), render_target_.GetRenderTargetTexture()); diff --git a/engine/src/flutter/impeller/display_list/canvas.h b/engine/src/flutter/impeller/display_list/canvas.h index 0b5e76331e..fe3d3b1b7a 100644 --- a/engine/src/flutter/impeller/display_list/canvas.h +++ b/engine/src/flutter/impeller/display_list/canvas.h @@ -251,6 +251,16 @@ class Canvas { // Visible for testing. bool RequiresReadback() const { return requires_readback_; } + // Whether the current device has the capabilities to blit an offscreen + // texture into the onscreen. + // + // This requires the availibility of the blit framebuffer command, but is + // disabled for GLES. A simple glBlitFramebuffer does not support resolving + // different sample counts which may be present in GLES when using MSAA. + // + // Visible for testing. + bool SupportsBlitToOnscreen() const; + private: ContentContext& renderer_; RenderTarget render_target_; diff --git a/engine/src/flutter/impeller/display_list/canvas_unittests.cc b/engine/src/flutter/impeller/display_list/canvas_unittests.cc index bd05de53e4..0ac3c2c3ba 100644 --- a/engine/src/flutter/impeller/display_list/canvas_unittests.cc +++ b/engine/src/flutter/impeller/display_list/canvas_unittests.cc @@ -15,6 +15,7 @@ #include "impeller/display_list/canvas.h" #include "impeller/display_list/dl_vertices_geometry.h" #include "impeller/geometry/geometry_asserts.h" +#include "impeller/playground/playground.h" #include "impeller/renderer/render_target.h" namespace impeller { @@ -372,5 +373,17 @@ TEST_P(AiksTest, DrawVerticesWithEmptyTextureCoordinates) { ASSERT_TRUE(Playground::OpenPlaygroundHere(callback)); } +TEST_P(AiksTest, SupportsBlitToOnscreen) { + ContentContext context(GetContext(), nullptr); + auto canvas = CreateTestCanvas(context, Rect::MakeLTRB(0, 0, 100, 100), + /*requires_readback=*/true); + + if (GetBackend() == PlaygroundBackend::kOpenGLES) { + EXPECT_FALSE(canvas->SupportsBlitToOnscreen()); + } else { + EXPECT_TRUE(canvas->SupportsBlitToOnscreen()); + } +} + } // namespace testing } // namespace impeller