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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 SkData* Request::drawToPng(int n, int m) { | 92 SkData* Request::drawToPng(int n, int m) { |
93 this->drawToCanvas(n, m); | 93 this->drawToCanvas(n, m); |
94 return writeCanvasToPng(this->getCanvas()); | 94 return writeCanvasToPng(this->getCanvas()); |
95 } | 95 } |
96 | 96 |
97 SkData* Request::writeOutSkp() { | 97 SkData* Request::writeOutSkp() { |
98 // Playback into picture recorder | 98 // Playback into picture recorder |
99 SkIRect bounds = this->getBounds(); | 99 SkIRect bounds = this->getBounds(); |
100 SkPictureRecorder recorder; | 100 SkPictureRecorder recorder; |
101 SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height()); | 101 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bounds.width()), |
| 102 SkIntToScalar(bounds.height())); |
102 | 103 |
103 fDebugCanvas->draw(canvas); | 104 fDebugCanvas->draw(canvas); |
104 | 105 |
105 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); | 106 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); |
106 | 107 |
107 SkDynamicMemoryWStream outStream; | 108 SkDynamicMemoryWStream outStream; |
108 | 109 |
109 SkAutoTUnref<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerial
izer()); | 110 SkAutoTUnref<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerial
izer()); |
110 picture->serialize(&outStream, serializer); | 111 picture->serialize(&outStream, serializer); |
111 | 112 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 SkASSERT(bitmap); | 292 SkASSERT(bitmap); |
292 | 293 |
293 // Convert to format suitable for inspection | 294 // Convert to format suitable for inspection |
294 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); | 295 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); |
295 SkASSERT(encodedBitmap.get()); | 296 SkASSERT(encodedBitmap.get()); |
296 | 297 |
297 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) *
4); | 298 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) *
4); |
298 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); | 299 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); |
299 return result; | 300 return result; |
300 } | 301 } |
OLD | NEW |