@@ -70,15 +70,15 @@ class LayerStateStack {
7070 // outstanding attributes.
7171 // (Currently only opacity is recorded for batching)
7272 void applyImageFilter (const SkRect& bounds,
73- const std::shared_ptr<const DlImageFilter> filter);
73+ const std::shared_ptr<const DlImageFilter>& filter);
7474
7575 // Records the color filter for application at the next call to
7676 // saveLayer or applyState. A saveLayer may be executed at
7777 // this time if the color filter cannot be batched with other
7878 // outstanding attributes.
7979 // (Currently only opacity is recorded for batching)
8080 void applyColorFilter (const SkRect& bounds,
81- const std::shared_ptr<const DlColorFilter> filter);
81+ const std::shared_ptr<const DlColorFilter>& filter);
8282
8383 // Saves the state stack and immediately executes a saveLayer
8484 // with the indicated backdrop filter and any outstanding
@@ -89,7 +89,7 @@ class LayerStateStack {
8989 // subsequent canvas or builder objects that are made delegates
9090 // will only see a saveLayer with the indicated blend_mode.
9191 void applyBackdropFilter (const SkRect& bounds,
92- const std::shared_ptr<const DlImageFilter> filter,
92+ const std::shared_ptr<const DlImageFilter>& filter,
9393 DlBlendMode blend_mode);
9494
9595 void translate (SkScalar tx, SkScalar ty);
@@ -122,11 +122,11 @@ class LayerStateStack {
122122
123123 SkScalar outstanding_opacity () { return outstanding_.opacity ; }
124124
125- const std::shared_ptr<const DlColorFilter> outstanding_color_filter () {
125+ std::shared_ptr<const DlColorFilter> outstanding_color_filter () {
126126 return outstanding_.color_filter ;
127127 }
128128
129- const std::shared_ptr<const DlImageFilter> outstanding_image_filter () {
129+ std::shared_ptr<const DlImageFilter> outstanding_image_filter () {
130130 return outstanding_.image_filter ;
131131 }
132132
@@ -165,11 +165,11 @@ class LayerStateStack {
165165 void push_attributes ();
166166 void push_opacity (const SkRect& rect, SkScalar opacity);
167167 void push_color_filter (const SkRect& bounds,
168- const std::shared_ptr<const DlColorFilter> filter);
168+ const std::shared_ptr<const DlColorFilter>& filter);
169169 void push_image_filter (const SkRect& bounds,
170- const std::shared_ptr<const DlImageFilter> filter);
170+ const std::shared_ptr<const DlImageFilter>& filter);
171171 void push_backdrop (const SkRect& bounds,
172- const std::shared_ptr<const DlImageFilter> filter,
172+ const std::shared_ptr<const DlImageFilter>& filter,
173173 DlBlendMode blend_mode);
174174
175175 void push_translate (SkScalar tx, SkScalar ty);
@@ -194,17 +194,10 @@ class LayerStateStack {
194194 void maybe_save_layer_for_clip ();
195195 void maybe_save_layer (int apply_flags);
196196 void maybe_save_layer (SkScalar opacity);
197- void maybe_save_layer (const std::shared_ptr<const DlColorFilter> filter);
198- void maybe_save_layer (const std::shared_ptr<const DlImageFilter> filter);
197+ void maybe_save_layer (const std::shared_ptr<const DlColorFilter>& filter);
198+ void maybe_save_layer (const std::shared_ptr<const DlImageFilter>& filter);
199199 // ---------------------
200200
201- static std::optional<SkRect> OptionalBounds (const SkRect* bounds) {
202- return bounds ? std::make_optional<SkRect>(*bounds) : std::nullopt ;
203- }
204- static const SkRect* BoundsPtr (const std::optional<SkRect>& bounds) {
205- return bounds.has_value () ? &bounds.value () : nullptr ;
206- }
207-
208201 struct RenderingAttributes {
209202 // We need to record the last bounds we received for the last
210203 // attribute that we recorded so that we can perform a saveLayer
@@ -322,7 +315,7 @@ class LayerStateStack {
322315 class ImageFilterEntry : public StateEntry {
323316 public:
324317 ImageFilterEntry (const SkRect& bounds,
325- const std::shared_ptr<const DlImageFilter> filter)
318+ const std::shared_ptr<const DlImageFilter>& filter)
326319 : bounds_(bounds), filter_(filter) {}
327320 ~ImageFilterEntry () override = default ;
328321
@@ -338,7 +331,7 @@ class LayerStateStack {
338331 class ColorFilterEntry : public StateEntry {
339332 public:
340333 ColorFilterEntry (const SkRect& bounds,
341- const std::shared_ptr<const DlColorFilter> filter)
334+ const std::shared_ptr<const DlColorFilter>& filter)
342335 : bounds_(bounds), filter_(filter) {}
343336 ~ColorFilterEntry () override = default ;
344337
@@ -354,7 +347,7 @@ class LayerStateStack {
354347 class BackdropFilterEntry : public SaveLayerEntry {
355348 public:
356349 BackdropFilterEntry (const SkRect& bounds,
357- const std::shared_ptr<const DlImageFilter> filter,
350+ const std::shared_ptr<const DlImageFilter>& filter,
358351 DlBlendMode blend_mode,
359352 bool checkerboard)
360353 : SaveLayerEntry(bounds, blend_mode, checkerboard), filter_(filter) {}
0 commit comments