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

Unified Diff: tests/ReadWriteAlphaTest.cpp

Issue 1448873002: Generate list of GPU contexts outside tests (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-01-gpu-test-context-support
Patch Set: make blurtest for all rendering contexts Created 5 years 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 | « tests/ReadPixelsTest.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ReadWriteAlphaTest.cpp
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 301bf6b78e428c9d256d6dba0906ca174f10f33f..a40f2c64576c4f498a3993834550234bd7109314 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -10,106 +10,95 @@
// This test is specific to the GPU backend.
#if SK_SUPPORT_GPU && !defined(SK_BUILD_FOR_ANDROID)
-#include "GrContextFactory.h"
+#include "GrContext.h"
#include "SkGpuDevice.h"
static const int X_SIZE = 12;
static const int Y_SIZE = 12;
-DEF_GPUTEST(ReadWriteAlpha, reporter, factory) {
- for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
- GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
- if (!GrContextFactory::IsRenderingGLContext(glType)) {
- continue;
- }
- GrContext* context = factory->get(glType);
- if (nullptr == context) {
- continue;
- }
-
- unsigned char textureData[X_SIZE][Y_SIZE];
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, context) {
+ unsigned char textureData[X_SIZE][Y_SIZE];
- memset(textureData, 0, X_SIZE * Y_SIZE);
+ memset(textureData, 0, X_SIZE * Y_SIZE);
- GrSurfaceDesc desc;
+ GrSurfaceDesc desc;
- // let Skia know we will be using this texture as a render target
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- // it is a single channel texture
- desc.fConfig = kAlpha_8_GrPixelConfig;
- desc.fWidth = X_SIZE;
- desc.fHeight = Y_SIZE;
+ // let Skia know we will be using this texture as a render target
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ // it is a single channel texture
+ desc.fConfig = kAlpha_8_GrPixelConfig;
+ desc.fWidth = X_SIZE;
+ desc.fHeight = Y_SIZE;
- // We are initializing the texture with zeros here
- GrTexture* texture = context->textureProvider()->createTexture(desc, false, textureData, 0);
- if (!texture) {
- return;
- }
+ // We are initializing the texture with zeros here
+ GrTexture* texture = context->textureProvider()->createTexture(desc, false, textureData, 0);
+ if (!texture) {
+ return;
+ }
- SkAutoTUnref<GrTexture> au(texture);
+ SkAutoTUnref<GrTexture> au(texture);
- // create a distinctive texture
- for (int y = 0; y < Y_SIZE; ++y) {
- for (int x = 0; x < X_SIZE; ++x) {
- textureData[x][y] = x*Y_SIZE+y;
- }
+ // create a distinctive texture
+ for (int y = 0; y < Y_SIZE; ++y) {
+ for (int x = 0; x < X_SIZE; ++x) {
+ textureData[x][y] = x*Y_SIZE+y;
}
+ }
- // upload the texture
- texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
- textureData, 0);
+ // upload the texture
+ texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
+ textureData, 0);
- unsigned char readback[X_SIZE][Y_SIZE];
+ unsigned char readback[X_SIZE][Y_SIZE];
- // clear readback to something non-zero so we can detect readback failures
- memset(readback, 0x1, X_SIZE * Y_SIZE);
+ // clear readback to something non-zero so we can detect readback failures
+ memset(readback, 0x1, X_SIZE * Y_SIZE);
- // read the texture back
- texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
- readback, 0);
+ // read the texture back
+ texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
+ readback, 0);
- // make sure the original & read back versions match
- bool match = true;
+ // make sure the original & read back versions match
+ bool match = true;
- for (int y = 0; y < Y_SIZE; ++y) {
- for (int x = 0; x < X_SIZE; ++x) {
- if (textureData[x][y] != readback[x][y]) {
- match = false;
- }
+ for (int y = 0; y < Y_SIZE; ++y) {
+ for (int x = 0; x < X_SIZE; ++x) {
+ if (textureData[x][y] != readback[x][y]) {
+ match = false;
}
}
+ }
- REPORTER_ASSERT(reporter, match);
+ REPORTER_ASSERT(reporter, match);
- // Now try writing on the single channel texture
- SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
- SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(texture->asRenderTarget(), &props,
- SkGpuDevice::kUninit_InitContents));
- SkCanvas canvas(device);
+ // Now try writing on the single channel texture
+ SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(texture->asRenderTarget(), &props,
+ SkGpuDevice::kUninit_InitContents));
+ SkCanvas canvas(device);
- SkPaint paint;
+ SkPaint paint;
- const SkRect rect = SkRect::MakeLTRB(-10, -10, X_SIZE + 10, Y_SIZE + 10);
+ const SkRect rect = SkRect::MakeLTRB(-10, -10, X_SIZE + 10, Y_SIZE + 10);
- paint.setColor(SK_ColorWHITE);
+ paint.setColor(SK_ColorWHITE);
- canvas.drawRect(rect, paint);
+ canvas.drawRect(rect, paint);
- texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
- readback, 0);
+ texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
+ readback, 0);
- match = true;
+ match = true;
- for (int y = 0; y < Y_SIZE; ++y) {
- for (int x = 0; x < X_SIZE; ++x) {
- if (0xFF != readback[x][y]) {
- match = false;
- }
+ for (int y = 0; y < Y_SIZE; ++y) {
+ for (int x = 0; x < X_SIZE; ++x) {
+ if (0xFF != readback[x][y]) {
+ match = false;
}
}
-
- REPORTER_ASSERT(reporter, match);
}
+
+ REPORTER_ASSERT(reporter, match);
}
#endif
« no previous file with comments | « tests/ReadPixelsTest.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698