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

Unified Diff: tests/SurfaceTest.cpp

Issue 398183002: Fix alpha textures in NV ES3 contexts on Windows (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: suppress warning Created 6 years, 5 months 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/PictureTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SurfaceTest.cpp
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 610e3370f6a47133544e77aa32a67f27271809d6..d31718694712db5cfa341df88a373639efaa146e 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -170,37 +170,53 @@ static void test_canvaspeek(skiatest::Reporter* reporter,
const SkColor color = SK_ColorRED;
const SkPMColor pmcolor = SkPreMultiplyColor(color);
- GrContext* context = NULL;
+ int cnt;
#if SK_SUPPORT_GPU
- context = factory->get(GrContextFactory::kNative_GLContextType);
+ cnt = GrContextFactory::kGLContextTypeCnt;
+#else
+ cnt = 1;
#endif
- for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
- SkImageInfo info, requestInfo;
- size_t rowBytes;
-
- SkAutoTUnref<SkSurface> surface(createSurface(gRec[i].fType, context,
- &requestInfo));
- surface->getCanvas()->clear(color);
-
- const void* addr = surface->getCanvas()->peekPixels(&info, &rowBytes);
- bool success = (NULL != addr);
- REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success);
-
- SkImageInfo info2;
- size_t rb2;
- const void* addr2 = surface->peekPixels(&info2, &rb2);
-
- if (success) {
- REPORTER_ASSERT(reporter, requestInfo == info);
- REPORTER_ASSERT(reporter, requestInfo.minRowBytes() <= rowBytes);
- REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr);
+ for (int i= 0; i < cnt; ++i) {
+ GrContext* context = NULL;
+#if SK_SUPPORT_GPU
+ GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
+ if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
+ continue;
+ }
+ context = factory->get(glCtxType);
- REPORTER_ASSERT(reporter, addr2 == addr);
- REPORTER_ASSERT(reporter, info2 == info);
- REPORTER_ASSERT(reporter, rb2 == rowBytes);
- } else {
- REPORTER_ASSERT(reporter, NULL == addr2);
+ if (NULL == context) {
+ continue;
+ }
+#endif
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
+ SkImageInfo info, requestInfo;
+ size_t rowBytes;
+
+ SkAutoTUnref<SkSurface> surface(createSurface(gRec[i].fType, context,
+ &requestInfo));
+ surface->getCanvas()->clear(color);
+
+ const void* addr = surface->getCanvas()->peekPixels(&info, &rowBytes);
+ bool success = (NULL != addr);
+ REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success);
+
+ SkImageInfo info2;
+ size_t rb2;
+ const void* addr2 = surface->peekPixels(&info2, &rb2);
+
+ if (success) {
+ REPORTER_ASSERT(reporter, requestInfo == info);
+ REPORTER_ASSERT(reporter, requestInfo.minRowBytes() <= rowBytes);
+ REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr);
+
+ REPORTER_ASSERT(reporter, addr2 == addr);
+ REPORTER_ASSERT(reporter, info2 == info);
+ REPORTER_ASSERT(reporter, rb2 == rowBytes);
+ } else {
+ REPORTER_ASSERT(reporter, NULL == addr2);
+ }
}
}
}
@@ -429,22 +445,28 @@ DEF_GPUTEST(Surface, reporter, factory) {
#if SK_SUPPORT_GPU
TestGetTexture(reporter, kRaster_SurfaceType, NULL);
if (NULL != factory) {
- GrContext* context = factory->get(GrContextFactory::kNative_GLContextType);
- if (NULL != context) {
- TestSurfaceInCache(reporter, kGpu_SurfaceType, context);
- TestSurfaceInCache(reporter, kGpuScratch_SurfaceType, context);
- Test_crbug263329(reporter, kGpu_SurfaceType, context);
- Test_crbug263329(reporter, kGpuScratch_SurfaceType, context);
- TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context);
- TestSurfaceCopyOnWrite(reporter, kGpuScratch_SurfaceType, context);
- TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, context);
- TestSurfaceWritableAfterSnapshotRelease(reporter, kGpuScratch_SurfaceType, context);
- TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
- TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
- TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
- TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
- TestGetTexture(reporter, kGpu_SurfaceType, context);
- TestGetTexture(reporter, kGpuScratch_SurfaceType, context);
+ for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
+ GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
+ if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
+ continue;
+ }
+ GrContext* context = factory->get(glCtxType);
+ if (NULL != context) {
+ TestSurfaceInCache(reporter, kGpu_SurfaceType, context);
+ TestSurfaceInCache(reporter, kGpuScratch_SurfaceType, context);
+ Test_crbug263329(reporter, kGpu_SurfaceType, context);
+ Test_crbug263329(reporter, kGpuScratch_SurfaceType, context);
+ TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context);
+ TestSurfaceCopyOnWrite(reporter, kGpuScratch_SurfaceType, context);
+ TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, context);
+ TestSurfaceWritableAfterSnapshotRelease(reporter, kGpuScratch_SurfaceType, context);
+ TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
+ TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
+ TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
+ TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
+ TestGetTexture(reporter, kGpu_SurfaceType, context);
+ TestGetTexture(reporter, kGpuScratch_SurfaceType, context);
+ }
}
}
#endif
« no previous file with comments | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698