From ac61cb770be8de25736580c1e72684030e8e7bec Mon Sep 17 00:00:00 2001 From: Michael Reed Date: Tue, 2 Feb 2021 09:43:54 -0500 Subject: [PATCH] Update to sampling versions (flutter/engine#24125) Co-authored-by: Mike Reed --- engine/src/flutter/flow/instrumentation.cc | 3 +-- .../layers/image_filter_layer_unittests.cc | 24 ++++++++++++------- .../flutter/lib/ui/painting/image_filter.cc | 7 +++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/engine/src/flutter/flow/instrumentation.cc b/engine/src/flutter/flow/instrumentation.cc index 541b8635b6..49a05a9aa4 100644 --- a/engine/src/flutter/flow/instrumentation.cc +++ b/engine/src/flutter/flow/instrumentation.cc @@ -225,8 +225,7 @@ void Stopwatch::Visualize(SkCanvas* canvas, const SkRect& rect) const { prev_drawn_sample_index_ = current_sample_; // Draw the cached surface onto the output canvas. - paint.reset(); - visualize_cache_surface_->draw(canvas, rect.x(), rect.y(), &paint); + visualize_cache_surface_->draw(canvas, rect.x(), rect.y()); } CounterValues::CounterValues() : current_sample_(kMaxSamples - 1) { diff --git a/engine/src/flutter/flow/layers/image_filter_layer_unittests.cc b/engine/src/flutter/flow/layers/image_filter_layer_unittests.cc index 68664dbb98..c2cab8d3f6 100644 --- a/engine/src/flutter/flow/layers/image_filter_layer_unittests.cc +++ b/engine/src/flutter/flow/layers/image_filter_layer_unittests.cc @@ -75,7 +75,8 @@ TEST_F(ImageFilterLayerTest, SimpleFilter) { const SkPath child_path = SkPath().addRect(child_bounds); const SkPaint child_paint = SkPaint(SkColors::kYellow); auto layer_filter = SkImageFilters::MatrixTransform( - SkMatrix(), SkFilterQuality::kMedium_SkFilterQuality, nullptr); + SkMatrix(), + SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), nullptr); auto mock_layer = std::make_shared(child_path, child_paint); auto layer = std::make_shared(layer_filter); layer->Add(mock_layer); @@ -109,7 +110,8 @@ TEST_F(ImageFilterLayerTest, SimpleFilterBounds) { const SkPaint child_paint = SkPaint(SkColors::kYellow); const SkMatrix filter_transform = SkMatrix::Scale(2.0, 2.0); auto layer_filter = SkImageFilters::MatrixTransform( - filter_transform, SkFilterQuality::kMedium_SkFilterQuality, nullptr); + filter_transform, + SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), nullptr); auto mock_layer = std::make_shared(child_path, child_paint); auto layer = std::make_shared(layer_filter); layer->Add(mock_layer); @@ -144,7 +146,8 @@ TEST_F(ImageFilterLayerTest, MultipleChildren) { const SkPaint child_paint1 = SkPaint(SkColors::kYellow); const SkPaint child_paint2 = SkPaint(SkColors::kCyan); auto layer_filter = SkImageFilters::MatrixTransform( - SkMatrix(), SkFilterQuality::kMedium_SkFilterQuality, nullptr); + SkMatrix(), + SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), nullptr); auto mock_layer1 = std::make_shared(child_path1, child_paint1); auto mock_layer2 = std::make_shared(child_path2, child_paint2); auto layer = std::make_shared(layer_filter); @@ -189,9 +192,11 @@ TEST_F(ImageFilterLayerTest, Nested) { const SkPaint child_paint1 = SkPaint(SkColors::kYellow); const SkPaint child_paint2 = SkPaint(SkColors::kCyan); auto layer_filter1 = SkImageFilters::MatrixTransform( - SkMatrix(), SkFilterQuality::kMedium_SkFilterQuality, nullptr); + SkMatrix(), + SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), nullptr); auto layer_filter2 = SkImageFilters::MatrixTransform( - SkMatrix(), SkFilterQuality::kMedium_SkFilterQuality, nullptr); + SkMatrix(), + SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), nullptr); auto mock_layer1 = std::make_shared(child_path1, child_paint1); auto mock_layer2 = std::make_shared(child_path2, child_paint2); auto layer1 = std::make_shared(layer_filter1); @@ -242,7 +247,8 @@ TEST_F(ImageFilterLayerTest, Nested) { TEST_F(ImageFilterLayerTest, Readback) { auto layer_filter = SkImageFilters::MatrixTransform( - SkMatrix(), SkFilterQuality::kMedium_SkFilterQuality, nullptr); + SkMatrix(), + SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), nullptr); auto initial_transform = SkMatrix(); // ImageFilterLayer does not read from surface @@ -262,7 +268,8 @@ TEST_F(ImageFilterLayerTest, Readback) { TEST_F(ImageFilterLayerTest, ChildIsCached) { auto layer_filter = SkImageFilters::MatrixTransform( - SkMatrix(), SkFilterQuality::kMedium_SkFilterQuality, nullptr); + SkMatrix(), + SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), nullptr); auto initial_transform = SkMatrix::Translate(50.0, 25.5); auto other_transform = SkMatrix::Scale(1.0, 2.0); const SkPath child_path = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f)); @@ -291,7 +298,8 @@ TEST_F(ImageFilterLayerTest, ChildIsCached) { TEST_F(ImageFilterLayerTest, ChildrenNotCached) { auto layer_filter = SkImageFilters::MatrixTransform( - SkMatrix(), SkFilterQuality::kMedium_SkFilterQuality, nullptr); + SkMatrix(), + SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), nullptr); auto initial_transform = SkMatrix::Translate(50.0, 25.5); auto other_transform = SkMatrix::Scale(1.0, 2.0); const SkPath child_path1 = SkPath().addRect(SkRect::MakeWH(5.0f, 5.0f)); diff --git a/engine/src/flutter/lib/ui/painting/image_filter.cc b/engine/src/flutter/lib/ui/painting/image_filter.cc index 4a3834cb52..08828f490a 100644 --- a/engine/src/flutter/lib/ui/painting/image_filter.cc +++ b/engine/src/flutter/lib/ui/painting/image_filter.cc @@ -60,9 +60,10 @@ void ImageFilter::initBlur(double sigma_x, void ImageFilter::initMatrix(const tonic::Float64List& matrix4, int filterQuality) { - filter_ = SkImageFilters::MatrixTransform( - ToSkMatrix(matrix4), static_cast(filterQuality), - nullptr); + auto sampling = SkSamplingOptions(static_cast(filterQuality), + SkSamplingOptions::kMedium_asMipmapLinear); + filter_ = + SkImageFilters::MatrixTransform(ToSkMatrix(matrix4), sampling, nullptr); } void ImageFilter::initColorFilter(ColorFilter* colorFilter) {