diff options
author | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-01 22:08:00 +0000 |
---|---|---|
committer | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-01 22:08:00 +0000 |
commit | 52844912b438f8c6609a25a42b9807f6a924e690 (patch) | |
tree | c68f195cf23fb4b4ef4fb8067ecab940797ea379 /cc/trees/layer_tree_host_pixeltest_filters.cc | |
parent | 68d1dd345e06e259a086c2ccc186f7f260bbf0d0 (diff) | |
download | chromium_src-52844912b438f8c6609a25a42b9807f6a924e690.zip chromium_src-52844912b438f8c6609a25a42b9807f6a924e690.tar.gz chromium_src-52844912b438f8c6609a25a42b9807f6a924e690.tar.bz2 |
Enable general CSS filters in the software compositor
The software compositor has only supported filters that include a
reference filter. This CL enables support for filters that don't
include a reference filter.
BUG=160302
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=229569
Review URL: https://codereview.chromium.org/24090003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees/layer_tree_host_pixeltest_filters.cc')
-rw-r--r-- | cc/trees/layer_tree_host_pixeltest_filters.cc | 95 |
1 files changed, 51 insertions, 44 deletions
diff --git a/cc/trees/layer_tree_host_pixeltest_filters.cc b/cc/trees/layer_tree_host_pixeltest_filters.cc index 604eabb..d2a6507f9 100644 --- a/cc/trees/layer_tree_host_pixeltest_filters.cc +++ b/cc/trees/layer_tree_host_pixeltest_filters.cc @@ -150,51 +150,58 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) { "background_filter_blur_off_axis.png"))); } -TEST_F(LayerTreeHostFiltersPixelTest, ImageFilterClipped) { - scoped_refptr<SolidColorLayer> root = CreateSolidColorLayer( - gfx::Rect(200, 200), SK_ColorBLACK); - - scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( - gfx::Rect(200, 200), SK_ColorYELLOW); - root->AddChild(background); - - scoped_refptr<SolidColorLayer> foreground = CreateSolidColorLayer( - gfx::Rect(200, 200), SK_ColorRED); - background->AddChild(foreground); - - SkScalar 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] = SK_Scalar1; - skia::RefPtr<SkColorFilter> colorFilter(skia::AdoptRef( - new SkColorMatrixFilter(matrix))); - // We filter only the bottom 200x100 pixels of the foreground. - SkImageFilter::CropRect crop_rect(SkRect::MakeXYWH(0, 100, 200, 100)); - skia::RefPtr<SkImageFilter> filter = - skia::AdoptRef(SkColorFilterImageFilter::Create( - colorFilter.get(), - NULL, - &crop_rect)); - FilterOperations filters; - filters.Append(FilterOperation::CreateReferenceFilter(filter)); - - // Make the foreground layer's render surface be clipped by the background - // layer. - background->SetMasksToBounds(true); - foreground->SetFilters(filters); - - // Then we translate the foreground up by 100 pixels in Y, so the cropped - // region is moved to to the top. This ensures that the crop rect is being - // correctly transformed in skia by the amount of clipping that the - // compositor performs. - gfx::Transform transform; - transform.Translate(0.0, -100.0); - foreground->SetTransform(transform); +class ImageFilterClippedPixelTest : public LayerTreeHostFiltersPixelTest { + protected: + void RunPixelTestType(PixelTestType test_type) { + scoped_refptr<SolidColorLayer> root = + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); + + scoped_refptr<SolidColorLayer> background = + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorYELLOW); + root->AddChild(background); + + scoped_refptr<SolidColorLayer> foreground = + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorRED); + background->AddChild(foreground); + + SkScalar 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] = SK_Scalar1; + skia::RefPtr<SkColorFilter> colorFilter( + skia::AdoptRef(new SkColorMatrixFilter(matrix))); + // We filter only the bottom 200x100 pixels of the foreground. + SkImageFilter::CropRect crop_rect(SkRect::MakeXYWH(0, 100, 200, 100)); + skia::RefPtr<SkImageFilter> filter = skia::AdoptRef( + SkColorFilterImageFilter::Create(colorFilter.get(), NULL, &crop_rect)); + FilterOperations filters; + filters.Append(FilterOperation::CreateReferenceFilter(filter)); + + // Make the foreground layer's render surface be clipped by the background + // layer. + background->SetMasksToBounds(true); + foreground->SetFilters(filters); + + // Then we translate the foreground up by 100 pixels in Y, so the cropped + // region is moved to to the top. This ensures that the crop rect is being + // correctly transformed in skia by the amount of clipping that the + // compositor performs. + gfx::Transform transform; + transform.Translate(0.0, -100.0); + foreground->SetTransform(transform); + + RunPixelTest(test_type, + background, + base::FilePath(FILE_PATH_LITERAL("blue_yellow.png"))); + } +}; + +TEST_F(ImageFilterClippedPixelTest, ImageFilterClipped_GL) { + RunPixelTestType(GL_WITH_BITMAP); +} - RunPixelTest(GL_WITH_BITMAP, - background, - base::FilePath(FILE_PATH_LITERAL( - "blue_yellow.png"))); +TEST_F(ImageFilterClippedPixelTest, ImageFilterClipped_Software) { + RunPixelTestType(SOFTWARE_WITH_BITMAP); } } // namespace |