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

Unified Diff: tests/ImageFilterTest.cpp

Issue 1301823005: Reland of Implement canComputeFastBounds() for image filters. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkRectShaderImageFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageFilterTest.cpp
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index d822212ac6ff41acd4a7301ea16cb6057de336e7..c15d719a64212dc8a552dbd485e0d8a76dcd837a 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -30,6 +30,7 @@
#include "SkReadBuffer.h"
#include "SkRect.h"
#include "SkRectShaderImageFilter.h"
+#include "SkTableColorFilter.h"
#include "SkTileImageFilter.h"
#include "SkXfermodeImageFilter.h"
#include "Test.h"
@@ -1159,6 +1160,58 @@
REPORTER_ASSERT(reporter, result.height() == 30);
}
+DEF_TEST(ImageFilterCanComputeFastBounds, reporter) {
+
+ SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
+ SkAutoTUnref<SkImageFilter> lighting(SkLightingImageFilter::CreatePointLitDiffuse(
+ location, SK_ColorGREEN, 0, 0));
+ REPORTER_ASSERT(reporter, !lighting->canComputeFastBounds());
+
+ SkAutoTUnref<SkImageFilter> gray(make_grayscale(nullptr, nullptr));
+ REPORTER_ASSERT(reporter, gray->canComputeFastBounds());
+ {
+ SkColorFilter* grayCF;
+ REPORTER_ASSERT(reporter, gray->asAColorFilter(&grayCF));
+ REPORTER_ASSERT(reporter, !grayCF->affectsTransparentBlack());
+ grayCF->unref();
+ }
+ REPORTER_ASSERT(reporter, gray->canComputeFastBounds());
+
+ SkAutoTUnref<SkImageFilter> grayBlur(SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1, gray.get()));
+ REPORTER_ASSERT(reporter, grayBlur->canComputeFastBounds());
+
+ SkScalar greenMatrix[20] = { 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1 };
+ SkAutoTUnref<SkColorFilter> greenCF(SkColorMatrixFilter::Create(greenMatrix));
+ SkAutoTUnref<SkImageFilter> green(SkColorFilterImageFilter::Create(greenCF));
+
+ REPORTER_ASSERT(reporter, greenCF->affectsTransparentBlack());
+ REPORTER_ASSERT(reporter, !green->canComputeFastBounds());
+
+ SkAutoTUnref<SkImageFilter> greenBlur(SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1, green.get()));
+ REPORTER_ASSERT(reporter, !greenBlur->canComputeFastBounds());
+
+ uint8_t allOne[256], identity[256];
+ for (int i = 0; i < 256; ++i) {
+ identity[i] = i;
+ allOne[i] = 255;
+ }
+
+ SkAutoTUnref<SkColorFilter> identityCF(
+ SkTableColorFilter::CreateARGB(identity, identity, identity, allOne));
+ SkAutoTUnref<SkImageFilter> identityFilter(SkColorFilterImageFilter::Create(identityCF.get()));
+ REPORTER_ASSERT(reporter, !identityCF->affectsTransparentBlack());
+ REPORTER_ASSERT(reporter, identityFilter->canComputeFastBounds());
+
+ SkAutoTUnref<SkColorFilter> forceOpaqueCF(
+ SkTableColorFilter::CreateARGB(allOne, identity, identity, identity));
+ SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(forceOpaqueCF.get()));
+ REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack());
+ REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds());
+}
+
#if SK_SUPPORT_GPU
DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) {
« no previous file with comments | « src/effects/SkRectShaderImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698