aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2016-10-03 14:23:50 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-03 18:47:42 +0000
commite2f732f475fbeff9cce2dd4023a183fa2492d2ad (patch)
tree5f40fe94c52ccc93bdf28694569c0a30e332ba1b
parent7de57798358127e959df9255b36f30ec9d7db534 (diff)
Start supplying random color space xforms to FP tests
Added helper to create random GrColorSpaceXforms in unit tests, and hooked it up for the FPs that currently accept one. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2873 Change-Id: Iaf93e379e405fbf745f5e0fd23b4daf017355966 Reviewed-on: https://skia-review.googlesource.com/2873 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
-rw-r--r--include/gpu/GrTestUtils.h2
-rw-r--r--src/effects/GrAlphaThresholdFragmentProcessor.cpp3
-rw-r--r--src/gpu/GrTestUtils.cpp17
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp3
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.cpp3
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp3
6 files changed, 27 insertions, 4 deletions
diff --git a/include/gpu/GrTestUtils.h b/include/gpu/GrTestUtils.h
index 89ac68ae3d..a4fef49728 100644
--- a/include/gpu/GrTestUtils.h
+++ b/include/gpu/GrTestUtils.h
@@ -13,6 +13,7 @@
#ifdef GR_TEST_UTILS
#include "GrColor.h"
+#include "GrColorSpaceXform.h"
#include "SkPathEffect.h"
#include "SkRandom.h"
#include "SkStrokeRec.h"
@@ -41,6 +42,7 @@ const SkPath& TestPathConvex(SkRandom*);
SkStrokeRec TestStrokeRec(SkRandom*);
/** Creates styles with dash path effects and null path effects */
void TestStyle(SkRandom*, GrStyle*);
+sk_sp<GrColorSpaceXform> TestColorXform(SkRandom*);
// We have a simplified dash path effect here to avoid relying on SkDashPathEffect which
// is in the optional build target effects.
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index a35dc6db56..99f0a192fc 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -180,7 +180,8 @@ sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(GrProce
uint32_t x = d->fRandom->nextULessThan(kMaxWidth - width);
uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height);
SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
- return GrAlphaThresholdFragmentProcessor::Make(bmpTex, nullptr, maskTex,
+ auto colorSpaceXform = GrTest::TestColorXform(d->fRandom);
+ return GrAlphaThresholdFragmentProcessor::Make(bmpTex, colorSpaceXform, maskTex,
innerThresh, outerThresh,
bounds);
}
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index d5cdbab1fb..7f5cc50efe 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -7,6 +7,7 @@
#include "GrTestUtils.h"
#include "GrStyle.h"
+#include "SkColorSpace.h"
#include "SkDashPathPriv.h"
#include "SkMatrix.h"
#include "SkPath.h"
@@ -289,6 +290,22 @@ SkPathEffect::DashType TestDashPathEffect::asADash(DashInfo* info) const {
return kDash_DashType;
}
+sk_sp<GrColorSpaceXform> TestColorXform(SkRandom* random) {
+ static sk_sp<GrColorSpaceXform> gXforms[3];
+ static bool gOnce;
+ if (!gOnce) {
+ gOnce = true;
+ sk_sp<SkColorSpace> srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ sk_sp<SkColorSpace> adobe = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named);
+ // No gamut change
+ gXforms[0] = nullptr;
+ // To larger gamut
+ gXforms[1] = GrColorSpaceXform::Make(srgb.get(), adobe.get());
+ // To smaller gamut
+ gXforms[2] = GrColorSpaceXform::Make(adobe.get(), srgb.get());
+ }
+ return gXforms[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gXforms)))];
+}
} // namespace GrTest
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 86726c9058..737625ffed 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -205,7 +205,8 @@ sk_sp<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
for (int i = 0; i < 16; i++) {
coefficients[i] = d->fRandom->nextSScalar1();
}
- return GrBicubicEffect::Make(d->fTextures[texIdx], nullptr, coefficients);
+ auto colorSpaceXform = GrTest::TestColorXform(d->fRandom);
+ return GrBicubicEffect::Make(d->fTextures[texIdx], colorSpaceXform, coefficients);
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index 6eb15e0c31..b05ac834a7 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -91,5 +91,6 @@ sk_sp<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(GrProcessorTestData
GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kCoordSets))];
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
- return GrSimpleTextureEffect::Make(d->fTextures[texIdx], nullptr, matrix, coordSet);
+ auto colorSpaceXform = GrTest::TestColorXform(d->fRandom);
+ return GrSimpleTextureEffect::Make(d->fTextures[texIdx], colorSpaceXform, matrix, coordSet);
}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index e06c8de801..e809109835 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -295,9 +295,10 @@ sk_sp<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcessorTestData
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false;
GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrCoordSet;
+ auto colorSpaceXform = GrTest::TestColorXform(d->fRandom);
return GrTextureDomainEffect::Make(
d->fTextures[texIdx],
- nullptr,
+ colorSpaceXform,
matrix,
domain,
mode,