aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ProcessorTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-02-10 12:39:26 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-13 15:21:34 +0000
commitd1a8bdfbb97647a2a46a5c179fc87fa3da1abd84 (patch)
tree6b49f3dc1df9251e438611889cc2cd40a3e309d7 /tests/ProcessorTest.cpp
parentf6877090114c002d02bef3804dbcd6be52b23cfc (diff)
Initialize test textures for ProcessorOptimizationValidationTest.
Ensure the data in the RGBA texture is premul. Reenable the "modulation" optimization flag on GrAlphaThresholdFragmentProcessor. Change-Id: I49ef215cee83ea74526c589bcee4bc215bc28ba4 Reviewed-on: https://skia-review.googlesource.com/8323 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/ProcessorTest.cpp')
-rw-r--r--tests/ProcessorTest.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 49938c6619..678fbaa245 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -271,21 +271,41 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
desc.fHeight = 256;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- sk_sp<GrTexture> tex0(context->textureProvider()->createTexture(desc, SkBudgeted::kYes));
+
+ // Put premul data into the RGBA texture that the test FPs can optionally use.
+ std::unique_ptr<GrColor[]> rgbaData(new GrColor[256 * 256]);
+ for (int y = 0; y < 256; ++y) {
+ for (int x = 0; x < 256; ++x) {
+ rgbaData.get()[256 * y + x] =
+ texel_color(random.nextULessThan(256), random.nextULessThan(256));
+ }
+ }
+ sk_sp<GrTexture> tex0(context->textureProvider()->createTexture(
+ desc, SkBudgeted::kYes, rgbaData.get(), 256 * sizeof(GrColor)));
+
+ // Put random values into the alpha texture that the test FPs can optionally use.
desc.fConfig = kAlpha_8_GrPixelConfig;
- sk_sp<GrTexture> tex1(context->textureProvider()->createTexture(desc, SkBudgeted::kYes));
+ std::unique_ptr<uint8_t[]> alphaData(new uint8_t[256 * 256]);
+ for (int y = 0; y < 256; ++y) {
+ for (int x = 0; x < 256; ++x) {
+ alphaData.get()[256 * y + x] = random.nextULessThan(256);
+ }
+ }
+ sk_sp<GrTexture> tex1(context->textureProvider()->createTexture(desc, SkBudgeted::kYes,
+ alphaData.get(), 256));
GrTexture* textures[] = {tex0.get(), tex1.get()};
GrProcessorTestData testData(&random, context, rtc.get(), textures);
- std::unique_ptr<GrColor[]> data(new GrColor[256 * 256]);
+ // Use a different array of premul colors for the output of the fragment processor that preceeds
+ // the fragment processor under test.
for (int y = 0; y < 256; ++y) {
for (int x = 0; x < 256; ++x) {
- data.get()[256 * y + x] = texel_color(x, y);
+ rgbaData.get()[256 * y + x] = texel_color(x, y);
}
}
desc.fConfig = kRGBA_8888_GrPixelConfig;
sk_sp<GrTexture> dataTexture(context->textureProvider()->createTexture(
- desc, SkBudgeted::kYes, data.get(), 256 * sizeof(GrColor)));
+ desc, SkBudgeted::kYes, rgbaData.get(), 256 * sizeof(GrColor)));
// Because processors factories configure themselves in random ways, this is not exhaustive.
for (int i = 0; i < FPFactory::Count(); ++i) {
@@ -305,10 +325,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
continue;
}
test_draw_op(rtc.get(), fp, dataTexture.get());
- memset(data.get(), 0x0, sizeof(GrColor) * 256 * 256);
+ memset(rgbaData.get(), 0x0, sizeof(GrColor) * 256 * 256);
rtc->readPixels(
SkImageInfo::Make(256, 256, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
- data.get(), 0, 0, 0);
+ rgbaData.get(), 0, 0, 0);
bool passing = true;
if (0) { // Useful to see what FPs are being tested.
SkString children;
@@ -324,7 +344,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
for (int y = 0; y < 256 && passing; ++y) {
for (int x = 0; x < 256 && passing; ++x) {
GrColor input = texel_color(x, y);
- GrColor output = data.get()[y * 256 + x];
+ GrColor output = rgbaData.get()[y * 256 + x];
if (fp->modulatesInput()) {
// A modulating processor is allowed to modulate either the input color or
// just the input alpha.