Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 268d5e4

Browse files
committed
draft for SkColorFilter to DlColorFilter
1 parent e242a80 commit 268d5e4

14 files changed

+59
-90
lines changed

display_list/display_list_builder.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
// found in the LICENSE file.
44

55
#include "flutter/display_list/display_list_builder.h"
6-
#include <cstddef>
76

8-
#include "flutter/display_list/display_list.h"
97
#include "flutter/display_list/display_list_blend_mode.h"
10-
#include "flutter/display_list/display_list_color.h"
118
#include "flutter/display_list/display_list_ops.h"
129

1310
namespace flutter {
@@ -492,7 +489,6 @@ void DisplayListBuilder::saveLayer(const SkRect* bounds,
492489
}
493490
}
494491
}
495-
496492
void DisplayListBuilder::saveLayer(const SkRect* bounds,
497493
const DlPaint* paint,
498494
const DlImageFilter* backdrop) {

display_list/display_list_builder.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "flutter/display_list/display_list.h"
99
#include "flutter/display_list/display_list_blend_mode.h"
10-
#include "flutter/display_list/display_list_color_filter.h"
1110
#include "flutter/display_list/display_list_comparable.h"
1211
#include "flutter/display_list/display_list_dispatcher.h"
1312
#include "flutter/display_list/display_list_flags.h"
@@ -170,7 +169,6 @@ class DisplayListBuilder final : public virtual Dispatcher,
170169
void saveLayer(const SkRect* bounds,
171170
const DlPaint* paint,
172171
const DlImageFilter* backdrop = nullptr);
173-
174172
void restore() override;
175173
int getSaveCount() { return layer_stack_.size(); }
176174
void restoreToCount(int restore_count);

display_list/display_list_canvas_dispatcher.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "flutter/display_list/display_list_blend_mode.h"
88
#include "flutter/fml/trace_event.h"
9-
#include "include/core/SkColorFilter.h"
109

1110
namespace flutter {
1211

display_list/display_list_dispatcher.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class Dispatcher {
7575
virtual void saveLayer(const SkRect* bounds,
7676
const SaveLayerOptions options,
7777
const DlImageFilter* backdrop = nullptr) = 0;
78-
7978
virtual void restore() = 0;
8079

8180
virtual void translate(SkScalar tx, SkScalar ty) = 0;

display_list/display_list_utils.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ void DisplayListBoundsCalculator::saveLayer(const SkRect* bounds,
345345
AccumulateUnbounded();
346346
}
347347
}
348-
349348
void DisplayListBoundsCalculator::restore() {
350349
if (layer_infos_.size() > 1) {
351350
SkMatrixDispatchHelper::restore();

display_list/display_list_utils.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,11 @@ class DisplayListBoundsCalculator final
508508
// during restore.
509509
class LayerData {
510510
public:
511-
// Construct a LayerData to DisplayListBoundsCalculatorpush on the save
512-
// stack for a |save| or |saveLayer| call. The |outer| parameter is the
513-
// |BoundsAccumulator| that was in use by the stream before this layer was
514-
// pushed on the stack and should be returned when this layer is popped off
511+
// Construct a LayerData to push on the save stack for a |save|
512+
// or |saveLayer| call.
513+
// The |outer| parameter is the |BoundsAccumulator| that was
514+
// in use by the stream before this layer was pushed on the
515+
// stack and should be returned when this layer is popped off
515516
// the stack.
516517
// Some saveLayer calls will process their bounds by a
517518
// |DlImageFilter| when they are restored, but for most

flow/layers/image_filter_layer.cc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
// found in the LICENSE file.
44

55
#include "flutter/flow/layers/image_filter_layer.h"
6-
7-
#include "flutter/display_list/display_list_image_filter.h"
86
#include "flutter/flow/layers/layer.h"
97
#include "flutter/flow/raster_cache_util.h"
108

119
namespace flutter {
1210

13-
ImageFilterLayer::ImageFilterLayer(std::shared_ptr<const DlImageFilter> filter)
11+
ImageFilterLayer::ImageFilterLayer(sk_sp<SkImageFilter> filter)
1412
: CacheableContainerLayer(
1513
RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer),
16-
sk_filter_(filter != nullptr ? filter->skia_object() : nullptr),
17-
transformed_filter_(nullptr),
18-
filter_(std::move(filter)) {}
14+
filter_(std::move(filter)),
15+
transformed_filter_(nullptr) {}
1916

2017
void ImageFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {
2118
DiffContext::AutoSubtreeRestore subtree(context);
@@ -28,7 +25,7 @@ void ImageFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {
2825
}
2926

3027
if (filter_) {
31-
auto filter = sk_filter_->makeWithLocalMatrix(context->GetTransform());
28+
auto filter = filter_->makeWithLocalMatrix(context->GetTransform());
3229
if (filter) {
3330
// This transform will be applied to every child rect in the subtree
3431
context->PushFilterBoundsAdjustment([filter](SkRect rect) {
@@ -65,7 +62,7 @@ void ImageFilterLayer::Preroll(PrerollContext* context,
6562
}
6663

6764
const SkIRect filter_input_bounds = child_bounds.roundOut();
68-
SkIRect filter_output_bounds = sk_filter_->filterBounds(
65+
SkIRect filter_output_bounds = filter_->filterBounds(
6966
filter_input_bounds, SkMatrix::I(), SkImageFilter::kForward_MapDirection);
7067
child_bounds = SkRect::Make(filter_output_bounds);
7168

@@ -75,7 +72,7 @@ void ImageFilterLayer::Preroll(PrerollContext* context,
7572
// So in here we reset the LayerRasterCacheItem cache state.
7673
layer_raster_cache_item_->MarkNotCacheChildren();
7774

78-
transformed_filter_ = sk_filter_->makeWithLocalMatrix(matrix);
75+
transformed_filter_ = filter_->makeWithLocalMatrix(matrix);
7976
if (transformed_filter_) {
8077
layer_raster_cache_item_->MarkCacheChildren();
8178
}
@@ -94,7 +91,7 @@ void ImageFilterLayer::Paint(PaintContext& context) const {
9491
return;
9592
}
9693

97-
cache_paint.setImageFilter(sk_filter_);
94+
cache_paint.setImageFilter(filter_);
9895

9996
// Normally a save_layer is sized to the current layer bounds, but in this
10097
// case the bounds of the child may not be the same as the filtered version

flow/layers/image_filter_layer.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@ namespace flutter {
1313

1414
class ImageFilterLayer : public CacheableContainerLayer {
1515
public:
16-
explicit ImageFilterLayer(std::shared_ptr<const DlImageFilter> filter);
16+
explicit ImageFilterLayer(sk_sp<SkImageFilter> filter);
1717

1818
void Diff(DiffContext* context, const Layer* old_layer) override;
1919

2020
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
2121

2222
void Paint(PaintContext& context) const override;
2323

24-
sk_sp<SkImageFilter> sk_filter() const { return sk_filter_; }
25-
2624
private:
27-
sk_sp<SkImageFilter> sk_filter_;
25+
sk_sp<SkImageFilter> filter_;
2826
sk_sp<SkImageFilter> transformed_filter_;
29-
std::shared_ptr<const DlImageFilter> filter_;
27+
3028
FML_DISALLOW_COPY_AND_ASSIGN(ImageFilterLayer);
3129
};
3230

0 commit comments

Comments
 (0)