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

Unified Diff: example/HelloWorld.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 | « no previous file | gm/blend.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: example/HelloWorld.cpp
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index 1cc18fdc8dd92d1ba19edd51082bc01348be0409..e13cb3b438045ef777ca711b471081b1981bdf4f 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -156,18 +156,18 @@ void HelloWorldWindow::draw(SkCanvas* canvas) {
if (kRaster_DeviceType == fType) {
// need to send the raster bits to the (gpu) window
- SkImage* snap = fSurface->newImageSnapshot();
- size_t rowBytes = 0;
- SkImageInfo info;
- const void* pixels = snap->peekPixels(&info, &rowBytes);
- fRenderTarget->writePixels(0, 0, snap->width(), snap->height(),
- SkImageInfo2GrPixelConfig(info.colorType(),
- info.alphaType(),
- info.profileType()),
- pixels,
- rowBytes,
- GrContext::kFlushWrites_PixelOp);
- SkSafeUnref(snap);
+ sk_sp<SkImage> snap = sk_sp<SkImage>(fSurface->newImageSnapshot());
+ SkPixmap pmap;
+ if (snap->peekPixels(&pmap)) {
+ const SkImageInfo& info = pmap.info();
+ fRenderTarget->writePixels(0, 0, snap->width(), snap->height(),
+ SkImageInfo2GrPixelConfig(info.colorType(),
+ info.alphaType(),
+ info.profileType()),
+ pmap.addr(),
+ pmap.rowBytes(),
+ GrContext::kFlushWrites_PixelOp);
+ }
}
INHERITED::present();
}
« no previous file with comments | « no previous file | gm/blend.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698