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

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

Issue 244273002: fix size_t/int warnings in pictures (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureRecord.h » ('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 * 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, size_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(SkToU32(size));
316 } 316 }
317 317
318 static void write_tag_size(SkWStream* stream, uint32_t tag, size_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(SkToU32(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
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 for (size_t i = 0; i < SK_ARRAY_COUNT(gSD); ++i) { 477 for (size_t i = 0; i < SK_ARRAY_COUNT(gSD); ++i) {
478 if (pictInfoFlags & gSD[i].fSrc) { 478 if (pictInfoFlags & gSD[i].fSrc) {
479 rbMask |= gSD[i].fDst; 479 rbMask |= gSD[i].fDst;
480 } 480 }
481 } 481 }
482 return rbMask; 482 return rbMask;
483 } 483 }
484 484
485 bool SkPicturePlayback::parseStreamTag(SkStream* stream, 485 bool SkPicturePlayback::parseStreamTag(SkStream* stream,
486 uint32_t tag, 486 uint32_t tag,
487 size_t size, 487 uint32_t size,
488 SkPicture::InstallPixelRefProc proc) { 488 SkPicture::InstallPixelRefProc proc) {
489 /* 489 /*
490 * By the time we encounter BUFFER_SIZE_TAG, we need to have already seen 490 * By the time we encounter BUFFER_SIZE_TAG, we need to have already seen
491 * its dependents: FACTORY_TAG and TYPEFACE_TAG. These two are not required 491 * its dependents: FACTORY_TAG and TYPEFACE_TAG. These two are not required
492 * but if they are present, they need to have been seen before the buffer. 492 * but if they are present, they need to have been seen before the buffer.
493 * 493 *
494 * We assert that if/when we see either of these, that we have not yet seen 494 * We assert that if/when we see either of these, that we have not yet seen
495 * the buffer tag, because if we have, then its too-late to deal with the 495 * the buffer tag, because if we have, then its too-late to deal with the
496 * factories or typefaces. 496 * factories or typefaces.
497 */ 497 */
(...skipping 27 matching lines...) Expand all
525 const size_t len = stream->readPackedUInt(); 525 const size_t len = stream->readPackedUInt();
526 str.resize(len); 526 str.resize(len);
527 if (stream->read(str.writable_str(), len) != len) { 527 if (stream->read(str.writable_str(), len) != len) {
528 return false; 528 return false;
529 } 529 }
530 fFactoryPlayback->base()[i] = SkFlattenable::NameToFactory(str.c _str()); 530 fFactoryPlayback->base()[i] = SkFlattenable::NameToFactory(str.c _str());
531 } 531 }
532 } break; 532 } break;
533 case SK_PICT_TYPEFACE_TAG: { 533 case SK_PICT_TYPEFACE_TAG: {
534 SkASSERT(!haveBuffer); 534 SkASSERT(!haveBuffer);
535 fTFPlayback.setCount(size); 535 const int count = SkToInt(size);
536 for (size_t i = 0; i < size; i++) { 536 fTFPlayback.setCount(count);
537 for (int i = 0; i < count; i++) {
537 SkAutoTUnref<SkTypeface> tf(SkTypeface::Deserialize(stream)); 538 SkAutoTUnref<SkTypeface> tf(SkTypeface::Deserialize(stream));
538 if (!tf.get()) { // failed to deserialize 539 if (!tf.get()) { // failed to deserialize
539 // fTFPlayback asserts it never has a null, so we plop in 540 // fTFPlayback asserts it never has a null, so we plop in
540 // the default here. 541 // the default here.
541 tf.reset(SkTypeface::RefDefault()); 542 tf.reset(SkTypeface::RefDefault());
542 } 543 }
543 fTFPlayback.set(i, tf); 544 fTFPlayback.set(i, tf);
544 } 545 }
545 } break; 546 } break;
546 case SK_PICT_PICTURE_TAG: { 547 case SK_PICT_PICTURE_TAG: {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 return false; 588 return false;
588 } 589 }
589 } 590 }
590 SkDEBUGCODE(haveBuffer = true;) 591 SkDEBUGCODE(haveBuffer = true;)
591 } break; 592 } break;
592 } 593 }
593 return true; // success 594 return true; // success
594 } 595 }
595 596
596 bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer, 597 bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer,
597 uint32_t tag, size_t size) { 598 uint32_t tag, uint32_t size) {
598 switch (tag) { 599 switch (tag) {
599 case SK_PICT_BITMAP_BUFFER_TAG: { 600 case SK_PICT_BITMAP_BUFFER_TAG: {
601 const int count = SkToInt(size);
600 fBitmaps = SkTRefArray<SkBitmap>::Create(size); 602 fBitmaps = SkTRefArray<SkBitmap>::Create(size);
601 for (size_t i = 0; i < size; ++i) { 603 for (int i = 0; i < count; ++i) {
602 SkBitmap* bm = &fBitmaps->writableAt(i); 604 SkBitmap* bm = &fBitmaps->writableAt(i);
603 buffer.readBitmap(bm); 605 buffer.readBitmap(bm);
604 bm->setImmutable(); 606 bm->setImmutable();
605 } 607 }
606 } break; 608 } break;
607 case SK_PICT_PAINT_BUFFER_TAG: { 609 case SK_PICT_PAINT_BUFFER_TAG: {
610 const int count = SkToInt(size);
608 fPaints = SkTRefArray<SkPaint>::Create(size); 611 fPaints = SkTRefArray<SkPaint>::Create(size);
609 for (size_t i = 0; i < size; ++i) { 612 for (int i = 0; i < count; ++i) {
610 buffer.readPaint(&fPaints->writableAt(i)); 613 buffer.readPaint(&fPaints->writableAt(i));
611 } 614 }
612 } break; 615 } break;
613 case SK_PICT_PATH_BUFFER_TAG: 616 case SK_PICT_PATH_BUFFER_TAG:
614 if (size > 0) { 617 if (size > 0) {
615 fPathHeap.reset(SkNEW_ARGS(SkPathHeap, (buffer))); 618 fPathHeap.reset(SkNEW_ARGS(SkPathHeap, (buffer)));
616 } 619 }
617 break; 620 break;
618 case SK_PICT_READER_TAG: { 621 case SK_PICT_READER_TAG: {
619 SkAutoMalloc storage(size); 622 SkAutoMalloc storage(size);
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 for (index = 0; index < fPictureCount; index++) 1782 for (index = 0; index < fPictureCount; index++)
1780 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1783 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1781 "picture%p, ", fPictureRefs[index]); 1784 "picture%p, ", fPictureRefs[index]);
1782 if (fPictureCount > 0) 1785 if (fPictureCount > 0)
1783 SkDebugf("%s0};\n", pBuffer); 1786 SkDebugf("%s0};\n", pBuffer);
1784 1787
1785 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1788 const_cast<SkPicturePlayback*>(this)->dumpStream();
1786 } 1789 }
1787 1790
1788 #endif 1791 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698