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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | gm/blend.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 * 7 *
8 */ 8 */
9 9
10 #include "HelloWorld.h" 10 #include "HelloWorld.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 void HelloWorldWindow::draw(SkCanvas* canvas) { 150 void HelloWorldWindow::draw(SkCanvas* canvas) {
151 drawContents(canvas); 151 drawContents(canvas);
152 // in case we have queued drawing calls 152 // in case we have queued drawing calls
153 fContext->flush(); 153 fContext->flush();
154 // Invalidate the window to force a redraw. Poor man's animation mechanism. 154 // Invalidate the window to force a redraw. Poor man's animation mechanism.
155 this->inval(NULL); 155 this->inval(NULL);
156 156
157 if (kRaster_DeviceType == fType) { 157 if (kRaster_DeviceType == fType) {
158 // need to send the raster bits to the (gpu) window 158 // need to send the raster bits to the (gpu) window
159 SkImage* snap = fSurface->newImageSnapshot(); 159 sk_sp<SkImage> snap = sk_sp<SkImage>(fSurface->newImageSnapshot());
160 size_t rowBytes = 0; 160 SkPixmap pmap;
161 SkImageInfo info; 161 if (snap->peekPixels(&pmap)) {
162 const void* pixels = snap->peekPixels(&info, &rowBytes); 162 const SkImageInfo& info = pmap.info();
163 fRenderTarget->writePixels(0, 0, snap->width(), snap->height(), 163 fRenderTarget->writePixels(0, 0, snap->width(), snap->height(),
164 SkImageInfo2GrPixelConfig(info.colorType (), 164 SkImageInfo2GrPixelConfig(info.color Type(),
165 info.alphaType() , 165 info.alphaTy pe(),
166 info.profileType ()), 166 info.profile Type()),
167 pixels, 167 pmap.addr(),
168 rowBytes, 168 pmap.rowBytes(),
169 GrContext::kFlushWrites_PixelOp); 169 GrContext::kFlushWrites_PixelOp);
170 SkSafeUnref(snap); 170 }
171 } 171 }
172 INHERITED::present(); 172 INHERITED::present();
173 } 173 }
174 174
175 void HelloWorldWindow::onSizeChange() { 175 void HelloWorldWindow::onSizeChange() {
176 setUpRenderTarget(); 176 setUpRenderTarget();
177 } 177 }
178 178
179 bool HelloWorldWindow::onHandleChar(SkUnichar unichar) { 179 bool HelloWorldWindow::onHandleChar(SkUnichar unichar) {
180 if (' ' == unichar) { 180 if (' ' == unichar) {
181 fType = fType == kRaster_DeviceType ? kGPU_DeviceType: kRaster_DeviceTyp e; 181 fType = fType == kRaster_DeviceType ? kGPU_DeviceType: kRaster_DeviceTyp e;
182 tearDownBackend(); 182 tearDownBackend();
183 setUpBackend(); 183 setUpBackend();
184 this->setTitle(); 184 this->setTitle();
185 this->inval(NULL); 185 this->inval(NULL);
186 } 186 }
187 return true; 187 return true;
188 } 188 }
189 189
190 SkOSWindow* create_sk_window(void* hwnd, int , char** ) { 190 SkOSWindow* create_sk_window(void* hwnd, int , char** ) {
191 return new HelloWorldWindow(hwnd); 191 return new HelloWorldWindow(hwnd);
192 } 192 }
OLDNEW
« 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