Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/core/SkWriteBuffer.cpp

Issue 1501303002: SkPixelSerializer: support indexed pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-07 (Monday) 15:24:44 EST Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPixelSerializer.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const SkPixmap& pmap = result.pixmap();
204 SkASSERT(nullptr == fBitmapHeap); 203 SkASSERT(nullptr == fBitmapHeap);
205 SkAutoDataUnref data(fPixelSerializer->encodePixels(pmap.info(), 204 SkAutoDataUnref data(fPixelSerializer->encode(result.pixmap()));
206 pmap.addr(),
207 pmap.rowBytes()) );
208 if (data.get() != nullptr) { 205 if (data.get() != nullptr) {
209 // 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
210 // 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
211 write_encoded_bitmap(this, data, SkIPoint::Make(0, 0)); 208 write_encoded_bitmap(this, data, SkIPoint::Make(0, 0));
212 return; 209 return;
213 } 210 }
214 } 211 }
215 } 212 }
216 213
217 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
334 // make room for the size of the flattened object 331 // make room for the size of the flattened object
335 (void)fWriter.reserve(sizeof(uint32_t)); 332 (void)fWriter.reserve(sizeof(uint32_t));
336 // 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.
337 size_t offset = fWriter.bytesWritten(); 334 size_t offset = fWriter.bytesWritten();
338 // now flatten the object 335 // now flatten the object
339 flattenable->flatten(*this); 336 flattenable->flatten(*this);
340 size_t objSize = fWriter.bytesWritten() - offset; 337 size_t objSize = fWriter.bytesWritten() - offset;
341 // record the obj's size 338 // record the obj's size
342 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize)); 339 fWriter.overwriteTAt(offset - sizeof(uint32_t), SkToU32(objSize));
343 } 340 }
OLDNEW
« no previous file with comments | « include/core/SkPixelSerializer.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698