5#ifndef FLUTTER_IMPELLER_DISPLAY_LIST_CANVAS_H_
6#define FLUTTER_IMPELLER_DISPLAY_LIST_CANVAS_H_
102 std::unique_ptr<EntityPassTarget> p_entity_pass_target);
114 std::unique_ptr<EntityPassTarget> entity_pass_target_;
115 std::unique_ptr<InlinePassContext> inline_pass_context_;
124 const Matrix& effect_transform,
130 bool requires_readback);
135 bool requires_readback,
141 bool requires_readback,
148 void SetBackdropData(std::unordered_map<int64_t, BackdropData> backdrop_data,
149 size_t backdrop_count);
159 std::optional<Rect> bounds = std::nullopt,
162 uint32_t total_content_depth =
kMaxDepth,
163 bool can_distribute_opacity =
false,
164 std::optional<int64_t> backdrop_id = std::nullopt);
199 bool reuse_depth =
false);
235 const std::shared_ptr<Texture>&
image,
242 void DrawTextFrame(
const std::shared_ptr<TextFrame>& text_frame,
246 void DrawVertices(
const std::shared_ptr<VerticesGeometry>& vertices,
250 void DrawAtlas(
const std::shared_ptr<AtlasContents>& atlas_contents,
261 uint64_t
GetMaxOpDepth()
const {
return transform_stack_.back().clip_depth; }
288 virtual ~BlurShape() =
default;
289 virtual Rect GetBounds()
const = 0;
290 virtual std::shared_ptr<SolidBlurContents> BuildBlurContent(
292 virtual const Geometry& BuildDrawGeometry() = 0;
294 class RRectBlurShape;
295 class RSuperellipseBlurShape;
298 ContentContext& renderer_;
299 RenderTarget render_target_;
300 const bool is_onscreen_;
301 bool requires_readback_;
302 EntityPassClipStack clip_coverage_stack_;
304 std::deque<CanvasStackEntry> transform_stack_;
305 std::optional<Rect> initial_cull_rect_;
306 std::vector<LazyRenderingConfig> render_passes_;
307 std::vector<SaveLayerState> save_layer_state_;
314 std::unordered_map<int64_t, BackdropData> backdrop_data_;
324 size_t backdrop_count_ = 0u;
329 std::vector<std::unique_ptr<Geometry>> clip_geometry_;
331 uint64_t current_depth_ = 0u;
333 Point GetGlobalPassPosition()
const;
336 size_t GetClipHeightFloor()
const;
340 bool IsSkipping()
const;
343 void SkipUntilMatchingRestore(
size_t total_content_depth);
345 void SetupRenderPass();
364 std::shared_ptr<Texture> FlipBackdrop(
Point global_pass_position,
365 bool should_remove_texture =
false,
366 bool should_use_onscreen =
false,
367 bool post_depth_increment =
false);
369 bool BlitToOnscreen(
bool is_onscreen =
false);
371 size_t GetClipHeight()
const;
373 void Initialize(std::optional<Rect> cull_rect);
377 void AddRenderEntityWithFiltersToCurrentPass(Entity& entity,
378 const Geometry* geometry,
380 bool reuse_depth =
false);
382 void AddRenderEntityToCurrentPass(Entity& entity,
bool reuse_depth =
false);
386 static bool IsShadowBlurDrawOperation(
const Paint& paint);
388 bool AttemptDrawAntialiasedCircle(
const Point& center,
394 static Scalar GetCommonRRectLikeRadius(
const RoundingRadii& radii);
396 bool AttemptDrawBlurredPathSource(
const PathSource& source,
399 bool AttemptDrawBlurredRRect(
const RoundRect& round_rect,
const Paint& paint);
401 bool AttemptDrawBlurredRSuperellipse(
const RoundSuperellipse& rse,
404 bool AttemptDrawBlur(BlurShape& shape,
const Paint& paint);
410 bool AttemptColorFilterOptimization(
const std::shared_ptr<Texture>&
image,
414 const SamplerDescriptor& sampler,
417 bool AttemptBlurredTextOptimization(
418 const std::shared_ptr<TextFrame>& text_frame,
419 const std::shared_ptr<TextContents>& text_contents,
423 RenderPass& GetCurrentRenderPass()
const;
425 Canvas(
const Canvas&) =
delete;
427 Canvas& operator=(
const Canvas&) =
delete;
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.
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)
bool IsApplyingClearColor() const
Whether or not the clear color texture can still be updated.
EntityPassTarget * GetEntityPassTarget() const
LazyRenderingConfig(LazyRenderingConfig &&)=default
InlinePassContext * GetInlinePassContext() const
FlutterVulkanImage * image
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
A 4x4 matrix using column-major storage.
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
std::vector< Point > points