Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 // Invalidate the window to force a redraw. Poor man's animation mechanism. | 148 // Invalidate the window to force a redraw. Poor man's animation mechanism. |
| 149 this->inval(NULL); | 149 this->inval(NULL); |
| 150 | 150 |
| 151 if (kRaster_DeviceType == fType) { | 151 if (kRaster_DeviceType == fType) { |
| 152 // need to send the raster bits to the (gpu) window | 152 // need to send the raster bits to the (gpu) window |
| 153 sk_sp<SkImage> snap = fSurface->makeImageSnapshot(); | 153 sk_sp<SkImage> snap = fSurface->makeImageSnapshot(); |
| 154 SkPixmap pmap; | 154 SkPixmap pmap; |
| 155 if (snap->peekPixels(&pmap)) { | 155 if (snap->peekPixels(&pmap)) { |
| 156 const SkImageInfo& info = pmap.info(); | 156 const SkImageInfo& info = pmap.info(); |
| 157 fRenderTarget->writePixels(0, 0, snap->width(), snap->height(), | 157 fRenderTarget->writePixels(0, 0, snap->width(), snap->height(), |
| 158 SkImageInfo2GrPixelConfig(info.color Type(), | 158 SkImageInfo2GrPixelConfig(info, *fCo ntext->caps()), |
|
msarett
2016/06/16 15:56:03
nit: formatting
Feel free to ignore this comment.
| |
| 159 info.alphaTy pe(), | |
| 160 info.profile Type(), | |
| 161 *fContext->c aps()), | |
| 162 pmap.addr(), | 159 pmap.addr(), |
| 163 pmap.rowBytes(), | 160 pmap.rowBytes(), |
| 164 GrContext::kFlushWrites_PixelOp); | 161 GrContext::kFlushWrites_PixelOp); |
| 165 } | 162 } |
| 166 } | 163 } |
| 167 INHERITED::present(); | 164 INHERITED::present(); |
| 168 } | 165 } |
| 169 | 166 |
| 170 void HelloWorldWindow::onSizeChange() { | 167 void HelloWorldWindow::onSizeChange() { |
| 171 setUpRenderTarget(); | 168 setUpRenderTarget(); |
| 172 } | 169 } |
| 173 | 170 |
| 174 bool HelloWorldWindow::onHandleChar(SkUnichar unichar) { | 171 bool HelloWorldWindow::onHandleChar(SkUnichar unichar) { |
| 175 if (' ' == unichar) { | 172 if (' ' == unichar) { |
| 176 fType = fType == kRaster_DeviceType ? kGPU_DeviceType: kRaster_DeviceTyp e; | 173 fType = fType == kRaster_DeviceType ? kGPU_DeviceType: kRaster_DeviceTyp e; |
| 177 tearDownBackend(); | 174 tearDownBackend(); |
| 178 setUpBackend(); | 175 setUpBackend(); |
| 179 this->setTitle(); | 176 this->setTitle(); |
| 180 this->inval(NULL); | 177 this->inval(NULL); |
| 181 } | 178 } |
| 182 return true; | 179 return true; |
| 183 } | 180 } |
| 184 | 181 |
| 185 SkOSWindow* create_sk_window(void* hwnd, int , char** ) { | 182 SkOSWindow* create_sk_window(void* hwnd, int , char** ) { |
| 186 return new HelloWorldWindow(hwnd); | 183 return new HelloWorldWindow(hwnd); |
| 187 } | 184 } |
| OLD | NEW |