aboutsummaryrefslogtreecommitdiffhomepage
path: root/example
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-09 14:26:26 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-09 14:26:26 -0800
commit6ceeebd37a43d879c120b6ba100ae1febdd67a18 (patch)
tree6c4dfeb68ba4183bc2e63d8888ae01f24caede88 /example
parentf842c50116863f44240f806509f14e434eabb0a8 (diff)
unify peekPixels around pixmap parameter
Diffstat (limited to 'example')
-rw-r--r--example/HelloWorld.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index 1cc18fdc8d..e13cb3b438 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();
}