| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  199         size_t offset = 0;  // this parameter is deprecated/ignored |  199         size_t offset = 0;  // this parameter is deprecated/ignored | 
|  200         // if we have to "encode" the bitmap, then we assume there is no |  200         // if we have to "encode" the bitmap, then we assume there is no | 
|  201         // offset to share, since we are effectively creating a new pixelref |  201         // offset to share, since we are effectively creating a new pixelref | 
|  202         SkAutoDataUnref data(fBitmapEncoder(&offset, bitmap)); |  202         SkAutoDataUnref data(fBitmapEncoder(&offset, bitmap)); | 
|  203         if (data.get() != NULL) { |  203         if (data.get() != NULL) { | 
|  204             write_encoded_bitmap(this, data, SkIPoint::Make(0, 0)); |  204             write_encoded_bitmap(this, data, SkIPoint::Make(0, 0)); | 
|  205             return; |  205             return; | 
|  206         } |  206         } | 
|  207     } |  207     } | 
|  208  |  208  | 
|  209     // Bitmap was not encoded. Record a zero, implying that the reader need not 
     decode. |  209     this->writeUInt(0); // signal raw pixels | 
|  210     this->writeUInt(0); |  210     SkBitmap::WriteRawPixels(this, bitmap); | 
|  211     bitmap.flatten(*this); |  | 
|  212 } |  211 } | 
|  213  |  212  | 
|  214 void SkWriteBuffer::writeTypeface(SkTypeface* obj) { |  213 void SkWriteBuffer::writeTypeface(SkTypeface* obj) { | 
|  215     if (NULL == obj || NULL == fTFSet) { |  214     if (NULL == obj || NULL == fTFSet) { | 
|  216         fWriter.write32(0); |  215         fWriter.write32(0); | 
|  217     } else { |  216     } else { | 
|  218         fWriter.write32(fTFSet->add(obj)); |  217         fWriter.write32(fTFSet->add(obj)); | 
|  219     } |  218     } | 
|  220 } |  219 } | 
|  221  |  220  | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  313     // make room for the size of the flattened object |  312     // make room for the size of the flattened object | 
|  314     (void)fWriter.reserve(sizeof(uint32_t)); |  313     (void)fWriter.reserve(sizeof(uint32_t)); | 
|  315     // record the current size, so we can subtract after the object writes. |  314     // record the current size, so we can subtract after the object writes. | 
|  316     size_t offset = fWriter.bytesWritten(); |  315     size_t offset = fWriter.bytesWritten(); | 
|  317     // now flatten the object |  316     // now flatten the object | 
|  318     flattenable->flatten(*this); |  317     flattenable->flatten(*this); | 
|  319     size_t objSize = fWriter.bytesWritten() - offset; |  318     size_t objSize = fWriter.bytesWritten() - offset; | 
|  320     // record the obj's size |  319     // record the obj's size | 
|  321     fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); |  320     fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); | 
|  322 } |  321 } | 
| OLD | NEW |