Commit 42a7d2fa authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Remove filters_origin from cc::Layer

This is no longer used in layer list mode as it has been replaced with
filters_origin on cc::EffectNode. This field was not used in
non-layer-list mode.

Bug: 993936
Change-Id: Ie7aeacdf28da29530d704033ad0cbfa1087c9c4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1956543
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722990}
parent a04d5166
...@@ -58,7 +58,6 @@ struct SameSizeAsLayer : public base::RefCounted<SameSizeAsLayer> { ...@@ -58,7 +58,6 @@ struct SameSizeAsLayer : public base::RefCounted<SameSizeAsLayer> {
SkColor background_color; SkColor background_color;
FilterOperations filters[2]; FilterOperations filters[2];
base::Optional<gfx::RRectF> backdrop_filter_bounds; base::Optional<gfx::RRectF> backdrop_filter_bounds;
gfx::PointF filters_origin;
float backdrop_filter_quality; float backdrop_filter_quality;
gfx::RoundedCornersF corner_radii; gfx::RoundedCornersF corner_radii;
gfx::ScrollOffset scroll_offset; gfx::ScrollOffset scroll_offset;
...@@ -636,16 +635,6 @@ void Layer::SetBackdropFilterQuality(const float quality) { ...@@ -636,16 +635,6 @@ void Layer::SetBackdropFilterQuality(const float quality) {
inputs_.backdrop_filter_quality = quality; inputs_.backdrop_filter_quality = quality;
} }
void Layer::SetFiltersOrigin(const gfx::PointF& filters_origin) {
DCHECK(IsPropertyChangeAllowed());
if (inputs_.filters_origin == filters_origin)
return;
inputs_.filters_origin = filters_origin;
SetSubtreePropertyChanged();
SetPropertyTreesNeedRebuild();
SetNeedsCommit();
}
void Layer::SetRoundedCorner(const gfx::RoundedCornersF& corner_radii) { void Layer::SetRoundedCorner(const gfx::RoundedCornersF& corner_radii) {
DCHECK(IsPropertyChangeAllowed()); DCHECK(IsPropertyChangeAllowed());
if (inputs_.corner_radii == corner_radii) if (inputs_.corner_radii == corner_radii)
......
...@@ -273,14 +273,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -273,14 +273,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
void SetFilters(const FilterOperations& filters); void SetFilters(const FilterOperations& filters);
const FilterOperations& filters() const { return inputs_.filters; } const FilterOperations& filters() const { return inputs_.filters; }
// Set or get the origin to be used when applying the filters given to
// SetFilters(). By default the origin is at the origin of this layer, but
// may be moved positively or negatively relative to that. The origin effects
// any filters which do not apply uniformly to the entire layer and its
// subtree.
void SetFiltersOrigin(const gfx::PointF& origin);
gfx::PointF filters_origin() const { return inputs_.filters_origin; }
// Set or get the list of filters that should be applied to the content this // Set or get the list of filters that should be applied to the content this
// layer and its subtree will be drawn into. The effect is clipped by // layer and its subtree will be drawn into. The effect is clipped by
// backdrop_filter_bounds. // backdrop_filter_bounds.
...@@ -832,7 +824,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -832,7 +824,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
FilterOperations filters; FilterOperations filters;
FilterOperations backdrop_filters; FilterOperations backdrop_filters;
base::Optional<gfx::RRectF> backdrop_filter_bounds; base::Optional<gfx::RRectF> backdrop_filter_bounds;
gfx::PointF filters_origin;
float backdrop_filter_quality; float backdrop_filter_quality;
// Corner clip radius for the 4 corners of the layer in the following order: // Corner clip radius for the 4 corners of the layer in the following order:
......
...@@ -298,10 +298,59 @@ TEST_P(LayerTreeHostFiltersPixelTest, BackdropFilterBlurOutsets) { ...@@ -298,10 +298,59 @@ TEST_P(LayerTreeHostFiltersPixelTest, BackdropFilterBlurOutsets) {
base::FilePath(FILE_PATH_LITERAL("backdrop_filter_blur_outsets.png"))); base::FilePath(FILE_PATH_LITERAL("backdrop_filter_blur_outsets.png")));
} }
class LayerTreeHostFiltersPixelTestGPULayerList class LayerTreeHostImageFiltersPixelTestLayerList
: public LayerTreeHostFiltersPixelTest { : public LayerTreeHostFiltersPixelTest {
public: public:
LayerTreeHostFiltersPixelTestGPULayerList() { SetUseLayerLists(); } LayerTreeHostImageFiltersPixelTestLayerList() { SetUseLayerLists(); }
void SetupTree() override {
SetInitialRootBounds(gfx::Size(200, 200));
LayerTreePixelTest::SetupTree();
Layer* root = layer_tree_host()->root_layer();
scoped_refptr<SolidColorLayer> background =
CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorYELLOW);
CopyProperties(root, background.get());
root->AddChild(background);
scoped_refptr<SolidColorLayer> foreground =
CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorRED);
CopyProperties(root, foreground.get());
root->AddChild(foreground);
EffectNode& effect_node = CreateEffectNode(foreground.get());
float matrix[20] = {0};
// This filter does a red-blue swap, so the foreground becomes blue.
matrix[2] = matrix[6] = matrix[10] = matrix[18] = 1.0f;
// Set up a crop rect to filter the bottom 200x100 pixels of the foreground.
SkImageFilter::CropRect crop_rect(SkRect::MakeXYWH(0, 100, 200, 100));
FilterOperations filters;
filters.Append(FilterOperation::CreateReferenceFilter(
sk_make_sp<ColorFilterPaintFilter>(SkColorFilters::Matrix(matrix),
nullptr, &crop_rect)));
effect_node.filters = filters;
effect_node.render_surface_reason = RenderSurfaceReason::kFilter;
// Move the filters origin up by 100 pixels so the crop rect is applied
// only to the top 100 pixels, not the bottom.
effect_node.filters_origin = gfx::PointF(0.0f, -100.0f);
}
};
INSTANTIATE_TEST_SUITE_P(All,
LayerTreeHostImageFiltersPixelTestLayerList,
::testing::ValuesIn(kRendererTypes));
TEST_P(LayerTreeHostImageFiltersPixelTestLayerList, NonZeroOrigin) {
RunPixelTestWithLayerList(
renderer_type(), base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")));
}
class LayerTreeHostBlurFiltersPixelTestGPULayerList
: public LayerTreeHostFiltersPixelTest {
public:
LayerTreeHostBlurFiltersPixelTestGPULayerList() { SetUseLayerLists(); }
void SetupTree() override { void SetupTree() override {
SetInitialRootBounds(gfx::Size(200, 200)); SetInitialRootBounds(gfx::Size(200, 200));
...@@ -370,10 +419,11 @@ class LayerTreeHostFiltersPixelTestGPULayerList ...@@ -370,10 +419,11 @@ class LayerTreeHostFiltersPixelTestGPULayerList
}; };
INSTANTIATE_TEST_SUITE_P(PixelResourceTest, INSTANTIATE_TEST_SUITE_P(PixelResourceTest,
LayerTreeHostFiltersPixelTestGPULayerList, LayerTreeHostBlurFiltersPixelTestGPULayerList,
::testing::ValuesIn(kRendererTypesGpu)); ::testing::ValuesIn(kRendererTypesGpu));
TEST_P(LayerTreeHostFiltersPixelTestGPULayerList, BackdropFilterBlurOffAxis) { TEST_P(LayerTreeHostBlurFiltersPixelTestGPULayerList,
BackdropFilterBlurOffAxis) {
#if defined(OS_WIN) || defined(ARCH_CPU_ARM64) #if defined(OS_WIN) || defined(ARCH_CPU_ARM64)
#if defined(OS_WIN) #if defined(OS_WIN)
// Windows has 116 pixels off by at most 2: crbug.com/225027 // Windows has 116 pixels off by at most 2: crbug.com/225027
...@@ -516,8 +566,7 @@ TEST_P(LayerTreeHostFiltersPixelTest, ImageFilterClipped) { ...@@ -516,8 +566,7 @@ TEST_P(LayerTreeHostFiltersPixelTest, ImageFilterClipped) {
CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorRED); CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorRED);
background->AddChild(foreground); background->AddChild(foreground);
float matrix[20]; float matrix[20] = {0};
memset(matrix, 0, 20 * sizeof(matrix[0]));
// This filter does a red-blue swap, so the foreground becomes blue. // This filter does a red-blue swap, so the foreground becomes blue.
matrix[2] = matrix[6] = matrix[10] = matrix[18] = 1.0f; matrix[2] = matrix[6] = matrix[10] = matrix[18] = 1.0f;
// We filter only the bottom 200x100 pixels of the foreground. // We filter only the bottom 200x100 pixels of the foreground.
...@@ -544,38 +593,6 @@ TEST_P(LayerTreeHostFiltersPixelTest, ImageFilterClipped) { ...@@ -544,38 +593,6 @@ TEST_P(LayerTreeHostFiltersPixelTest, ImageFilterClipped) {
base::FilePath(FILE_PATH_LITERAL("blue_yellow.png"))); base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")));
} }
TEST_P(LayerTreeHostFiltersPixelTest, ImageFilterNonZeroOrigin) {
scoped_refptr<SolidColorLayer> background =
CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorYELLOW);
scoped_refptr<SolidColorLayer> foreground =
CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorRED);
background->AddChild(foreground);
float matrix[20];
memset(matrix, 0, 20 * sizeof(matrix[0]));
// This filter does a red-blue swap, so the foreground becomes blue.
matrix[2] = matrix[6] = matrix[10] = matrix[18] = 1.0f;
// Set up a crop rec to filter the bottom 200x100 pixels of the foreground.
SkImageFilter::CropRect crop_rect(SkRect::MakeXYWH(0, 100, 200, 100));
FilterOperations filters;
filters.Append(
FilterOperation::CreateReferenceFilter(sk_make_sp<ColorFilterPaintFilter>(
SkColorFilters::Matrix(matrix), nullptr, &crop_rect)));
// Make the foreground layer's render surface be clipped by the background
// layer.
background->SetMasksToBounds(true);
foreground->SetFilters(filters);
// Now move the filters origin up by 100 pixels, so the crop rect is
// applied only to the top 100 pixels, not the bottom.
foreground->SetFiltersOrigin(gfx::PointF(0.0f, -100.0f));
RunPixelTest(renderer_type(), background,
base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")));
}
TEST_P(LayerTreeHostFiltersPixelTest, ImageFilterScaled) { TEST_P(LayerTreeHostFiltersPixelTest, ImageFilterScaled) {
scoped_refptr<SolidColorLayer> background = scoped_refptr<SolidColorLayer> background =
CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE);
......
...@@ -467,7 +467,6 @@ bool PropertyTreeBuilderContext::AddEffectNodeIfNeeded( ...@@ -467,7 +467,6 @@ bool PropertyTreeBuilderContext::AddEffectNodeIfNeeded(
node->backdrop_mask_element_id = layer->mask_layer()->element_id(); node->backdrop_mask_element_id = layer->mask_layer()->element_id();
layer->mask_layer()->SetIsBackdropFilterMask(true); layer->mask_layer()->SetIsBackdropFilterMask(true);
} }
node->filters_origin = layer->filters_origin();
node->trilinear_filtering = layer->trilinear_filtering(); node->trilinear_filtering = layer->trilinear_filtering();
node->has_potential_opacity_animation = has_potential_opacity_animation; node->has_potential_opacity_animation = has_potential_opacity_animation;
node->has_potential_filter_animation = has_potential_filter_animation; node->has_potential_filter_animation = has_potential_filter_animation;
......
...@@ -258,8 +258,6 @@ void GraphicsLayer::SetOffsetFromLayoutObject(const IntSize& offset) { ...@@ -258,8 +258,6 @@ void GraphicsLayer::SetOffsetFromLayoutObject(const IntSize& offset) {
return; return;
offset_from_layout_object_ = offset; offset_from_layout_object_ = offset;
CcLayer()->SetFiltersOrigin(FloatPoint() -
FloatSize(offset_from_layout_object_));
// If the compositing layer offset changes, we need to repaint. // If the compositing layer offset changes, we need to repaint.
SetNeedsDisplay(); SetNeedsDisplay();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment