OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "SkPicturePlayback.h" | 8 #include "SkPicturePlayback.h" |
9 #include "SkPictureRecord.h" | 9 #include "SkPictureRecord.h" |
10 #include "SkTypeface.h" | 10 #include "SkTypeface.h" |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 // fTFPlayback asserts it never has a null, so we plop in | 513 // fTFPlayback asserts it never has a null, so we plop in |
514 // the default here. | 514 // the default here. |
515 tf.reset(SkTypeface::RefDefault()); | 515 tf.reset(SkTypeface::RefDefault()); |
516 } | 516 } |
517 fTFPlayback.set(i, tf); | 517 fTFPlayback.set(i, tf); |
518 } | 518 } |
519 } break; | 519 } break; |
520 case PICT_PICTURE_TAG: { | 520 case PICT_PICTURE_TAG: { |
521 fPictureCount = size; | 521 fPictureCount = size; |
522 fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount); | 522 fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount); |
523 bool success; | |
524 for (int i = 0; i < fPictureCount; i++) { | 523 for (int i = 0; i < fPictureCount; i++) { |
525 fPictureRefs[i] = SkNEW_ARGS(SkPicture, (stream, &success, proc) ); | 524 fPictureRefs[i] = SkPicture::CreateFromStream(stream, proc); |
robertphillips
2013/06/24 17:22:09
I don't think this comment is true.
scroggo
2013/06/24 18:22:19
How else can it fail?
| |
526 // Success can only be false if PICTURE_VERSION does not match | 525 // CreateFromStream can only fail if PICTURE_VERSION does not ma tch |
527 // (which should never happen from here, since a sub picture wil l | 526 // (which should never happen from here, since a sub picture wil l |
528 // have the same PICTURE_VERSION as its parent) or if stream->re ad | 527 // have the same PICTURE_VERSION as its parent) or if stream->re ad |
529 // returns 0. In the latter case, we have a bug when writing the | 528 // returns 0. In the latter case, we have a bug when writing the |
530 // picture to begin with, which will be alerted to here. | 529 // picture to begin with, which will be alerted to here. |
531 SkASSERT(success); | 530 SkASSERT(fPictureRefs[i] != NULL); |
531 if (NULL == fPictureRefs[i]) { | |
532 // Delete the array | |
robertphillips
2013/06/24 17:22:09
Don't we need to also loop backwards across the ar
scroggo
2013/06/24 18:22:19
Yes. Done.
| |
533 SkDELETE_ARRAY(fPictureRefs); | |
534 fPictureCount = 0; | |
535 return; | |
536 } | |
532 } | 537 } |
533 } break; | 538 } break; |
534 case PICT_BUFFER_SIZE_TAG: { | 539 case PICT_BUFFER_SIZE_TAG: { |
535 SkAutoMalloc storage(size); | 540 SkAutoMalloc storage(size); |
536 stream->read(storage.get(), size); | 541 stream->read(storage.get(), size); |
537 | 542 |
538 SkOrderedReadBuffer buffer(storage.get(), size); | 543 SkOrderedReadBuffer buffer(storage.get(), size); |
539 buffer.setFlags(pictInfoFlagsToReadBufferFlags(info.fFlags)); | 544 buffer.setFlags(pictInfoFlagsToReadBufferFlags(info.fFlags)); |
540 | 545 |
541 fFactoryPlayback->setupBuffer(buffer); | 546 fFactoryPlayback->setupBuffer(buffer); |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1610 for (index = 0; index < fRegionCount; index++) | 1615 for (index = 0; index < fRegionCount; index++) |
1611 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), | 1616 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), |
1612 "region%p, ", &fRegions[index]); | 1617 "region%p, ", &fRegions[index]); |
1613 if (fRegionCount > 0) | 1618 if (fRegionCount > 0) |
1614 SkDebugf("%s0};\n", pBuffer); | 1619 SkDebugf("%s0};\n", pBuffer); |
1615 | 1620 |
1616 const_cast<SkPicturePlayback*>(this)->dumpStream(); | 1621 const_cast<SkPicturePlayback*>(this)->dumpStream(); |
1617 } | 1622 } |
1618 | 1623 |
1619 #endif | 1624 #endif |
OLD | NEW |