5 #ifndef FLUTTER_IMPELLER_DISPLAY_LIST_CANVAS_H_
6 #define FLUTTER_IMPELLER_DISPLAY_LIST_CANVAS_H_
15 #include "flutter/display_list/effects/dl_image_filter.h"
16 #include "flutter/display_list/geometry/dl_path.h"
107 std::unique_ptr<EntityPassTarget> p_entity_pass_target)
126 const Matrix& effect_transform,
132 bool requires_readback);
137 bool requires_readback,
143 bool requires_readback,
150 void SetBackdropData(std::unordered_map<int64_t, BackdropData> backdrop_data,
151 size_t backdrop_count);
161 std::optional<Rect> bounds = std::nullopt,
162 const flutter::DlImageFilter* backdrop_filter =
nullptr,
164 uint32_t total_content_depth =
kMaxDepth,
165 bool can_distribute_opacity =
false,
166 std::optional<int64_t> backdrop_id = std::nullopt);
201 bool reuse_depth =
false);
231 void DrawImage(
const std::shared_ptr<Texture>& image,
237 const std::shared_ptr<Texture>& image,
244 void DrawTextFrame(
const std::shared_ptr<TextFrame>& text_frame,
248 void DrawVertices(
const std::shared_ptr<VerticesGeometry>& vertices,
252 void DrawAtlas(
const std::shared_ptr<AtlasContents>& atlas_contents,
263 uint64_t
GetMaxOpDepth()
const {
return transform_stack_.back().clip_depth; }
288 class RRectLikeBlurShape {
290 virtual ~RRectLikeBlurShape() =
default;
291 virtual std::shared_ptr<SolidRRectLikeBlurContents> BuildBlurContent() = 0;
295 class RRectBlurShape :
public RRectLikeBlurShape {
297 std::shared_ptr<SolidRRectLikeBlurContents> BuildBlurContent()
override;
298 Geometry& BuildGeometry(
Rect rect,
Scalar radius)
override;
301 std::optional<RoundRectGeometry> geom_;
304 class RSuperellipseBlurShape :
public RRectLikeBlurShape {
306 std::shared_ptr<SolidRRectLikeBlurContents> BuildBlurContent()
override;
307 Geometry& BuildGeometry(
Rect rect,
Scalar radius)
override;
310 std::optional<RoundSuperellipseGeometry>
314 ContentContext& renderer_;
315 RenderTarget render_target_;
316 const bool is_onscreen_;
317 bool requires_readback_;
318 EntityPassClipStack clip_coverage_stack_;
320 std::deque<CanvasStackEntry> transform_stack_;
321 std::optional<Rect> initial_cull_rect_;
322 std::vector<LazyRenderingConfig> render_passes_;
323 std::vector<SaveLayerState> save_layer_state_;
330 std::unordered_map<int64_t, BackdropData> backdrop_data_;
340 size_t backdrop_count_ = 0u;
345 std::vector<std::unique_ptr<Geometry>> clip_geometry_;
347 uint64_t current_depth_ = 0u;
349 Point GetGlobalPassPosition()
const;
352 size_t GetClipHeightFloor()
const;
356 bool IsSkipping()
const;
359 void SkipUntilMatchingRestore(
size_t total_content_depth);
361 void SetupRenderPass();
380 std::shared_ptr<Texture> FlipBackdrop(
Point global_pass_position,
381 bool should_remove_texture =
false,
382 bool should_use_onscreen =
false,
383 bool post_depth_increment =
false);
385 bool BlitToOnscreen(
bool is_onscreen =
false);
387 size_t GetClipHeight()
const;
389 void Initialize(std::optional<Rect> cull_rect);
393 void AddRenderEntityWithFiltersToCurrentPass(Entity& entity,
394 const Geometry* geometry,
396 bool reuse_depth =
false);
398 void AddRenderEntityToCurrentPass(Entity& entity,
bool reuse_depth =
false);
400 bool AttemptDrawBlurredRRect(
const Rect& rect,
404 bool AttemptDrawBlurredRSuperellipse(
const Rect& rect,
408 bool AttemptDrawBlurredRRectLike(
const Rect& rect,
411 RRectLikeBlurShape& shape);
417 bool AttemptColorFilterOptimization(
const std::shared_ptr<Texture>& image,
421 const SamplerDescriptor& sampler,
424 bool AttemptBlurredTextOptimization(
425 const std::shared_ptr<TextFrame>& text_frame,
426 const std::shared_ptr<TextContents>& text_contents,
430 RenderPass& GetCurrentRenderPass()
const;
void ClipGeometry(const Geometry &geometry, Entity::ClipOperation clip_op, bool is_aa=true)
static constexpr uint32_t kMaxDepth
void SetBackdropData(std::unordered_map< int64_t, BackdropData > backdrop_data, size_t backdrop_count)
Update the backdrop data used to group together backdrop filters within the same layer.
Canvas(ContentContext &renderer, const RenderTarget &render_target, bool is_onscreen, bool requires_readback)
bool RequiresReadback() const
void DrawRoundSuperellipse(const RoundSuperellipse &rse, const Paint &paint)
std::optional< Rect > GetLocalCoverageLimit() const
Return the culling bounds of the current render target, or nullopt if there is no coverage.
void SaveLayer(const Paint &paint, std::optional< Rect > bounds=std::nullopt, const flutter::DlImageFilter *backdrop_filter=nullptr, ContentBoundsPromise bounds_promise=ContentBoundsPromise::kUnknown, uint32_t total_content_depth=kMaxDepth, bool can_distribute_opacity=false, std::optional< int64_t > backdrop_id=std::nullopt)
const Matrix & GetCurrentTransform() const
void DrawVertices(const std::shared_ptr< VerticesGeometry > &vertices, BlendMode blend_mode, const Paint &paint)
void DrawOval(const Rect &rect, const Paint &paint)
void DrawImageRect(const std::shared_ptr< Texture > &image, Rect source, Rect dest, const Paint &paint, const SamplerDescriptor &sampler={}, SourceRectConstraint src_rect_constraint=SourceRectConstraint::kFast)
void RestoreToCount(size_t count)
size_t GetSaveCount() const
void Concat(const Matrix &transform)
void Transform(const Matrix &transform)
uint64_t GetMaxOpDepth() const
void DrawDashedLine(const Point &p0, const Point &p1, Scalar on_length, Scalar off_length, const Paint &paint)
void DrawDiffRoundRect(const RoundRect &outer, const RoundRect &inner, const Paint &paint)
void DrawPath(const flutter::DlPath &path, const Paint &paint)
std::function< std::shared_ptr< FilterContents >(FilterInput::Ref, const Matrix &effect_transform, Entity::RenderingMode rendering_mode)> BackdropFilterProc
void PreConcat(const Matrix &transform)
void Rotate(Radians radians)
void DrawPoints(const Point points[], uint32_t count, Scalar radius, const Paint &paint, PointStyle point_style)
void DrawTextFrame(const std::shared_ptr< TextFrame > &text_frame, Point position, const Paint &paint)
void DrawImage(const std::shared_ptr< Texture > &image, Point offset, const Paint &paint, const SamplerDescriptor &sampler={})
void DrawPaint(const Paint &paint)
void DrawRoundRect(const RoundRect &rect, const Paint &paint)
void Skew(Scalar sx, Scalar sy)
void Scale(const Vector2 &scale)
uint64_t GetOpDepth() const
void Save(uint32_t total_content_depth=kMaxDepth)
bool SupportsBlitToOnscreen() const
void DrawRect(const Rect &rect, const Paint &paint)
bool EnsureFinalMipmapGeneration() const
void DrawAtlas(const std::shared_ptr< AtlasContents > &atlas_contents, const Paint &paint)
void DrawLine(const Point &p0, const Point &p1, const Paint &paint, bool reuse_depth=false)
void Translate(const Vector3 &offset)
void DrawCircle(const Point ¢er, Scalar radius, const Paint &paint)
void DrawArc(const Arc &arc, const Paint &paint)
SourceRectConstraint
Controls the behavior of the source rectangle given to DrawImageRect.
@ kStrict
Sample only within the source rectangle. May be slower.
@ kFast
Faster, but may sample outside the bounds of the source rectangle.
@ kRound
Points are drawn as squares.
@ kSquare
Points are drawn as circles.
@ kUnknown
The caller makes no claims related to the size of the bounds.
@ kMayClipContents
The caller claims the bounds are a subset of an estimate of the reasonably tight bounds but likely cl...
@ kContainsContents
The caller claims the bounds are a reasonably tight estimate of the coverage of the contents and shou...
std::shared_ptr< Texture > texture_slot
std::shared_ptr< flutter::DlImageFilter > last_backdrop
std::optional< Snapshot > shared_filter_snapshot
Entity::RenderingMode rendering_mode
Scalar distributed_opacity
LazyRenderingConfig(ContentContext &renderer, std::unique_ptr< EntityPassTarget > p_entity_pass_target)
bool IsApplyingClearColor() const
Whether or not the clear color texture can still be updated.
std::unique_ptr< InlinePassContext > inline_pass_context
std::unique_ptr< EntityPassTarget > entity_pass_target
LazyRenderingConfig(ContentContext &renderer, std::unique_ptr< EntityPassTarget > entity_pass_target, std::unique_ptr< InlinePassContext > inline_pass_context)
A 4x4 matrix using column-major storage.
std::vector< Point > points