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 153583007: Revert "Serialization of SkPictureImageFilter" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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/effects/SkPictureImageFilter.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 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 writeFactories(stream, factSet); 424 writeFactories(stream, factSet);
425 writeTypefaces(stream, typefaceSet); 425 writeTypefaces(stream, typefaceSet);
426 426
427 writeTagSize(stream, PICT_BUFFER_SIZE_TAG, buffer.bytesWritten()); 427 writeTagSize(stream, PICT_BUFFER_SIZE_TAG, buffer.bytesWritten());
428 buffer.writeToStream(stream); 428 buffer.writeToStream(stream);
429 } 429 }
430 430
431 stream->write32(PICT_EOF_TAG); 431 stream->write32(PICT_EOF_TAG);
432 } 432 }
433 433
434 void SkPicturePlayback::flatten(SkWriteBuffer& buffer) const {
435 writeTagSize(buffer, PICT_READER_TAG, fOpData->size());
436 buffer.writeByteArray(fOpData->bytes(), fOpData->size());
437
438 if (fPictureCount > 0) {
439 writeTagSize(buffer, PICT_PICTURE_TAG, fPictureCount);
440 for (int i = 0; i < fPictureCount; i++) {
441 fPictureRefs[i]->flatten(buffer);
442 }
443 }
444
445 // Write this picture playback's data into a writebuffer
446 this->flattenToBuffer(buffer);
447 buffer.write32(PICT_EOF_TAG);
448 }
449
450 /////////////////////////////////////////////////////////////////////////////// 434 ///////////////////////////////////////////////////////////////////////////////
451 435
452 /** 436 /**
453 * Return the corresponding SkReadBuffer flags, given a set of 437 * Return the corresponding SkReadBuffer flags, given a set of
454 * SkPictInfo flags. 438 * SkPictInfo flags.
455 */ 439 */
456 static uint32_t pictInfoFlagsToReadBufferFlags(uint32_t pictInfoFlags) { 440 static uint32_t pictInfoFlagsToReadBufferFlags(uint32_t pictInfoFlags) {
457 static const struct { 441 static const struct {
458 uint32_t fSrc; 442 uint32_t fSrc;
459 uint32_t fDst; 443 uint32_t fDst;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 const SkPictInfo& info, 586 const SkPictInfo& info,
603 SkPicture::InstallPixelRe fProc proc) { 587 SkPicture::InstallPixelRe fProc proc) {
604 SkAutoTDelete<SkPicturePlayback> playback(SkNEW(SkPicturePlayback)); 588 SkAutoTDelete<SkPicturePlayback> playback(SkNEW(SkPicturePlayback));
605 589
606 if (!playback->parseStream(stream, info, proc)) { 590 if (!playback->parseStream(stream, info, proc)) {
607 return NULL; 591 return NULL;
608 } 592 }
609 return playback.detach(); 593 return playback.detach();
610 } 594 }
611 595
612 SkPicturePlayback* SkPicturePlayback::CreateFromBuffer(SkReadBuffer& buffer) {
613 SkAutoTDelete<SkPicturePlayback> playback(SkNEW(SkPicturePlayback));
614
615 if (!playback->parseBuffer(buffer)) {
616 return NULL;
617 }
618 return playback.detach();
619 }
620
621 bool SkPicturePlayback::parseStream(SkStream* stream, const SkPictInfo& info, 596 bool SkPicturePlayback::parseStream(SkStream* stream, const SkPictInfo& info,
622 SkPicture::InstallPixelRefProc proc) { 597 SkPicture::InstallPixelRefProc proc) {
623 for (;;) { 598 for (;;) {
624 uint32_t tag = stream->readU32(); 599 uint32_t tag = stream->readU32();
625 if (PICT_EOF_TAG == tag) { 600 if (PICT_EOF_TAG == tag) {
626 break; 601 break;
627 } 602 }
628 603
629 uint32_t size = stream->readU32(); 604 uint32_t size = stream->readU32();
630 if (!this->parseStreamTag(stream, info, tag, size, proc)) { 605 if (!this->parseStreamTag(stream, info, tag, size, proc)) {
631 return false; // we're invalid 606 return false; // we're invalid
632 } 607 }
633 } 608 }
634 return true; 609 return true;
635 } 610 }
636 611
637 bool SkPicturePlayback::parseBuffer(SkReadBuffer& buffer) {
638 for (;;) {
639 uint32_t tag = buffer.readUInt();
640 if (PICT_EOF_TAG == tag) {
641 break;
642 }
643
644 uint32_t size = buffer.readUInt();
645 if (!this->parseBufferTag(buffer, tag, size)) {
646 return false; // we're invalid
647 }
648 }
649 return true;
650 }
651
652 /////////////////////////////////////////////////////////////////////////////// 612 ///////////////////////////////////////////////////////////////////////////////
653 /////////////////////////////////////////////////////////////////////////////// 613 ///////////////////////////////////////////////////////////////////////////////
654 614
655 #ifdef SPEW_CLIP_SKIPPING 615 #ifdef SPEW_CLIP_SKIPPING
656 struct SkipClipRec { 616 struct SkipClipRec {
657 int fCount; 617 int fCount;
658 size_t fSize; 618 size_t fSize;
659 619
660 SkipClipRec() { 620 SkipClipRec() {
661 fCount = 0; 621 fCount = 0;
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 for (index = 0; index < fPictureCount; index++) 1590 for (index = 0; index < fPictureCount; index++)
1631 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1591 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1632 "picture%p, ", fPictureRefs[index]); 1592 "picture%p, ", fPictureRefs[index]);
1633 if (fPictureCount > 0) 1593 if (fPictureCount > 0)
1634 SkDebugf("%s0};\n", pBuffer); 1594 SkDebugf("%s0};\n", pBuffer);
1635 1595
1636 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1596 const_cast<SkPicturePlayback*>(this)->dumpStream();
1637 } 1597 }
1638 1598
1639 #endif 1599 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698