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 "SkWriteBuffer.h" | 8 #include "SkWriteBuffer.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 | 170 |
171 this->writeUInt(0); // signal raw pixels | 171 this->writeUInt(0); // signal raw pixels |
172 SkBitmap::WriteRawPixels(this, bitmap); | 172 SkBitmap::WriteRawPixels(this, bitmap); |
173 } | 173 } |
174 | 174 |
175 void SkBinaryWriteBuffer::writeImage(const SkImage* image) { | 175 void SkBinaryWriteBuffer::writeImage(const SkImage* image) { |
176 this->writeInt(image->width()); | 176 this->writeInt(image->width()); |
177 this->writeInt(image->height()); | 177 this->writeInt(image->height()); |
178 | 178 |
179 SkAutoTUnref<SkData> encoded(image->encode(this->getPixelSerializer())); | 179 sk_sp<SkData> encoded(image->encode(this->getPixelSerializer())); |
180 if (encoded && encoded->size() > 0) { | 180 if (encoded && encoded->size() > 0) { |
181 write_encoded_bitmap(this, encoded, SkIPoint::Make(0, 0)); | 181 write_encoded_bitmap(this, encoded.get(), SkIPoint::Make(0, 0)); |
182 return; | 182 return; |
183 } | 183 } |
184 | 184 |
185 SkBitmap bm; | 185 SkBitmap bm; |
186 if (image->asLegacyBitmap(&bm, SkImage::kRO_LegacyBitmapMode)) { | 186 if (image->asLegacyBitmap(&bm, SkImage::kRO_LegacyBitmapMode)) { |
187 this->writeUInt(1); // signal raw pixels. | 187 this->writeUInt(1); // signal raw pixels. |
188 SkBitmap::WriteRawPixels(this, bm); | 188 SkBitmap::WriteRawPixels(this, bm); |
189 return; | 189 return; |
190 } | 190 } |
191 | 191 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 // make room for the size of the flattened object | 275 // make room for the size of the flattened object |
276 (void)fWriter.reserve(sizeof(uint32_t)); | 276 (void)fWriter.reserve(sizeof(uint32_t)); |
277 // record the current size, so we can subtract after the object writes. | 277 // record the current size, so we can subtract after the object writes. |
278 size_t offset = fWriter.bytesWritten(); | 278 size_t offset = fWriter.bytesWritten(); |
279 // now flatten the object | 279 // now flatten the object |
280 flattenable->flatten(*this); | 280 flattenable->flatten(*this); |
281 size_t objSize = fWriter.bytesWritten() - offset; | 281 size_t objSize = fWriter.bytesWritten() - offset; |
282 // record the obj's size | 282 // record the obj's size |
283 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); | 283 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); |
284 } | 284 } |
OLD | NEW |