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

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

Issue 138013009: Culling API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated per comments. Created 6 years, 9 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/SkPictureFlat.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 /* 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 } 700 }
701 return (DrawType) op; 701 return (DrawType) op;
702 } 702 }
703 703
704 void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) { 704 void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) {
705 #ifdef ENABLE_TIME_DRAW 705 #ifdef ENABLE_TIME_DRAW
706 SkAutoTime at("SkPicture::draw", 50); 706 SkAutoTime at("SkPicture::draw", 50);
707 #endif 707 #endif
708 708
709 #ifdef SPEW_CLIP_SKIPPING 709 #ifdef SPEW_CLIP_SKIPPING
710 SkipClipRec skipRect, skipRRect, skipRegion, skipPath; 710 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull;
711 int opCount = 0;
711 #endif 712 #endif
712 713
713 #ifdef SK_BUILD_FOR_ANDROID 714 #ifdef SK_BUILD_FOR_ANDROID
714 SkAutoMutexAcquire autoMutex(fDrawMutex); 715 SkAutoMutexAcquire autoMutex(fDrawMutex);
715 #endif 716 #endif
716 717
717 // kDrawComplete will be the signal that we have reached the end of 718 // kDrawComplete will be the signal that we have reached the end of
718 // the command stream 719 // the command stream
719 static const uint32_t kDrawComplete = SK_MaxU32; 720 static const uint32_t kDrawComplete = SK_MaxU32;
720 721
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 if (callback && callback->abortDrawing()) { 766 if (callback && callback->abortDrawing()) {
766 canvas.restoreToCount(originalSaveCount); 767 canvas.restoreToCount(originalSaveCount);
767 return; 768 return;
768 } 769 }
769 #ifdef SK_BUILD_FOR_ANDROID 770 #ifdef SK_BUILD_FOR_ANDROID
770 if (fAbortCurrentPlayback) { 771 if (fAbortCurrentPlayback) {
771 return; 772 return;
772 } 773 }
773 #endif 774 #endif
774 775
776 #ifdef SPEW_CLIP_SKIPPING
777 opCount++;
778 #endif
779
775 size_t curOffset = reader.offset(); 780 size_t curOffset = reader.offset();
776 uint32_t size; 781 uint32_t size;
777 DrawType op = read_op_and_size(&reader, &size); 782 DrawType op = read_op_and_size(&reader, &size);
778 size_t skipTo = 0; 783 size_t skipTo = 0;
779 if (NOOP == op) { 784 if (NOOP == op) {
780 // NOOPs are to be ignored - do not propagate them any further 785 // NOOPs are to be ignored - do not propagate them any further
781 skipTo = curOffset + size; 786 skipTo = curOffset + size;
782 #ifdef SK_DEVELOPER 787 #ifdef SK_DEVELOPER
783 } else { 788 } else {
784 opIndex++; 789 opIndex++;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 size_t offsetToRestore = reader.readInt(); 865 size_t offsetToRestore = reader.readInt();
861 SkASSERT(!offsetToRestore || \ 866 SkASSERT(!offsetToRestore || \
862 offsetToRestore >= reader.offset()); 867 offsetToRestore >= reader.offset());
863 if (!canvas.clipRRect(rrect, regionOp, doAA) && offsetToRestore) { 868 if (!canvas.clipRRect(rrect, regionOp, doAA) && offsetToRestore) {
864 #ifdef SPEW_CLIP_SKIPPING 869 #ifdef SPEW_CLIP_SKIPPING
865 skipRRect.recordSkip(offsetToRestore - reader.offset()); 870 skipRRect.recordSkip(offsetToRestore - reader.offset());
866 #endif 871 #endif
867 reader.setOffset(offsetToRestore); 872 reader.setOffset(offsetToRestore);
868 } 873 }
869 } break; 874 } break;
875 case PUSH_CULL: {
876 const SkRect& cullRect = reader.skipT<SkRect>();
877 size_t offsetToRestore = reader.readInt();
878 if (offsetToRestore && canvas.quickReject(cullRect)) {
879 #ifdef SPEW_CLIP_SKIPPING
880 skipCull.recordSkip(offsetToRestore - reader.offset());
881 #endif
882 reader.setOffset(offsetToRestore);
883 } else {
884 canvas.pushCull(cullRect);
885 }
886 } break;
887 case POP_CULL:
888 canvas.popCull();
889 break;
870 case CONCAT: { 890 case CONCAT: {
871 SkMatrix matrix; 891 SkMatrix matrix;
872 this->getMatrix(reader, &matrix); 892 this->getMatrix(reader, &matrix);
873 canvas.concat(matrix); 893 canvas.concat(matrix);
874 break; 894 break;
875 } 895 }
876 case DRAW_BITMAP: { 896 case DRAW_BITMAP: {
877 const SkPaint* paint = getPaint(reader); 897 const SkPaint* paint = getPaint(reader);
878 const SkBitmap& bitmap = getBitmap(reader); 898 const SkBitmap& bitmap = getBitmap(reader);
879 const SkPoint& loc = reader.skipT<SkPoint>(); 899 const SkPoint& loc = reader.skipT<SkPoint>();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 uint32_t skipTo = it.draw(); 1137 uint32_t skipTo = it.draw();
1118 if (kDrawComplete == skipTo) { 1138 if (kDrawComplete == skipTo) {
1119 break; 1139 break;
1120 } 1140 }
1121 reader.setOffset(skipTo); 1141 reader.setOffset(skipTo);
1122 } 1142 }
1123 } 1143 }
1124 1144
1125 #ifdef SPEW_CLIP_SKIPPING 1145 #ifdef SPEW_CLIP_SKIPPING
1126 { 1146 {
1127 size_t size = skipRect.fSize + skipRRect.fSize + skipPath.fSize + skipR egion.fSize; 1147 size_t size = skipRect.fSize + skipRRect.fSize + skipPath.fSize + skipR egion.fSize +
1128 SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d\n", 1148 skipCull.fSize;
1149 SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d cull:%d\n" ,
1129 size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount, 1150 size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount,
1130 skipPath.fCount, skipRegion.fCount); 1151 skipPath.fCount, skipRegion.fCount, skipCull.fCount);
1152 SkDebugf("--- Total ops: %d\n", opCount);
1131 } 1153 }
1132 #endif 1154 #endif
1133 // this->dumpSize(); 1155 // this->dumpSize();
1134 } 1156 }
1135 1157
1136 /////////////////////////////////////////////////////////////////////////////// 1158 ///////////////////////////////////////////////////////////////////////////////
1137 1159
1138 #ifdef SK_DEBUG_SIZE 1160 #ifdef SK_DEBUG_SIZE
1139 int SkPicturePlayback::size(size_t* sizePtr) { 1161 int SkPicturePlayback::size(size_t* sizePtr) {
1140 int objects = bitmaps(sizePtr); 1162 int objects = bitmaps(sizePtr);
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 for (index = 0; index < fPictureCount; index++) 1659 for (index = 0; index < fPictureCount; index++)
1638 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1660 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1639 "picture%p, ", fPictureRefs[index]); 1661 "picture%p, ", fPictureRefs[index]);
1640 if (fPictureCount > 0) 1662 if (fPictureCount > 0)
1641 SkDebugf("%s0};\n", pBuffer); 1663 SkDebugf("%s0};\n", pBuffer);
1642 1664
1643 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1665 const_cast<SkPicturePlayback*>(this)->dumpStream();
1644 } 1666 }
1645 1667
1646 #endif 1668 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureFlat.h ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698