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

Side by Side Diff: include/core/SkCanvas.h

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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkCanvas_DEFINED 8 #ifndef SkCanvas_DEFINED
9 #define SkCanvas_DEFINED 9 #define SkCanvas_DEFINED
10 10
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 virtual void beginCommentGroup(const char* description) { 884 virtual void beginCommentGroup(const char* description) {
885 // do nothing. Subclasses may do something 885 // do nothing. Subclasses may do something
886 } 886 }
887 virtual void addComment(const char* kywd, const char* value) { 887 virtual void addComment(const char* kywd, const char* value) {
888 // do nothing. Subclasses may do something 888 // do nothing. Subclasses may do something
889 } 889 }
890 virtual void endCommentGroup() { 890 virtual void endCommentGroup() {
891 // do nothing. Subclasses may do something 891 // do nothing. Subclasses may do something
892 } 892 }
893 893
894 /**
895 * This call asserts that subsequent draw operations (up to the matching po pCull() call)
896 * are fully contained within the given bounding box. The assertion is not enforced,
897 * but the information might be used to quick-reject command blocks, so an incorrect
898 * bounding box may result in incomplete rendering.
899 */
900 void pushCull(const SkRect& cullRect) {
901 fCullCount += 1;
902 this->onPushCull(cullRect);
903 }
894 904
905 /**
906 * Terminates the current culling block, and restores the previous one (if any).
907 */
908 void popCull() {
909 SkASSERT(fCullCount > 0);
910 if (fCullCount > 0) {
caryclark 2014/02/14 14:54:35 since you have the assert, do you also need the te
f(malita) 2014/02/20 02:37:26 We guard against underflow for restore(), so I fig
911 fCullCount -= 1;
912 this->onPopCull();
913 }
914 }
reed1 2014/02/14 14:39:06 I wonder if we'll want similar helpers to what sav
895 ////////////////////////////////////////////////////////////////////////// 915 //////////////////////////////////////////////////////////////////////////
896 916
897 /** Get the current bounder object. 917 /** Get the current bounder object.
898 The bounder's reference count is unchaged. 918 The bounder's reference count is unchaged.
899 @return the canva's bounder (or NULL). 919 @return the canva's bounder (or NULL).
900 */ 920 */
901 SkBounder* getBounder() const { return fBounder; } 921 SkBounder* getBounder() const { return fBounder; }
902 922
903 /** Set a new bounder (or NULL). 923 /** Set a new bounder (or NULL).
904 Pass NULL to clear any previous bounder. 924 Pass NULL to clear any previous bounder.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 DEPRECATED -- need to remove when subclass stop relying on it. 1066 DEPRECATED -- need to remove when subclass stop relying on it.
1047 Marked as 'protected' to avoid new clients using this before we can 1067 Marked as 'protected' to avoid new clients using this before we can
1048 completely remove it. 1068 completely remove it.
1049 1069
1050 Specify a device for this canvas to draw into. If it is not null, its 1070 Specify a device for this canvas to draw into. If it is not null, its
1051 reference count is incremented. If the canvas was already holding a 1071 reference count is incremented. If the canvas was already holding a
1052 device, its reference count is decremented. The new device is returned. 1072 device, its reference count is decremented. The new device is returned.
1053 */ 1073 */
1054 virtual SkBaseDevice* setDevice(SkBaseDevice* device); 1074 virtual SkBaseDevice* setDevice(SkBaseDevice* device);
1055 1075
1076 virtual void onPushCull(const SkRect& cullRect);
1077 virtual void onPopCull();
1078
1056 private: 1079 private:
1057 class MCRec; 1080 class MCRec;
1058 1081
1059 SkClipStack fClipStack; 1082 SkClipStack fClipStack;
1060 SkDeque fMCStack; 1083 SkDeque fMCStack;
1061 // points to top of stack 1084 // points to top of stack
1062 MCRec* fMCRec; 1085 MCRec* fMCRec;
1063 // the first N recs that can fit here mean we won't call malloc 1086 // the first N recs that can fit here mean we won't call malloc
1064 uint32_t fMCRecStorage[32]; 1087 uint32_t fMCRecStorage[32];
1065 1088
1066 SkBounder* fBounder; 1089 SkBounder* fBounder;
1067 int fSaveLayerCount; // number of successful saveLayer calls 1090 int fSaveLayerCount; // number of successful saveLayer calls
1091 unsigned fCullCount; // number of active culls
reed1 2014/02/14 14:39:06 nit: int so we can notice negatives easier, and to
f(malita) 2014/02/20 02:37:26 Will do.
1068 1092
1069 SkMetaData* fMetaData; 1093 SkMetaData* fMetaData;
1070 1094
1071 SkSurface_Base* fSurfaceBase; 1095 SkSurface_Base* fSurfaceBase;
1072 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; } 1096 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; }
1073 void setSurfaceBase(SkSurface_Base* sb) { 1097 void setSurfaceBase(SkSurface_Base* sb) {
1074 fSurfaceBase = sb; 1098 fSurfaceBase = sb;
1075 } 1099 }
1076 friend class SkSurface_Base; 1100 friend class SkSurface_Base;
1077 friend class SkSurface_Gpu; 1101 friend class SkSurface_Gpu;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 fCanvas->endCommentGroup(); 1224 fCanvas->endCommentGroup();
1201 } 1225 }
1202 } 1226 }
1203 1227
1204 private: 1228 private:
1205 SkCanvas* fCanvas; 1229 SkCanvas* fCanvas;
1206 }; 1230 };
1207 #define SkAutoCommentBlock(...) SK_REQUIRE_LOCAL_VAR(SkAutoCommentBlock) 1231 #define SkAutoCommentBlock(...) SK_REQUIRE_LOCAL_VAR(SkAutoCommentBlock)
1208 1232
1209 #endif 1233 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698