Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkWriteBuffer.h" | 9 #include "SkWriteBuffer.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 // unflattened (i.e. stale) instance of a similar flattenable is in the dictionary | 179 // unflattened (i.e. stale) instance of a similar flattenable is in the dictionary |
| 180 // and the instance currently being written is re-using the same slot fr om the | 180 // and the instance currently being written is re-using the same slot fr om the |
| 181 // bitmap heap. | 181 // bitmap heap. |
| 182 fWriter.write32(bitmap.getGenerationID()); | 182 fWriter.write32(bitmap.getGenerationID()); |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 | 185 |
| 186 SkPixelRef* pixelRef = bitmap.pixelRef(); | 186 SkPixelRef* pixelRef = bitmap.pixelRef(); |
| 187 if (pixelRef) { | 187 if (pixelRef) { |
| 188 // see if the pixelref already has an encoded version | 188 // see if the pixelref already has an encoded version |
| 189 SkAutoDataUnref existingData(pixelRef->refEncodedData()); | 189 SkAutoTUnref<SkData> existingData(pixelRef->refEncodedData()); |
|
bungeman-skia
2016/03/11 14:53:13
Not sk_sp?
reed1
2016/03/11 19:23:34
PixelRef (and PixelSerializer below) are not yet c
| |
| 190 if (existingData.get() != nullptr) { | 190 if (existingData.get() != nullptr) { |
| 191 // Assumes that if the client did not set a serializer, they are | 191 // Assumes that if the client did not set a serializer, they are |
| 192 // happy to get the encoded data. | 192 // happy to get the encoded data. |
| 193 if (!fPixelSerializer || fPixelSerializer->useEncodedData(existingDa ta->data(), | 193 if (!fPixelSerializer || fPixelSerializer->useEncodedData(existingDa ta->data(), |
| 194 existingDa ta->size())) { | 194 existingDa ta->size())) { |
| 195 write_encoded_bitmap(this, existingData, bitmap.pixelRefOrigin() ); | 195 write_encoded_bitmap(this, existingData, bitmap.pixelRefOrigin() ); |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 // see if the caller wants to manually encode | 200 // see if the caller wants to manually encode |
| 201 SkAutoPixmapUnlock result; | 201 SkAutoPixmapUnlock result; |
| 202 if (fPixelSerializer && bitmap.requestLock(&result)) { | 202 if (fPixelSerializer && bitmap.requestLock(&result)) { |
| 203 SkASSERT(nullptr == fBitmapHeap); | 203 SkASSERT(nullptr == fBitmapHeap); |
| 204 SkAutoDataUnref data(fPixelSerializer->encode(result.pixmap())); | 204 SkAutoTUnref<SkData> data(fPixelSerializer->encode(result.pixmap())) ; |
| 205 if (data.get() != nullptr) { | 205 if (data.get() != nullptr) { |
| 206 // if we have to "encode" the bitmap, then we assume there is no | 206 // if we have to "encode" the bitmap, then we assume there is no |
| 207 // offset to share, since we are effectively creating a new pixe lref | 207 // offset to share, since we are effectively creating a new pixe lref |
| 208 write_encoded_bitmap(this, data, SkIPoint::Make(0, 0)); | 208 write_encoded_bitmap(this, data, SkIPoint::Make(0, 0)); |
| 209 return; | 209 return; |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 this->writeUInt(0); // signal raw pixels | 214 this->writeUInt(0); // signal raw pixels |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 // make room for the size of the flattened object | 331 // make room for the size of the flattened object |
| 332 (void)fWriter.reserve(sizeof(uint32_t)); | 332 (void)fWriter.reserve(sizeof(uint32_t)); |
| 333 // record the current size, so we can subtract after the object writes. | 333 // record the current size, so we can subtract after the object writes. |
| 334 size_t offset = fWriter.bytesWritten(); | 334 size_t offset = fWriter.bytesWritten(); |
| 335 // now flatten the object | 335 // now flatten the object |
| 336 flattenable->flatten(*this); | 336 flattenable->flatten(*this); |
| 337 size_t objSize = fWriter.bytesWritten() - offset; | 337 size_t objSize = fWriter.bytesWritten() - offset; |
| 338 // record the obj's size | 338 // record the obj's size |
| 339 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); | 339 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); |
| 340 } | 340 } |
| OLD | NEW |