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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // capture pixels | 56 // capture pixels |
57 SkAutoTDelete<SkBitmap> bmp(this->getBitmapFromCanvas(canvas)); | 57 SkAutoTDelete<SkBitmap> bmp(this->getBitmapFromCanvas(canvas)); |
58 SkASSERT(bmp); | 58 SkASSERT(bmp); |
59 | 59 |
60 // Convert to format suitable for PNG output | 60 // Convert to format suitable for PNG output |
61 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bmp); | 61 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bmp); |
62 SkASSERT(encodedBitmap.get()); | 62 SkASSERT(encodedBitmap.get()); |
63 | 63 |
64 // write to an opaque png (black background) | 64 // write to an opaque png (black background) |
65 SkDynamicMemoryWStream buffer; | 65 SkDynamicMemoryWStream buffer; |
66 SkDrawCommand::WritePNG((const png_bytep) encodedBitmap->bytes(), bmp->width
(), bmp->height(), | 66 SkDrawCommand::WritePNG(encodedBitmap->bytes(), bmp->width(), bmp->height(), |
67 buffer, true); | 67 buffer, true); |
68 return buffer.detachAsData(); | 68 return buffer.detachAsData(); |
69 } | 69 } |
70 | 70 |
71 SkCanvas* Request::getCanvas() { | 71 SkCanvas* Request::getCanvas() { |
72 #if SK_SUPPORT_GPU | 72 #if SK_SUPPORT_GPU |
73 GrContextFactory* factory = fContextFactory; | 73 GrContextFactory* factory = fContextFactory; |
74 GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNativeGL_Cont
extType, | 74 GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNativeGL_Cont
extType, |
75 GrContextFactory::ContextOptions:
:kNone).glContext(); | 75 GrContextFactory::ContextOptions:
:kNone).glContext(); |
76 if (!gl) { | 76 if (!gl) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 SkASSERT(bitmap); | 298 SkASSERT(bitmap); |
299 | 299 |
300 // Convert to format suitable for inspection | 300 // Convert to format suitable for inspection |
301 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); | 301 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); |
302 SkASSERT(encodedBitmap); | 302 SkASSERT(encodedBitmap); |
303 | 303 |
304 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) *
4); | 304 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) *
4); |
305 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); | 305 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); |
306 return result; | 306 return result; |
307 } | 307 } |
OLD | NEW |