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

Unified Diff: tests/SurfaceTest.cpp

Issue 1784563002: unify peekPixels around pixmap parameter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update GrUploadPixmapToTexture to know about the new desc if readPixels was called Created 4 years, 9 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/ImageTest.cpp ('k') | tools/android/SkAndroidSDKCanvas.cpp » ('j') | 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 971e6b56f7ebe33afed7d9b1f666c9c2a979e6ca..d6c7acd9160ff91768b4e5b800f2c7ecc7bf6288 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -157,26 +157,23 @@ static void test_canvas_peek(skiatest::Reporter* reporter,
bool expectPeekSuccess) {
const SkColor color = SK_ColorRED;
const SkPMColor pmcolor = SkPreMultiplyColor(color);
- SkImageInfo info;
- size_t rowBytes;
surface->getCanvas()->clear(color);
- const void* addr = surface->getCanvas()->peekPixels(&info, &rowBytes);
- bool success = SkToBool(addr);
+ SkPixmap pmap;
+ bool success = surface->getCanvas()->peekPixels(&pmap);
REPORTER_ASSERT(reporter, expectPeekSuccess == success);
- SkImageInfo info2;
- size_t rb2;
- const void* addr2 = surface->peekPixels(&info2, &rb2);
+ SkPixmap pmap2;
+ const void* addr2 = surface->peekPixels(&pmap2) ? pmap2.addr() : nullptr;
if (success) {
- REPORTER_ASSERT(reporter, requestInfo == info);
- REPORTER_ASSERT(reporter, requestInfo.minRowBytes() <= rowBytes);
- REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr);
+ REPORTER_ASSERT(reporter, requestInfo == pmap.info());
+ REPORTER_ASSERT(reporter, requestInfo.minRowBytes() <= pmap.rowBytes());
+ REPORTER_ASSERT(reporter, pmcolor == *pmap.addr32());
- REPORTER_ASSERT(reporter, addr2 == addr);
- REPORTER_ASSERT(reporter, info2 == info);
- REPORTER_ASSERT(reporter, rb2 == rowBytes);
+ REPORTER_ASSERT(reporter, pmap.addr() == pmap2.addr());
+ REPORTER_ASSERT(reporter, pmap.info() == pmap2.info());
+ REPORTER_ASSERT(reporter, pmap.rowBytes() == pmap2.rowBytes());
} else {
REPORTER_ASSERT(reporter, nullptr == addr2);
}
@@ -387,9 +384,8 @@ DEF_TEST(UniqueImageSnapshot, reporter) {
return reinterpret_cast<intptr_t>(pm.addr());
};
auto getSufaceBackingStore = [reporter](SkSurface* surface) {
- SkImageInfo info;
- size_t rowBytes;
- const void* pixels = surface->getCanvas()->peekPixels(&info, &rowBytes);
+ SkPixmap pmap;
+ const void* pixels = surface->getCanvas()->peekPixels(&pmap) ? pmap.addr() : nullptr;
REPORTER_ASSERT(reporter, pixels);
return reinterpret_cast<intptr_t>(pixels);
};
@@ -785,27 +781,23 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceNoCanvas_Gpu, reporter, context) {
#endif
static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Reporter* reporter) {
- SkImageInfo info;
- size_t rowBytes;
- REPORTER_ASSERT(reporter, surface->peekPixels(&info, &rowBytes));
+ SkPixmap surfacePM;
+ REPORTER_ASSERT(reporter, surface->peekPixels(&surfacePM));
SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
- SkImageInfo im_info;
- size_t im_rowbytes;
- REPORTER_ASSERT(reporter, image->peekPixels(&im_info, &im_rowbytes));
+ SkPixmap pm;
+ REPORTER_ASSERT(reporter, image->peekPixels(&pm));
- REPORTER_ASSERT(reporter, rowBytes == im_rowbytes);
+ REPORTER_ASSERT(reporter, surfacePM.rowBytes() == pm.rowBytes());
// trigger a copy-on-write
surface->getCanvas()->drawPaint(SkPaint());
SkAutoTUnref<SkImage> image2(surface->newImageSnapshot());
REPORTER_ASSERT(reporter, image->uniqueID() != image2->uniqueID());
- SkImageInfo im_info2;
- size_t im_rowbytes2;
- REPORTER_ASSERT(reporter, image2->peekPixels(&im_info2, &im_rowbytes2));
-
- REPORTER_ASSERT(reporter, im_rowbytes2 == im_rowbytes);
+ SkPixmap pm2;
+ REPORTER_ASSERT(reporter, image2->peekPixels(&pm2));
+ REPORTER_ASSERT(reporter, pm2.rowBytes() == pm.rowBytes());
}
DEF_TEST(surface_rowbytes, reporter) {
« no previous file with comments | « tests/ImageTest.cpp ('k') | tools/android/SkAndroidSDKCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698