| 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 "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
| 9 #include "SkPicturePlayback.h" | 9 #include "SkPicturePlayback.h" |
| 10 #include "SkPictureRecord.h" | 10 #include "SkPictureRecord.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 return false; | 305 return false; |
| 306 } | 306 } |
| 307 | 307 |
| 308 /////////////////////////////////////////////////////////////////////////////// | 308 /////////////////////////////////////////////////////////////////////////////// |
| 309 /////////////////////////////////////////////////////////////////////////////// | 309 /////////////////////////////////////////////////////////////////////////////// |
| 310 | 310 |
| 311 #include "SkStream.h" | 311 #include "SkStream.h" |
| 312 | 312 |
| 313 static void write_tag_size(SkWriteBuffer& buffer, uint32_t tag, uint32_t size) { | 313 static void write_tag_size(SkWriteBuffer& buffer, uint32_t tag, size_t size) { |
| 314 buffer.writeUInt(tag); | 314 buffer.writeUInt(tag); |
| 315 buffer.writeUInt(size); | 315 buffer.writeUInt(size); |
| 316 } | 316 } |
| 317 | 317 |
| 318 static void write_tag_size(SkWStream* stream, uint32_t tag, uint32_t size) { | 318 static void write_tag_size(SkWStream* stream, uint32_t tag, size_t size) { |
| 319 stream->write32(tag); | 319 stream->write32(tag); |
| 320 stream->write32(size); | 320 stream->write32(SkToU32(size)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 static size_t compute_chunk_size(SkFlattenable::Factory* array, int count) { | 323 static size_t compute_chunk_size(SkFlattenable::Factory* array, int count) { |
| 324 size_t size = 4; // for 'count' | 324 size_t size = 4; // for 'count' |
| 325 | 325 |
| 326 for (int i = 0; i < count; i++) { | 326 for (int i = 0; i < count; i++) { |
| 327 const char* name = SkFlattenable::FactoryToName(array[i]); | 327 const char* name = SkFlattenable::FactoryToName(array[i]); |
| 328 if (NULL == name || 0 == *name) { | 328 if (NULL == name || 0 == *name) { |
| 329 size += SkWStream::SizeOfPackedUInt(0); | 329 size += SkWStream::SizeOfPackedUInt(0); |
| 330 } else { | 330 } else { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 350 write_tag_size(stream, SK_PICT_FACTORY_TAG, (uint32_t) size); | 350 write_tag_size(stream, SK_PICT_FACTORY_TAG, (uint32_t) size); |
| 351 SkDEBUGCODE(size_t start = stream->bytesWritten()); | 351 SkDEBUGCODE(size_t start = stream->bytesWritten()); |
| 352 stream->write32(count); | 352 stream->write32(count); |
| 353 | 353 |
| 354 for (int i = 0; i < count; i++) { | 354 for (int i = 0; i < count; i++) { |
| 355 const char* name = SkFlattenable::FactoryToName(array[i]); | 355 const char* name = SkFlattenable::FactoryToName(array[i]); |
| 356 // SkDebugf("---- write factories [%d] %p <%s>\n", i, array[i], name); | 356 // SkDebugf("---- write factories [%d] %p <%s>\n", i, array[i], name); |
| 357 if (NULL == name || 0 == *name) { | 357 if (NULL == name || 0 == *name) { |
| 358 stream->writePackedUInt(0); | 358 stream->writePackedUInt(0); |
| 359 } else { | 359 } else { |
| 360 uint32_t len = strlen(name); | 360 size_t len = strlen(name); |
| 361 stream->writePackedUInt(len); | 361 stream->writePackedUInt(len); |
| 362 stream->write(name, len); | 362 stream->write(name, len); |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 SkASSERT(size == (stream->bytesWritten() - start)); | 366 SkASSERT(size == (stream->bytesWritten() - start)); |
| 367 } | 367 } |
| 368 | 368 |
| 369 static void write_typefaces(SkWStream* stream, const SkRefCntSet& rec) { | 369 static void write_typefaces(SkWStream* stream, const SkRefCntSet& rec) { |
| 370 int count = rec.count(); | 370 int count = rec.count(); |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 for (index = 0; index < fPictureCount; index++) | 1779 for (index = 0; index < fPictureCount; index++) |
| 1780 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), | 1780 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer
), |
| 1781 "picture%p, ", fPictureRefs[index]); | 1781 "picture%p, ", fPictureRefs[index]); |
| 1782 if (fPictureCount > 0) | 1782 if (fPictureCount > 0) |
| 1783 SkDebugf("%s0};\n", pBuffer); | 1783 SkDebugf("%s0};\n", pBuffer); |
| 1784 | 1784 |
| 1785 const_cast<SkPicturePlayback*>(this)->dumpStream(); | 1785 const_cast<SkPicturePlayback*>(this)->dumpStream(); |
| 1786 } | 1786 } |
| 1787 | 1787 |
| 1788 #endif | 1788 #endif |
| OLD | NEW |