5#ifndef FLUTTER_FLOW_LAYERS_LAYER_STATE_STACK_H_
6#define FLUTTER_FLOW_LAYERS_LAYER_STATE_STACK_H_
137 layer_state_stack_->restore_to_count(stack_restore_count_);
142 : layer_state_stack_(stack),
143 stack_restore_count_(stack->stack_count()) {
144 if (stack->needs_save_layer(flags)) {
145 stack->save_layer(bounds);
151 const size_t stack_restore_count_;
159 layer_state_stack_->restore_to_count(stack_restore_count_);
180 const std::shared_ptr<DlImageFilter>& filter);
188 const std::shared_ptr<const DlColorFilter>& filter);
199 const std::shared_ptr<DlImageFilter>& filter,
201 std::optional<int64_t> backdrop_id);
215 : layer_state_stack_(stack),
216 stack_restore_count_(stack->stack_count()) {}
220 const size_t stack_restore_count_;
221 bool save_needed_ =
true;
245 int can_apply_flags) {
252 return outstanding_.color_filter;
256 return outstanding_.image_filter;
298 return delegate_->content_culled(content_bounds);
309 bool is_empty()
const {
return state_stack_.empty(); }
312 size_t stack_count()
const {
return state_stack_.size(); }
313 void restore_to_count(
size_t restore_count);
316 void apply_last_entry() { state_stack_.back()->apply(
this); }
323 void push_color_filter(
const DlRect& bounds,
324 const std::shared_ptr<const DlColorFilter>& filter);
325 void push_image_filter(
const DlRect& bounds,
326 const std::shared_ptr<DlImageFilter>& filter);
327 void push_backdrop(
const DlRect& bounds,
328 const std::shared_ptr<DlImageFilter>& filter,
330 std::optional<int64_t> backdrop_id);
334 void push_integral_transform();
336 void push_clip_rect(
const DlRect& rect,
bool is_aa);
337 void push_clip_rrect(
const DlRoundRect& rrect,
bool is_aa);
339 void push_clip_path(
const DlPath&
path,
bool is_aa);
348 bool needs_save_layer(
int flags)
const;
350 void save_layer(
const DlRect& bounds);
351 void maybe_save_layer_for_transform(
bool needs_save);
352 void maybe_save_layer_for_clip(
bool needs_save);
353 void maybe_save_layer(
int apply_flags);
354 void maybe_save_layer(
DlScalar opacity);
355 void maybe_save_layer(
const std::shared_ptr<const DlColorFilter>& filter);
356 void maybe_save_layer(
const std::shared_ptr<DlImageFilter>& filter);
359 struct RenderingAttributes {
372 std::shared_ptr<const DlColorFilter> color_filter;
373 std::shared_ptr<DlImageFilter> image_filter;
378 bool operator==(
const RenderingAttributes& other)
const {
379 return save_layer_bounds == other.save_layer_bounds &&
380 opacity == other.opacity &&
381 Equals(color_filter, other.color_filter) &&
382 Equals(image_filter, other.image_filter);
388 virtual ~StateEntry() =
default;
393 virtual void update_mutators(MutatorsStack* mutators_stack)
const {}
396 StateEntry() =
default;
418 virtual ~Delegate() =
default;
427 virtual void decommission() = 0;
429 virtual DlCanvas* canvas()
const {
return nullptr; }
431 virtual DlRect local_cull_rect()
const = 0;
432 virtual DlRect device_cull_rect()
const = 0;
433 virtual DlMatrix matrix()
const = 0;
434 virtual bool content_culled(
const DlRect& content_bounds)
const = 0;
436 virtual void save() = 0;
437 virtual void saveLayer(
439 RenderingAttributes& attributes,
442 std::optional<int64_t> backdrop_id = std::nullopt) = 0;
443 virtual void restore() = 0;
447 virtual void integralTransform() = 0;
449 virtual void clipRect(
const DlRect& rect,
DlClipOp op,
bool is_aa) = 0;
462 std::vector<std::unique_ptr<StateEntry>> state_stack_;
466 RenderingAttributes outstanding_;
Developer-facing API for rendering anything within the engine.
void applyColorFilter(const DlRect &bounds, const std::shared_ptr< const DlColorFilter > &filter)
void clipPath(const DlPath &path, bool is_aa)
void clipRSuperellipse(const DlRoundSuperellipse &rse, bool is_aa)
void saveLayer(const DlRect &bounds)
void translate(const DlPoint &tp)
void translate(DlScalar tx, DlScalar ty)
void clipRRect(const DlRoundRect &rrect, bool is_aa)
void applyOpacity(const DlRect &bounds, DlScalar opacity)
void clipRect(const DlRect &rect, bool is_aa)
void applyBackdropFilter(const DlRect &bounds, const std::shared_ptr< DlImageFilter > &filter, DlBlendMode blend_mode, std::optional< int64_t > backdrop_id)
void applyImageFilter(const DlRect &bounds, const std::shared_ptr< DlImageFilter > &filter)
DlScalar outstanding_opacity() const
void fill(MutatorsStack *mutators)
DlCanvas * canvas_delegate()
std::shared_ptr< DlImageFilter > outstanding_image_filter() const
DlPaint * fill(DlPaint &paint) const
DlRect device_cull_rect() const
friend class TransformM44Entry
bool painting_is_nop() const
bool content_culled(const DlRect &content_bounds) const
static constexpr int kCallerCanApplyAnything
static constexpr int kCallerCanApplyColorFilter
void set_delegate(DlCanvas *canvas)
void set_preroll_delegate(const DlRect &cull_rect, const DlMatrix &matrix)
AutoRestore applyState(const DlRect &bounds, int can_apply_flags)
std::shared_ptr< const DlColorFilter > outstanding_color_filter() const
DlRect outstanding_bounds() const
static constexpr int kCallerCanApplyImageFilter
const DlMatrix matrix() const
DlRect local_cull_rect() const
static constexpr int kCallerCanApplyOpacity
#define FML_DISALLOW_COPY_ASSIGN_AND_MOVE(TypeName)
impeller::Scalar DlScalar
impeller::RoundRect DlRoundRect
impeller::Matrix DlMatrix
impeller::RoundSuperellipse DlRoundSuperellipse
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
bool Equals(const T *a, const U *b)
impeller::BlendMode DlBlendMode
bool operator==(const T &value, const UniqueObject< T, Traits > &object)
A 4x4 matrix using column-major storage.