| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include <new> | 7 #include <new> |
| 8 #include "SkImageGenerator.h" | 8 #include "SkImageGenerator.h" |
| 9 #include "SkPictureData.h" | 9 #include "SkPictureData.h" |
| 10 #include "SkPictureRecord.h" | 10 #include "SkPictureRecord.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 SkPictureData::SkPictureData(const SkPictureRecord& record, | 36 SkPictureData::SkPictureData(const SkPictureRecord& record, |
| 37 const SkPictInfo& info) | 37 const SkPictInfo& info) |
| 38 : fInfo(info) { | 38 : fInfo(info) { |
| 39 | 39 |
| 40 this->init(); | 40 this->init(); |
| 41 | 41 |
| 42 fOpData = record.opData(); | 42 fOpData = record.opData(); |
| 43 | 43 |
| 44 fContentInfo.set(record.fContentInfo); | 44 fContentInfo.set(record.fContentInfo); |
| 45 | 45 |
| 46 fBitmaps = record.fBitmaps; | 46 fBitmaps.reset(); // we never make bitmaps (anymore) during recording |
| 47 fPaints = record.fPaints; | 47 fPaints = record.fPaints; |
| 48 | 48 |
| 49 fPaths.reset(record.fPaths.count()); | 49 fPaths.reset(record.fPaths.count()); |
| 50 record.fPaths.foreach([this](const SkPath& path, int n) { | 50 record.fPaths.foreach([this](const SkPath& path, int n) { |
| 51 // These indices are logically 1-based, but we need to serialize them | 51 // These indices are logically 1-based, but we need to serialize them |
| 52 // 0-based to keep the deserializing SkPictureData::getPath() working. | 52 // 0-based to keep the deserializing SkPictureData::getPath() working. |
| 53 fPaths[n-1] = path; | 53 fPaths[n-1] = path; |
| 54 }); | 54 }); |
| 55 | 55 |
| 56 this->initForPlayback(); | 56 this->initForPlayback(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 rec.copyToArray((SkRefCnt**)array); | 216 rec.copyToArray((SkRefCnt**)array); |
| 217 | 217 |
| 218 for (int i = 0; i < count; i++) { | 218 for (int i = 0; i < count; i++) { |
| 219 array[i]->serialize(stream); | 219 array[i]->serialize(stream); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 void SkPictureData::flattenToBuffer(SkWriteBuffer& buffer) const { | 223 void SkPictureData::flattenToBuffer(SkWriteBuffer& buffer) const { |
| 224 int i, n; | 224 int i, n; |
| 225 | 225 |
| 226 if ((n = fBitmaps.count()) > 0) { | 226 // we never record bitmaps anymore, only images |
| 227 write_tag_size(buffer, SK_PICT_BITMAP_BUFFER_TAG, n); | 227 SkASSERT(fBitmaps.count() == 0); |
| 228 for (i = 0; i < n; i++) { | |
| 229 buffer.writeBitmap(fBitmaps[i]); | |
| 230 } | |
| 231 } | |
| 232 | 228 |
| 233 if ((n = fPaints.count()) > 0) { | 229 if ((n = fPaints.count()) > 0) { |
| 234 write_tag_size(buffer, SK_PICT_PAINT_BUFFER_TAG, n); | 230 write_tag_size(buffer, SK_PICT_PAINT_BUFFER_TAG, n); |
| 235 for (i = 0; i < n; i++) { | 231 for (i = 0; i < n; i++) { |
| 236 buffer.writePaint(fPaints[i]); | 232 buffer.writePaint(fPaints[i]); |
| 237 } | 233 } |
| 238 } | 234 } |
| 239 | 235 |
| 240 if ((n = fPaths.count()) > 0) { | 236 if ((n = fPaths.count()) > 0) { |
| 241 write_tag_size(buffer, SK_PICT_PATH_BUFFER_TAG, n); | 237 write_tag_size(buffer, SK_PICT_PATH_BUFFER_TAG, n); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 } else { | 655 } else { |
| 660 return this->suitableForGpuRasterization(nullptr, reason); | 656 return this->suitableForGpuRasterization(nullptr, reason); |
| 661 } | 657 } |
| 662 } | 658 } |
| 663 | 659 |
| 664 bool SkPictureData::suitableForLayerOptimization() const { | 660 bool SkPictureData::suitableForLayerOptimization() const { |
| 665 return fContentInfo.numLayers() > 0; | 661 return fContentInfo.numLayers() > 0; |
| 666 } | 662 } |
| 667 #endif | 663 #endif |
| 668 /////////////////////////////////////////////////////////////////////////////// | 664 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |