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

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

Issue 15746003: Remove offsetcanvas from debugger (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review issues Created 7 years, 7 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') | no next file » | 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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 618 }
619 619
620 void recordSkip(size_t bytes) { 620 void recordSkip(size_t bytes) {
621 fCount += 1; 621 fCount += 1;
622 fSize += bytes; 622 fSize += bytes;
623 } 623 }
624 }; 624 };
625 #endif 625 #endif
626 626
627 #ifdef SK_DEVELOPER 627 #ifdef SK_DEVELOPER
628 size_t SkPicturePlayback::preDraw(size_t offset, int type) { 628 bool SkPicturePlayback::preDraw(int opIndex, int type) {
629 return 0; 629 return false;
630 } 630 }
631 631
632 void SkPicturePlayback::postDraw(size_t offset) { 632 void SkPicturePlayback::postDraw(int opIndex) {
633 } 633 }
634 #endif 634 #endif
635 635
636 /* 636 /*
637 * Read the next op code and chunk size from 'reader'. The returned size 637 * Read the next op code and chunk size from 'reader'. The returned size
638 * is the entire size of the chunk (including the opcode). Thus, the 638 * is the entire size of the chunk (including the opcode). Thus, the
639 * offset just prior to calling read_op_and_size + 'size' is the offset 639 * offset just prior to calling read_op_and_size + 'size' is the offset
640 * to the next chunk's op code. This also means that the size of a chunk 640 * to the next chunk's op code. This also means that the size of a chunk
641 * with no arguments (just an opcode) will be 4. 641 * with no arguments (just an opcode) will be 4.
642 */ 642 */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 705 }
706 706
707 // Record this, so we can concat w/ it if we encounter a setMatrix() 707 // Record this, so we can concat w/ it if we encounter a setMatrix()
708 SkMatrix initialMatrix = canvas.getTotalMatrix(); 708 SkMatrix initialMatrix = canvas.getTotalMatrix();
709 int originalSaveCount = canvas.getSaveCount(); 709 int originalSaveCount = canvas.getSaveCount();
710 710
711 #ifdef SK_BUILD_FOR_ANDROID 711 #ifdef SK_BUILD_FOR_ANDROID
712 fAbortCurrentPlayback = false; 712 fAbortCurrentPlayback = false;
713 #endif 713 #endif
714 714
715 #ifdef SK_DEVELOPER
716 int opIndex = -1;
717 #endif
718
715 while (!reader.eof()) { 719 while (!reader.eof()) {
716 if (callback && callback->abortDrawing()) { 720 if (callback && callback->abortDrawing()) {
717 canvas.restoreToCount(originalSaveCount); 721 canvas.restoreToCount(originalSaveCount);
718 return; 722 return;
719 } 723 }
720 #ifdef SK_BUILD_FOR_ANDROID 724 #ifdef SK_BUILD_FOR_ANDROID
721 if (fAbortCurrentPlayback) { 725 if (fAbortCurrentPlayback) {
722 return; 726 return;
723 } 727 }
724 #endif 728 #endif
725 729
726 size_t curOffset = reader.offset(); 730 size_t curOffset = reader.offset();
727 uint32_t size; 731 uint32_t size;
728 DrawType op = read_op_and_size(&reader, &size); 732 DrawType op = read_op_and_size(&reader, &size);
729 size_t skipTo = 0; 733 size_t skipTo = 0;
730 #ifdef SK_DEVELOPER 734 if (NOOP == op) {
731 // TODO: once chunk sizes are in all .skps just use
732 // "curOffset + size"
733 skipTo = this->preDraw(curOffset, op);
734 #endif
735 if (0 == skipTo && NOOP == op) {
736 // NOOPs are to be ignored - do not propagate them any further 735 // NOOPs are to be ignored - do not propagate them any further
737 skipTo = curOffset + size; 736 skipTo = curOffset + size;
737 #ifdef SK_DEVELOPER
738 } else {
739 opIndex++;
740 if (this->preDraw(opIndex, op)) {
741 skipTo = curOffset + size;
742 }
743 #endif
738 } 744 }
739 745
740 if (0 != skipTo) { 746 if (0 != skipTo) {
741 if (it.isValid()) { 747 if (it.isValid()) {
742 // If using a bounding box hierarchy, advance the state tree 748 // If using a bounding box hierarchy, advance the state tree
743 // iterator until at or after skipTo 749 // iterator until at or after skipTo
744 uint32_t adjustedSkipTo; 750 uint32_t adjustedSkipTo;
745 do { 751 do {
746 adjustedSkipTo = it.draw(); 752 adjustedSkipTo = it.draw();
747 } while (adjustedSkipTo < skipTo); 753 } while (adjustedSkipTo < skipTo);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 case TRANSLATE: { 1022 case TRANSLATE: {
1017 SkScalar dx = reader.readScalar(); 1023 SkScalar dx = reader.readScalar();
1018 SkScalar dy = reader.readScalar(); 1024 SkScalar dy = reader.readScalar();
1019 canvas.translate(dx, dy); 1025 canvas.translate(dx, dy);
1020 } break; 1026 } break;
1021 default: 1027 default:
1022 SkASSERT(0); 1028 SkASSERT(0);
1023 } 1029 }
1024 1030
1025 #ifdef SK_DEVELOPER 1031 #ifdef SK_DEVELOPER
1026 this->postDraw(curOffset); 1032 this->postDraw(opIndex);
1027 #endif 1033 #endif
1028 1034
1029 if (it.isValid()) { 1035 if (it.isValid()) {
1030 uint32_t skipTo = it.draw(); 1036 uint32_t skipTo = it.draw();
1031 if (kDrawComplete == skipTo) { 1037 if (kDrawComplete == skipTo) {
1032 break; 1038 break;
1033 } 1039 }
1034 reader.setOffset(skipTo); 1040 reader.setOffset(skipTo);
1035 } 1041 }
1036 } 1042 }
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 for (index = 0; index < fRegionCount; index++) 1598 for (index = 0; index < fRegionCount; index++)
1593 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1599 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1594 "region%p, ", &fRegions[index]); 1600 "region%p, ", &fRegions[index]);
1595 if (fRegionCount > 0) 1601 if (fRegionCount > 0)
1596 SkDebugf("%s0};\n", pBuffer); 1602 SkDebugf("%s0};\n", pBuffer);
1597 1603
1598 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1604 const_cast<SkPicturePlayback*>(this)->dumpStream();
1599 } 1605 }
1600 1606
1601 #endif 1607 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698