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

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

Issue 138013009: Culling API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Comments, formatting. 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
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 unsigned opCount = 0;
caryclark 2014/02/14 14:54:35 nit : this is fine, but seeing unsigned instead of
f(malita) 2014/02/20 02:37:26 Will update.
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 skipOffset = reader.readInt();
878 // FIXME: use inlineable quickRejectNoCheck()
caryclark 2014/02/14 14:54:35 is there a bug associated with this FIXME?
f(malita) 2014/02/20 02:37:26 Not yet. I recall that at some point quickReject()
879 if (skipOffset && canvas.quickReject(cullRect)) {
880 #ifdef SPEW_CLIP_SKIPPING
881 skipCull.recordSkip(skipOffset - reader.offset());
882 #endif
883 reader.setOffset(skipOffset);
884 } else {
885 canvas.pushCull(cullRect);
886 }
887 } break;
888 case POP_CULL:
889 canvas.popCull();
890 break;
870 case CONCAT: { 891 case CONCAT: {
871 SkMatrix matrix; 892 SkMatrix matrix;
872 this->getMatrix(reader, &matrix); 893 this->getMatrix(reader, &matrix);
873 canvas.concat(matrix); 894 canvas.concat(matrix);
874 break; 895 break;
875 } 896 }
876 case DRAW_BITMAP: { 897 case DRAW_BITMAP: {
877 const SkPaint* paint = getPaint(reader); 898 const SkPaint* paint = getPaint(reader);
878 const SkBitmap& bitmap = getBitmap(reader); 899 const SkBitmap& bitmap = getBitmap(reader);
879 const SkPoint& loc = reader.skipT<SkPoint>(); 900 const SkPoint& loc = reader.skipT<SkPoint>();
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 uint32_t skipTo = it.draw(); 1131 uint32_t skipTo = it.draw();
1111 if (kDrawComplete == skipTo) { 1132 if (kDrawComplete == skipTo) {
1112 break; 1133 break;
1113 } 1134 }
1114 reader.setOffset(skipTo); 1135 reader.setOffset(skipTo);
1115 } 1136 }
1116 } 1137 }
1117 1138
1118 #ifdef SPEW_CLIP_SKIPPING 1139 #ifdef SPEW_CLIP_SKIPPING
1119 { 1140 {
1120 size_t size = skipRect.fSize + skipRRect.fSize + skipPath.fSize + skipR egion.fSize; 1141 size_t size = skipRect.fSize + skipRRect.fSize + skipPath.fSize + skipR egion.fSize +
1121 SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d\n", 1142 skipCull.fSize;
1143 SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d cull:%d\n" ,
1122 size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount, 1144 size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount,
1123 skipPath.fCount, skipRegion.fCount); 1145 skipPath.fCount, skipRegion.fCount, skipCull.fCount);
1146 SkDebugf("--- Draw ops: %u\n", opCount);
1124 } 1147 }
1125 #endif 1148 #endif
1126 // this->dumpSize(); 1149 // this->dumpSize();
1127 } 1150 }
1128 1151
1129 /////////////////////////////////////////////////////////////////////////////// 1152 ///////////////////////////////////////////////////////////////////////////////
1130 1153
1131 #ifdef SK_DEBUG_SIZE 1154 #ifdef SK_DEBUG_SIZE
1132 int SkPicturePlayback::size(size_t* sizePtr) { 1155 int SkPicturePlayback::size(size_t* sizePtr) {
1133 int objects = bitmaps(sizePtr); 1156 int objects = bitmaps(sizePtr);
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 for (index = 0; index < fPictureCount; index++) 1653 for (index = 0; index < fPictureCount; index++)
1631 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1654 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1632 "picture%p, ", fPictureRefs[index]); 1655 "picture%p, ", fPictureRefs[index]);
1633 if (fPictureCount > 0) 1656 if (fPictureCount > 0)
1634 SkDebugf("%s0};\n", pBuffer); 1657 SkDebugf("%s0};\n", pBuffer);
1635 1658
1636 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1659 const_cast<SkPicturePlayback*>(this)->dumpStream();
1637 } 1660 }
1638 1661
1639 #endif 1662 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698