Skip to content

Commit

Permalink
[Impeller] experimental canvas bdf support. (#53597)
Browse files Browse the repository at this point in the history
Almost working bdf for experimentcal canvas.

Currently there are some problems with the clip depth, and positioning of the backdrop filter. I think I am not taking the blur transform into account at the very least.

FYI @bdero
  • Loading branch information
jonahwilliams authored Jun 28, 2024
1 parent f828363 commit b6f6e1d
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 65 deletions.
299 changes: 245 additions & 54 deletions impeller/aiks/experimental_canvas.cc

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions impeller/aiks/experimental_canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@

namespace impeller {

struct LazyRenderingConfig {
std::unique_ptr<EntityPassTarget> entity_pass_target;
std::unique_ptr<InlinePassContext> inline_pass_context;

LazyRenderingConfig(ContentContext& renderer,
std::unique_ptr<EntityPassTarget> p_entity_pass_target)
: entity_pass_target(std::move(p_entity_pass_target)) {
inline_pass_context =
std::make_unique<InlinePassContext>(renderer, *entity_pass_target, 0);
}
};

/// This Canvas attempts to translate from display lists to draw calls directly.
///
/// It's not fully implemented yet but if successful it will be replacing the
Expand Down Expand Up @@ -78,10 +90,8 @@ class ExperimentalCanvas : public Canvas {
RenderTarget& render_target_;
const bool requires_readback_;
EntityPassClipStack clip_coverage_stack_;
std::vector<std::unique_ptr<InlinePassContext>> inline_pass_contexts_;
std::vector<std::unique_ptr<EntityPassTarget>> entity_pass_targets_;
std::vector<LazyRenderingConfig> render_passes_;
std::vector<SaveLayerState> save_layer_state_;
std::vector<std::shared_ptr<RenderPass>> render_passes_;

void SetupRenderPass();

Expand Down
4 changes: 4 additions & 0 deletions impeller/aiks/image_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class ImageFilter {
virtual std::shared_ptr<ImageFilter> Clone() const = 0;

virtual void Visit(ImageFilterVisitor& visitor) = 0;

virtual int GetRequiredMipCount() const { return 1; }
};

/*******************************************************************************
Expand All @@ -112,6 +114,8 @@ class BlurImageFilter : public ImageFilter {
// |ImageFilter|
void Visit(ImageFilterVisitor& visitor) override { visitor.Visit(*this); }

int GetRequiredMipCount() const override { return 4; }

private:
Sigma sigma_x_;
Sigma sigma_y_;
Expand Down
10 changes: 6 additions & 4 deletions impeller/display_list/dl_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1313,10 +1313,12 @@ void TextFrameDispatcher::drawTextFrame(
if (text_frame->HasColor()) {
properties.color = paint_.color;
}
renderer_.GetLazyGlyphAtlas()->AddTextFrame(*text_frame, //
matrix_.GetMaxBasisLengthXY(), //
Point(x, y), //
properties //
auto scale =
(matrix_ * Matrix::MakeTranslation(Point(x, y))).GetMaxBasisLengthXY();
renderer_.GetLazyGlyphAtlas()->AddTextFrame(*text_frame, //
scale, //
Point(x, y), //
properties //
);
}

Expand Down
4 changes: 2 additions & 2 deletions impeller/display_list/dl_playground.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ bool DlPlayground::OpenPlaygroundHere(DisplayListPlaygroundCallback callback) {

ExperimentalDlDispatcher impeller_dispatcher(
context.GetContentContext(), render_target,
display_list->root_has_backdrop_filter(),
display_list->max_root_blend_mode(), IRect::MakeMaximum());
list->root_has_backdrop_filter(), list->max_root_blend_mode(),
IRect::MakeMaximum());
list->Dispatch(impeller_dispatcher);
impeller_dispatcher.FinishRecording();
context.GetContentContext().GetTransientsBuffer().Reset();
Expand Down
1 change: 0 additions & 1 deletion impeller/entity/entity_pass_clip_stack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "impeller/entity/entity_pass_clip_stack.h"
#include "impeller/entity/contents/clip_contents.h"
#include "impeller/entity/contents/content_context.h"
#include "impeller/entity/entity.h"

namespace impeller {
Expand Down
4 changes: 3 additions & 1 deletion shell/gpu/gpu_surface_metal_impeller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,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, 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

0 comments on commit b6f6e1d

Please sign in to comment.