OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Request.h" | 8 #include "Request.h" |
9 | 9 |
10 #include "png.h" | 10 #include "png.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 &props); | 170 &props); |
171 return surface; | 171 return surface; |
172 } | 172 } |
173 | 173 |
174 bool Request::enableGPU(bool enable) { | 174 bool Request::enableGPU(bool enable) { |
175 if (enable) { | 175 if (enable) { |
176 SkSurface* surface = this->createGPUSurface(); | 176 SkSurface* surface = this->createGPUSurface(); |
177 if (surface) { | 177 if (surface) { |
178 fSurface.reset(surface); | 178 fSurface.reset(surface); |
179 fGPUEnabled = true; | 179 fGPUEnabled = true; |
| 180 |
| 181 // When we switch to GPU, there seems to be some mystery draws in th
e canvas. So we |
| 182 // draw once to flush the pipe |
| 183 // TODO understand what is actually happening here |
| 184 fDebugCanvas->drawTo(this->getCanvas(), this->getLastOp()); |
| 185 this->getCanvas()->flush(); |
| 186 |
180 return true; | 187 return true; |
181 } | 188 } |
182 return false; | 189 return false; |
183 } | 190 } |
184 fSurface.reset(this->createCPUSurface()); | 191 fSurface.reset(this->createCPUSurface()); |
185 fGPUEnabled = false; | 192 fGPUEnabled = false; |
186 return true; | 193 return true; |
187 } | 194 } |
188 | 195 |
189 bool Request::initPictureFromStream(SkStream* stream) { | 196 bool Request::initPictureFromStream(SkStream* stream) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 canvas->flush(); | 264 canvas->flush(); |
258 SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas)); | 265 SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas)); |
259 SkASSERT(bitmap); | 266 SkASSERT(bitmap); |
260 bitmap->lockPixels(); | 267 bitmap->lockPixels(); |
261 uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * bitmap->width() + x
) * 4; | 268 uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * bitmap->width() + x
) * 4; |
262 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); | 269 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); |
263 bitmap->unlockPixels(); | 270 bitmap->unlockPixels(); |
264 return result; | 271 return result; |
265 } | 272 } |
266 | 273 |
OLD | NEW |