aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-04 17:29:51 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-04 17:29:51 +0000
commited8659b51d9f2bad3f004df6033d72cc32d71c0d (patch)
treec9882164b3ce1c63e164bf0434c9505c95f80b6f /tests
parent83f7c659461d602e498569dab63f04b1b578b742 (diff)
Implement support for origin-TopLeft render targets in GL backend.
Review URL: https://codereview.appspot.com/7230049 git-svn-id: http://skia.googlecode.com/svn/trunk@7545 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/ReadPixelsTest.cpp13
-rw-r--r--tests/WritePixelsTest.cpp26
2 files changed, 31 insertions, 8 deletions
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 41ecccff35..df51a19a94 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -303,7 +303,7 @@ void ReadPixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
SkIRect::MakeLTRB(3 * DEV_W / 4, -10, DEV_W + 10, DEV_H + 10),
};
- for (int dtype = 0; dtype < 2; ++dtype) {
+ for (int dtype = 0; dtype < 3; ++dtype) {
int glCtxTypeCnt = 1;
#if SK_SUPPORT_GPU
if (0 != dtype) {
@@ -325,7 +325,16 @@ void ReadPixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
if (NULL == context) {
continue;
}
- device.reset(new SkGpuDevice(context, SkBitmap::kARGB_8888_Config, DEV_W, DEV_H));
+ GrTextureDesc desc;
+ desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
+ desc.fWidth = DEV_W;
+ desc.fHeight = DEV_H;
+ desc.fConfig = kSkia8888_PM_GrPixelConfig;
+ desc.fOrigin = 1 == dtype ? kBottomLeft_GrSurfaceOrigin
+ : kTopLeft_GrSurfaceOrigin;
+ GrAutoScratchTexture ast(context, desc, GrContext::kExact_ScratchTexMatch);
+ SkAutoTUnref<GrTexture> tex(ast.detach());
+ device.reset(new SkGpuDevice(context, tex));
#else
continue;
#endif
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 14b2c51e9a..83e0784305 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -286,7 +286,8 @@ bool checkWrite(skiatest::Reporter* reporter,
enum DevType {
kRaster_DevType,
#if SK_SUPPORT_GPU
- kGpu_DevType,
+ kGpu_BottomLeft_DevType,
+ kGpu_TopLeft_DevType,
#endif
};
@@ -299,7 +300,8 @@ static const CanvasConfig gCanvasConfigs[] = {
{kRaster_DevType, true},
{kRaster_DevType, false},
#if SK_SUPPORT_GPU && defined(SK_SCALAR_IS_FLOAT)
- {kGpu_DevType, true}, // row bytes has no meaning on gpu devices
+ {kGpu_BottomLeft_DevType, true}, // row bytes has no meaning on gpu devices
+ {kGpu_TopLeft_DevType, true}, // row bytes has no meaning on gpu devices
#endif
};
@@ -321,8 +323,18 @@ SkDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) {
return new SkDevice(bmp);
}
#if SK_SUPPORT_GPU
- case kGpu_DevType:
- return new SkGpuDevice(grCtx, SkBitmap::kARGB_8888_Config, DEV_W, DEV_H);
+ case kGpu_BottomLeft_DevType:
+ case kGpu_TopLeft_DevType:
+ GrTextureDesc desc;
+ desc.fFlags = kRenderTarget_GrTextureFlagBit;
+ desc.fWidth = DEV_W;
+ desc.fHeight = DEV_H;
+ desc.fConfig = kSkia8888_PM_GrPixelConfig;
+ desc.fOrigin = kGpu_TopLeft_DevType == c.fDevType ?
+ kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
+ GrAutoScratchTexture ast(grCtx, desc, GrContext::kExact_ScratchTexMatch);
+ SkAutoTUnref<GrTexture> tex(ast.detach());
+ return new SkGpuDevice(grCtx, tex);
#endif
}
return NULL;
@@ -401,14 +413,16 @@ void WritePixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gCanvasConfigs); ++i) {
int glCtxTypeCnt = 1;
#if SK_SUPPORT_GPU
- if (kGpu_DevType == gCanvasConfigs[i].fDevType) {
+ bool isGPUDevice = kGpu_TopLeft_DevType == gCanvasConfigs[i].fDevType ||
+ kGpu_BottomLeft_DevType == gCanvasConfigs[i].fDevType;
+ if (isGPUDevice) {
glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt;
}
#endif
for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
GrContext* context = NULL;
#if SK_SUPPORT_GPU
- if (kGpu_DevType == gCanvasConfigs[i].fDevType) {
+ if (isGPUDevice) {
GrContextFactory::GLContextType type =
static_cast<GrContextFactory::GLContextType>(glCtxType);
#if SK_ANGLE // This test breaks ANGLE with GL errors in texsubimage2D. Disable until debugged.