Chromium Code Reviews| 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); |
| 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]) { | |
|
reed1
2013/06/24 22:24:14
so we want this, or is it better to crash? Do we c
scroggo
2013/06/25 15:36:50
We do not check for read failures in other places.
| |
| 532 // Delete the already created picture refs. | |
| 533 for (int k = 0; k < i; k++) { | |
| 534 fPictureRefs[i]->unref(); | |
| 535 } | |
| 536 // Delete the array | |
| 537 SkDELETE_ARRAY(fPictureRefs); | |
| 538 fPictureCount = 0; | |
| 539 return; | |
| 540 } | |
| 532 } | 541 } |
| 533 } break; | 542 } break; |
| 534 case PICT_BUFFER_SIZE_TAG: { | 543 case PICT_BUFFER_SIZE_TAG: { |
| 535 SkAutoMalloc storage(size); | 544 SkAutoMalloc storage(size); |
| 536 stream->read(storage.get(), size); | 545 stream->read(storage.get(), size); |
| 537 | 546 |
| 538 SkOrderedReadBuffer buffer(storage.get(), size); | 547 SkOrderedReadBuffer buffer(storage.get(), size); |
| 539 buffer.setFlags(pictInfoFlagsToReadBufferFlags(info.fFlags)); | 548 buffer.setFlags(pictInfoFlagsToReadBufferFlags(info.fFlags)); |
| 540 | 549 |
| 541 fFactoryPlayback->setupBuffer(buffer); | 550 fFactoryPlayback->setupBuffer(buffer); |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1610 for (index = 0; index < fRegionCount; index++) | 1619 for (index = 0; index < fRegionCount; index++) |
| 1611 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), | 1620 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), |
| 1612 "region%p, ", &fRegions[index]); | 1621 "region%p, ", &fRegions[index]); |
| 1613 if (fRegionCount > 0) | 1622 if (fRegionCount > 0) |
| 1614 SkDebugf("%s0};\n", pBuffer); | 1623 SkDebugf("%s0};\n", pBuffer); |
| 1615 | 1624 |
| 1616 const_cast<SkPicturePlayback*>(this)->dumpStream(); | 1625 const_cast<SkPicturePlayback*>(this)->dumpStream(); |
| 1617 } | 1626 } |
| 1618 | 1627 |
| 1619 #endif | 1628 #endif |
| OLD | NEW |