Skip to content

Commit

Permalink
[Impeller] wire up bdf and blend detection in experimental canvas. (#…
Browse files Browse the repository at this point in the history
…53151)

Use the flags in #53104 + context capabilities to determine if we need to begin the first pass as an offscreen.

Part of flutter/flutter#142054
  • Loading branch information
jonahwilliams committed Jun 4, 2024
1 parent 3dd4015 commit 7a55478
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
25 changes: 20 additions & 5 deletions impeller/display_list/dl_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
#include "impeller/display_list/dl_vertices_geometry.h"
#include "impeller/display_list/nine_patch_converter.h"
#include "impeller/display_list/skia_conversions.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/contents/filters/filter_contents.h"
#include "impeller/entity/contents/filters/inputs/filter_input.h"
#include "impeller/entity/contents/runtime_effect_contents.h"
#include "impeller/entity/entity.h"
#include "impeller/geometry/color.h"
#include "impeller/geometry/path.h"
#include "impeller/geometry/path_builder.h"
#include "impeller/geometry/scalar.h"
Expand Down Expand Up @@ -1170,11 +1172,24 @@ Canvas& DlDispatcher::GetCanvas() {
return canvas_;
}

ExperimentalDlDispatcher::ExperimentalDlDispatcher(ContentContext& renderer,
RenderTarget& render_target,
bool requires_readback,
IRect cull_rect)
: canvas_(renderer, render_target, requires_readback, cull_rect) {}
static bool RequiresReadbackForBlends(
const ContentContext& renderer,
flutter::DlBlendMode max_root_blend_mode) {
return !renderer.GetDeviceCapabilities().SupportsFramebufferFetch() &&
ToBlendMode(max_root_blend_mode) > Entity::kLastPipelineBlendMode;
}

ExperimentalDlDispatcher::ExperimentalDlDispatcher(
ContentContext& renderer,
RenderTarget& render_target,
bool has_root_backdrop_filter,
flutter::DlBlendMode max_root_blend_mode,
IRect cull_rect)
: canvas_(renderer,
render_target,
has_root_backdrop_filter ||
RequiresReadbackForBlends(renderer, max_root_blend_mode),
cull_rect) {}

Canvas& ExperimentalDlDispatcher::GetCanvas() {
return canvas_;
Expand Down
4 changes: 3 additions & 1 deletion impeller/display_list/dl_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "impeller/aiks/experimental_canvas.h"
#include "impeller/aiks/paint.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/geometry/color.h"

namespace impeller {

Expand Down Expand Up @@ -291,7 +292,8 @@ class ExperimentalDlDispatcher : public DlDispatcherBase {
public:
ExperimentalDlDispatcher(ContentContext& renderer,
RenderTarget& render_target,
bool requires_readback,
bool has_root_backdrop_filter,
flutter::DlBlendMode max_root_blend_mode,
IRect cull_rect);

~ExperimentalDlDispatcher() = default;
Expand Down
4 changes: 3 additions & 1 deletion impeller/display_list/dl_playground.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ bool DlPlayground::OpenPlaygroundHere(DisplayListPlaygroundCallback callback) {
list->Dispatch(collector);

ExperimentalDlDispatcher impeller_dispatcher(
context.GetContentContext(), render_target, IRect::MakeMaximum());
context.GetContentContext(), render_target,
display_list->root_has_backdrop_filter(),
display_list->max_root_blend_mode(), IRect::MakeMaximum());
list->Dispatch(impeller_dispatcher);
impeller_dispatcher.FinishRecording();
context.GetContentContext().GetTransientsBuffer().Reset();
Expand Down
6 changes: 3 additions & 3 deletions shell/gpu/gpu_surface_metal_impeller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@

impeller::IRect cull_rect = surface->coverage();
SkIRect sk_cull_rect = SkIRect::MakeWH(cull_rect.GetWidth(), cull_rect.GetHeight());
[[maybe_unused]] auto supports_readback =
surface_frame.framebuffer_info().supports_readback;

#if ENABLE_EXPERIMENTAL_CANVAS
impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(),
Expand All @@ -176,7 +174,9 @@
fml::MakeCopyable([aiks_context, &display_list, &cull_rect,
&sk_cull_rect](impeller::RenderTarget& render_target) -> bool {
impeller::ExperimentalDlDispatcher impeller_dispatcher(
aiks_context->GetContentContext(), render_target, supports_readback, cull_rect);
aiks_context->GetContentContext(), render_target,
display_list->root_has_backdrop_filter(), display_list->max_root_blend_mode(),
cull_rect);
display_list->Dispatch(impeller_dispatcher, sk_cull_rect);
impeller_dispatcher.FinishRecording();
aiks_context->GetContentContext().GetTransientsBuffer().Reset();
Expand Down
5 changes: 2 additions & 3 deletions shell/gpu/gpu_surface_vulkan_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceVulkanImpeller::AcquireFrame(

auto cull_rect =
surface->GetTargetRenderPassDescriptor().GetRenderTargetSize();
[[maybe_unused]] auto supports_readback =
surface_frame.framebuffer_info().supports_readback;

return renderer->Render(
std::move(surface),
Expand All @@ -99,7 +97,8 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceVulkanImpeller::AcquireFrame(
SkIRect::MakeWH(cull_rect.width, cull_rect.height));
impeller::ExperimentalDlDispatcher impeller_dispatcher(
aiks_context->GetContentContext(), render_target,
supports_readback,
display_list->root_has_backdrop_filter(),
display_list->max_root_blend_mode(),
impeller::IRect::RoundOut(
impeller::Rect::MakeSize(cull_rect)));
display_list->Dispatch(
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/embedder/embedder_external_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ bool EmbedderExternalView::Render(const EmbedderRenderTarget& render_target,

impeller::ExperimentalDlDispatcher impeller_dispatcher(
aiks_context->GetContentContext(), *impeller_target,
/*supports_readback=*/false, cull_rect);
display_list->root_has_backdrop_filter(),
display_list->max_root_blend_mode(), cull_rect);
display_list->Dispatch(impeller_dispatcher, sk_cull_rect);
impeller_dispatcher.FinishRecording();
aiks_context->GetContentContext().GetTransientsBuffer().Reset();
Expand Down

0 comments on commit 7a55478

Please sign in to comment.