Index: tests/SRGBReadWritePixelsTest.cpp |
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp |
index 7e0b721246cd7e6dee3311049b5dd04a9d04b7bf..01d88f9902ef8a3f482a0160698c97061c08c3cb 100644 |
--- a/tests/SRGBReadWritePixelsTest.cpp |
+++ b/tests/SRGBReadWritePixelsTest.cpp |
@@ -12,6 +12,7 @@ |
#include "SkSurface.h" |
#include "GrContextFactory.h" |
#include "GrCaps.h" |
+#include "GrDrawContext.h" |
// using anonymous namespace because these functions are used as template params. |
namespace { |
@@ -137,6 +138,8 @@ void read_and_check_pixels(skiatest::Reporter* reporter, GrTexture* texture, uin |
} |
} |
+#include "GrDrawTarget.h" |
+ |
// TODO: Add tests for copySurface between srgb/linear textures. Add tests for unpremul/premul |
// conversion during read/write along with srgb/linear conversions. |
DEF_GPUTEST(SRGBReadWritePixels, reporter, factory) { |
@@ -175,11 +178,16 @@ DEF_GPUTEST(SRGBReadWritePixels, reporter, factory) { |
ERRORF(reporter, "Could not create SRGBA texture."); |
continue; |
} |
+ SkAutoTUnref<GrDrawContext> dc(context->drawContext(tex->asRenderTarget())); |
+ if (!dc) { |
+ ERRORF(reporter, "Could not create SRGBA texture."); |
+ continue; |
+ } |
float error = context->caps()->shaderCaps()->floatPrecisionVaries() ? 1.2f : 0.5f; |
// Write srgba data and read as srgba and then as rgba |
- if (tex->writePixels(0, 0, kW, kH, kSRGBA_8888_GrPixelConfig, origData)) { |
+ if (tex->writePixels(dc, 0, 0, kW, kH, kSRGBA_8888_GrPixelConfig, origData)) { |
// For the all-srgba case, we allow a small error only for devices that have |
// precision variation because the srgba data gets converted to linear and back in |
// the shader. |
@@ -196,7 +204,7 @@ DEF_GPUTEST(SRGBReadWritePixels, reporter, factory) { |
} |
// Now verify that we can write linear data |
- if (tex->writePixels(0, 0, kW, kH, kRGBA_8888_GrPixelConfig, origData)) { |
+ if (tex->writePixels(dc, 0, 0, kW, kH, kRGBA_8888_GrPixelConfig, origData)) { |
// We allow more error on GPUs with lower precision shader variables. |
read_and_check_pixels(reporter, tex, origData, kSRGBA_8888_GrPixelConfig, |
check_linear_to_srgb_conversion, error, |
@@ -214,9 +222,14 @@ DEF_GPUTEST(SRGBReadWritePixels, reporter, factory) { |
ERRORF(reporter, "Could not create RGBA texture."); |
continue; |
} |
+ dc.reset(context->drawContext(tex->asRenderTarget())); |
+ if (!dc) { |
+ ERRORF(reporter, "Could not create SRGBA texture."); |
+ continue; |
+ } |
// Write srgba data to a rgba texture and read back as srgba and rgba |
- if (tex->writePixels(0, 0, kW, kH, kSRGBA_8888_GrPixelConfig, origData)) { |
+ if (tex->writePixels(dc, 0, 0, kW, kH, kSRGBA_8888_GrPixelConfig, origData)) { |
read_and_check_pixels(reporter, tex, origData, kSRGBA_8888_GrPixelConfig, |
check_srgb_to_linear_to_srgb_conversion, error, |
"write/read srgba to rgba texture"); |
@@ -228,7 +241,7 @@ DEF_GPUTEST(SRGBReadWritePixels, reporter, factory) { |
} |
// Write rgba data to a rgba texture and read back as srgba |
- if (tex->writePixels(0, 0, kW, kH, kRGBA_8888_GrPixelConfig, origData)) { |
+ if (tex->writePixels(dc, 0, 0, kW, kH, kRGBA_8888_GrPixelConfig, origData)) { |
read_and_check_pixels(reporter, tex, origData, kSRGBA_8888_GrPixelConfig, |
check_linear_to_srgb_conversion, 1.2f, |
"write rgba/read srgba to rgba texture"); |