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 "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // write to png | 58 // write to png |
59 SkDynamicMemoryWStream buffer; | 59 SkDynamicMemoryWStream buffer; |
60 SkDrawCommand::WritePNG((const png_bytep) bmp->getPixels(), bmp->width(), bm
p->height(), | 60 SkDrawCommand::WritePNG((const png_bytep) bmp->getPixels(), bmp->width(), bm
p->height(), |
61 buffer); | 61 buffer); |
62 return buffer.copyToData(); | 62 return buffer.copyToData(); |
63 } | 63 } |
64 | 64 |
65 SkCanvas* Request::getCanvas() { | 65 SkCanvas* Request::getCanvas() { |
66 #if SK_SUPPORT_GPU | 66 #if SK_SUPPORT_GPU |
67 GrContextFactory* factory = fContextFactory; | 67 GrContextFactory* factory = fContextFactory; |
68 GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLCont
extType, | 68 GLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextT
ype, |
69 GrContextFactory::kNone_GLContextOpt
ions).fGLContext; | 69 GrContextFactory::kNone_GLContextOpt
ions).fGLContext; |
70 gl->makeCurrent(); | 70 gl->makeCurrent(); |
71 #endif | 71 #endif |
72 SkASSERT(fDebugCanvas); | 72 SkASSERT(fDebugCanvas); |
73 | 73 |
74 // create the appropriate surface if necessary | 74 // create the appropriate surface if necessary |
75 if (!fSurface) { | 75 if (!fSurface) { |
76 this->enableGPU(fGPUEnabled); | 76 this->enableGPU(fGPUEnabled); |
77 } | 77 } |
78 SkCanvas* target = fSurface->getCanvas(); | 78 SkCanvas* target = fSurface->getCanvas(); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 SkCanvas* canvas = this->getCanvas(); | 249 SkCanvas* canvas = this->getCanvas(); |
250 canvas->flush(); | 250 canvas->flush(); |
251 SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas)); | 251 SkAutoTDelete<SkBitmap> bitmap(this->getBitmapFromCanvas(canvas)); |
252 SkASSERT(bitmap); | 252 SkASSERT(bitmap); |
253 bitmap->lockPixels(); | 253 bitmap->lockPixels(); |
254 uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * bitmap->width() + x
) * 4; | 254 uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * bitmap->width() + x
) * 4; |
255 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); | 255 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); |
256 bitmap->unlockPixels(); | 256 bitmap->unlockPixels(); |
257 return result; | 257 return result; |
258 } | 258 } |
OLD | NEW |