Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
| 10 #include "SkImage.h" | 10 #include "SkImage.h" |
| 11 #include "SkImageGenerator.h" | 11 #include "SkImageGenerator.h" |
| 12 #include "SkPictureData.h" | |
| 13 #include "SkPicturePlayback.h" | |
| 14 #include "SkPictureRecord.h" | |
| 15 #include "SkPictureRecorder.h" | |
| 12 #include "SkReadBuffer.h" | 16 #include "SkReadBuffer.h" |
| 13 #include "SkStream.h" | 17 #include "SkStream.h" |
| 14 #include "SkTypeface.h" | 18 #include "SkTypeface.h" |
| 15 | 19 |
| 16 static uint32_t default_flags() { | 20 static uint32_t default_flags() { |
| 17 uint32_t flags = 0; | 21 uint32_t flags = 0; |
| 18 flags |= SkReadBuffer::kScalarIsFloat_Flag; | 22 flags |= SkReadBuffer::kScalarIsFloat_Flag; |
| 19 if (8 == sizeof(void*)) { | 23 if (8 == sizeof(void*)) { |
| 20 flags |= SkReadBuffer::kPtrIs64Bit_Flag; | 24 flags |= SkReadBuffer::kPtrIs64Bit_Flag; |
| 21 } | 25 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 return; | 416 return; |
| 413 } | 417 } |
| 414 } else { | 418 } else { |
| 415 if (nullptr == this->readFunctionPtr()) { | 419 if (nullptr == this->readFunctionPtr()) { |
| 416 return; | 420 return; |
| 417 } | 421 } |
| 418 } | 422 } |
| 419 uint32_t sizeRecorded = fReader.readU32(); | 423 uint32_t sizeRecorded = fReader.readU32(); |
| 420 fReader.skip(sizeRecorded); | 424 fReader.skip(sizeRecorded); |
| 421 } | 425 } |
| 426 | |
| 427 static sk_sp<SkFlattenable> unflatten_recorded_drawable(SkReadBuffer& buffer) { | |
|
msarett
2016/04/25 16:40:38
Maybe this function belongs in a different file?
| |
| 428 // Read the bounds. | |
| 429 SkRect bounds; | |
| 430 buffer.readRect(&bounds); | |
| 431 | |
| 432 // Unflatten into a SkPictureData. | |
| 433 SkPictInfo info; | |
| 434 info.fCullRect = bounds; | |
| 435 SkAutoTDelete<SkPictureData> pictureData(SkPictureData::CreateFromBuffer(buf fer, info)); | |
| 436 if (!pictureData) { | |
| 437 return nullptr; | |
| 438 } | |
| 439 | |
| 440 // Create a drawable. | |
| 441 SkPicturePlayback playback(pictureData); | |
| 442 SkPictureRecorder recorder; | |
| 443 playback.draw(recorder.beginRecording(bounds), nullptr, &buffer); | |
| 444 return recorder.finishRecordingAsDrawable(); | |
| 445 } | |
| 446 | |
| 447 void SkReadBuffer::initDrawableFactories() { | |
| 448 this->setCustomFactory(SkString("SkRecordedDrawable"), unflatten_recorded_dr awable); | |
| 449 } | |
| OLD | NEW |