| 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, *fContext
->caps()), |
| 159 info.alphaTy
pe(), | 159 pmap.addr(), pmap.rowBytes(), |
| 160 info.profile
Type(), | 160 GrContext::kFlushWrites_PixelOp); |
| 161 *fContext->c
aps()), | |
| 162 pmap.addr(), | |
| 163 pmap.rowBytes(), | |
| 164 GrContext::kFlushWrites_PixelOp); | |
| 165 } | 161 } |
| 166 } | 162 } |
| 167 INHERITED::present(); | 163 INHERITED::present(); |
| 168 } | 164 } |
| 169 | 165 |
| 170 void HelloWorldWindow::onSizeChange() { | 166 void HelloWorldWindow::onSizeChange() { |
| 171 setUpRenderTarget(); | 167 setUpRenderTarget(); |
| 172 } | 168 } |
| 173 | 169 |
| 174 bool HelloWorldWindow::onHandleChar(SkUnichar unichar) { | 170 bool HelloWorldWindow::onHandleChar(SkUnichar unichar) { |
| 175 if (' ' == unichar) { | 171 if (' ' == unichar) { |
| 176 fType = fType == kRaster_DeviceType ? kGPU_DeviceType: kRaster_DeviceTyp
e; | 172 fType = fType == kRaster_DeviceType ? kGPU_DeviceType: kRaster_DeviceTyp
e; |
| 177 tearDownBackend(); | 173 tearDownBackend(); |
| 178 setUpBackend(); | 174 setUpBackend(); |
| 179 this->setTitle(); | 175 this->setTitle(); |
| 180 this->inval(NULL); | 176 this->inval(NULL); |
| 181 } | 177 } |
| 182 return true; | 178 return true; |
| 183 } | 179 } |
| 184 | 180 |
| 185 SkOSWindow* create_sk_window(void* hwnd, int , char** ) { | 181 SkOSWindow* create_sk_window(void* hwnd, int , char** ) { |
| 186 return new HelloWorldWindow(hwnd); | 182 return new HelloWorldWindow(hwnd); |
| 187 } | 183 } |
| OLD | NEW |