Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/ApplyGammaTest.cpp ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 { 255 {
256 SkPaint paint; 256 SkPaint paint;
257 paint.setShader(SkPerlinNoiseShader::MakeTurbulence(SK_Scalar1, SK_S calar1, 1, 0)); 257 paint.setShader(SkPerlinNoiseShader::MakeTurbulence(SK_Scalar1, SK_S calar1, 1, 0));
258 sk_sp<SkImageFilter> paintFilter(SkPaintImageFilter::Make(paint)); 258 sk_sp<SkImageFilter> paintFilter(SkPaintImageFilter::Make(paint));
259 259
260 this->addFilter("paint and blur", SkBlurImageFilter::Make(five, five , 260 this->addFilter("paint and blur", SkBlurImageFilter::Make(five, five ,
261 std::move( paintFilter), 261 std::move( paintFilter),
262 cropRect)) ; 262 cropRect)) ;
263 } 263 }
264 this->addFilter("xfermode", SkXfermodeImageFilter::Make( 264 this->addFilter("xfermode", SkXfermodeImageFilter::Make(SkBlendMode::kSr c, input, input,
265 SkXfermode::Make(SkXfermode::kSrc_Mode), input, input, cropRect)); 265 cropRect));
266 } 266 }
267 int count() const { return fFilters.count(); } 267 int count() const { return fFilters.count(); }
268 SkImageFilter* getFilter(int index) const { return fFilters[index].fFilter.g et(); } 268 SkImageFilter* getFilter(int index) const { return fFilters[index].fFilter.g et(); }
269 const char* getName(int index) const { return fFilters[index].fName; } 269 const char* getName(int index) const { return fFilters[index].fName; }
270 private: 270 private:
271 struct Filter { 271 struct Filter {
272 Filter() : fName(nullptr) {} 272 Filter() : fName(nullptr) {}
273 Filter(const char* name, sk_sp<SkImageFilter> filter) 273 Filter(const char* name, sk_sp<SkImageFilter> filter)
274 : fName(name) 274 : fName(name)
275 , fFilter(std::move(filter)) { 275 , fFilter(std::move(filter)) {
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 SkRect boundsDst = composedFilter->computeFastBounds(boundsSrc); 931 SkRect boundsDst = composedFilter->computeFastBounds(boundsSrc);
932 932
933 REPORTER_ASSERT(reporter, boundsDst == expectedBounds); 933 REPORTER_ASSERT(reporter, boundsDst == expectedBounds);
934 } 934 }
935 935
936 DEF_TEST(ImageFilterUnionBounds, reporter) { 936 DEF_TEST(ImageFilterUnionBounds, reporter) {
937 sk_sp<SkImageFilter> offset(SkOffsetImageFilter::Make(50, 0, nullptr)); 937 sk_sp<SkImageFilter> offset(SkOffsetImageFilter::Make(50, 0, nullptr));
938 // Regardless of which order they appear in, the image filter bounds should 938 // Regardless of which order they appear in, the image filter bounds should
939 // be combined correctly. 939 // be combined correctly.
940 { 940 {
941 sk_sp<SkImageFilter> composite(SkXfermodeImageFilter::Make(nullptr, offs et)); 941 sk_sp<SkImageFilter> composite(SkXfermodeImageFilter::Make(SkBlendMode:: kSrcOver, offset));
942 SkRect bounds = SkRect::MakeWH(100, 100); 942 SkRect bounds = SkRect::MakeWH(100, 100);
943 // Intentionally aliasing here, as that's what the real callers do. 943 // Intentionally aliasing here, as that's what the real callers do.
944 bounds = composite->computeFastBounds(bounds); 944 bounds = composite->computeFastBounds(bounds);
945 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100)); 945 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100));
946 } 946 }
947 { 947 {
948 sk_sp<SkImageFilter> composite(SkXfermodeImageFilter::Make(nullptr, null ptr, 948 sk_sp<SkImageFilter> composite(SkXfermodeImageFilter::Make(SkBlendMode:: kSrcOver, nullptr,
949 offset, nullp tr)); 949 offset, nullp tr));
950 SkRect bounds = SkRect::MakeWH(100, 100); 950 SkRect bounds = SkRect::MakeWH(100, 100);
951 // Intentionally aliasing here, as that's what the real callers do. 951 // Intentionally aliasing here, as that's what the real callers do.
952 bounds = composite->computeFastBounds(bounds); 952 bounds = composite->computeFastBounds(bounds);
953 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100)); 953 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100));
954 } 954 }
955 } 955 }
956 956
957 static void test_imagefilter_merge_result_size(skiatest::Reporter* reporter, GrC ontext* context) { 957 static void test_imagefilter_merge_result_size(skiatest::Reporter* reporter, GrC ontext* context) {
958 SkBitmap greenBM; 958 SkBitmap greenBM;
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 bitmap.eraseARGB(255, 255, 255, 255); 1425 bitmap.eraseARGB(255, 255, 255, 255);
1426 1426
1427 sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN, 1427 sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN,
1428 SkXfermode::kSrcIn_ Mode)); 1428 SkXfermode::kSrcIn_ Mode));
1429 sk_sp<SkImageFilter> greenFilter(SkColorFilterImageFilter::Make(green, nullp tr)); 1429 sk_sp<SkImageFilter> greenFilter(SkColorFilterImageFilter::Make(green, nullp tr));
1430 SkImageFilter::CropRect cropRect(SkRect::MakeEmpty()); 1430 SkImageFilter::CropRect cropRect(SkRect::MakeEmpty());
1431 sk_sp<SkImageFilter> croppedOut(SkColorFilterImageFilter::Make(green, nullpt r, &cropRect)); 1431 sk_sp<SkImageFilter> croppedOut(SkColorFilterImageFilter::Make(green, nullpt r, &cropRect));
1432 1432
1433 // Check that an xfermode image filter whose input has been cropped out stil l draws the other 1433 // Check that an xfermode image filter whose input has been cropped out stil l draws the other
1434 // input. Also check that drawing with both inputs cropped out doesn't cause a GPU warning. 1434 // input. Also check that drawing with both inputs cropped out doesn't cause a GPU warning.
1435 sk_sp<SkXfermode> mode(SkXfermode::Make(SkXfermode::kSrcOver_Mode)); 1435 SkBlendMode mode = SkBlendMode::kSrcOver;
1436 sk_sp<SkImageFilter> xfermodeNoFg(SkXfermodeImageFilter::Make(mode, greenFil ter, 1436 sk_sp<SkImageFilter> xfermodeNoFg(SkXfermodeImageFilter::Make(mode, greenFil ter,
1437 croppedOut, nu llptr)); 1437 croppedOut, nu llptr));
1438 sk_sp<SkImageFilter> xfermodeNoBg(SkXfermodeImageFilter::Make(mode, croppedO ut, 1438 sk_sp<SkImageFilter> xfermodeNoBg(SkXfermodeImageFilter::Make(mode, croppedO ut,
1439 greenFilter, n ullptr)); 1439 greenFilter, n ullptr));
1440 sk_sp<SkImageFilter> xfermodeNoFgNoBg(SkXfermodeImageFilter::Make(mode, crop pedOut, 1440 sk_sp<SkImageFilter> xfermodeNoFgNoBg(SkXfermodeImageFilter::Make(mode, crop pedOut,
1441 croppedOut , nullptr)); 1441 croppedOut , nullptr));
1442 1442
1443 SkPaint paint; 1443 SkPaint paint;
1444 paint.setImageFilter(std::move(xfermodeNoFg)); 1444 paint.setImageFilter(std::move(xfermodeNoFg));
1445 canvas->drawBitmap(bitmap, 0, 0, &paint); // drawSprite 1445 canvas->drawBitmap(bitmap, 0, 0, &paint); // drawSprite
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 { SkColorFilterImageFilter::Make(cf, blif), false }, 1866 { SkColorFilterImageFilter::Make(cf, blif), false },
1867 { SkMergeImageFilter::Make(cfif, blif), false }, 1867 { SkMergeImageFilter::Make(cfif, blif), false },
1868 { SkComposeImageFilter::Make(blif, cfif), false }, 1868 { SkComposeImageFilter::Make(blif, cfif), false },
1869 }; 1869 };
1870 1870
1871 for (const auto& rec : recs) { 1871 for (const auto& rec : recs) {
1872 const bool canHandle = rec.fFilter->canHandleComplexCTM(); 1872 const bool canHandle = rec.fFilter->canHandleComplexCTM();
1873 REPORTER_ASSERT(reporter, canHandle == rec.fExpectCanHandle); 1873 REPORTER_ASSERT(reporter, canHandle == rec.fExpectCanHandle);
1874 } 1874 }
1875 } 1875 }
OLDNEW
« no previous file with comments | « tests/ApplyGammaTest.cpp ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698