| OLD | NEW |
| 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 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 virtual void beginCommentGroup(const char* /*description*/) { | 1048 virtual void beginCommentGroup(const char* /*description*/) { |
| 1049 // do nothing. Subclasses may do something | 1049 // do nothing. Subclasses may do something |
| 1050 } | 1050 } |
| 1051 virtual void addComment(const char* /*kywd*/, const char* /*value*/) { | 1051 virtual void addComment(const char* /*kywd*/, const char* /*value*/) { |
| 1052 // do nothing. Subclasses may do something | 1052 // do nothing. Subclasses may do something |
| 1053 } | 1053 } |
| 1054 virtual void endCommentGroup() { | 1054 virtual void endCommentGroup() { |
| 1055 // do nothing. Subclasses may do something | 1055 // do nothing. Subclasses may do something |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 /** | |
| 1059 * With this call the client asserts that subsequent draw operations (up to
the | |
| 1060 * matching popCull()) are fully contained within the given bounding box. T
he assertion | |
| 1061 * is not enforced, but the information might be used to quick-reject comma
nd blocks, | |
| 1062 * so an incorrect bounding box may result in incomplete rendering. | |
| 1063 */ | |
| 1064 void pushCull(const SkRect& cullRect); | |
| 1065 | |
| 1066 /** | |
| 1067 * Terminates the current culling block, and restores the previous one (if
any). | |
| 1068 */ | |
| 1069 void popCull(); | |
| 1070 | |
| 1071 ////////////////////////////////////////////////////////////////////////// | 1058 ////////////////////////////////////////////////////////////////////////// |
| 1072 | 1059 |
| 1073 /** Get the current filter object. The filter's reference count is not | 1060 /** Get the current filter object. The filter's reference count is not |
| 1074 affected. The filter is saved/restored, just like the matrix and clip. | 1061 affected. The filter is saved/restored, just like the matrix and clip. |
| 1075 @return the canvas' filter (or NULL). | 1062 @return the canvas' filter (or NULL). |
| 1076 */ | 1063 */ |
| 1077 SkDrawFilter* getDrawFilter() const; | 1064 SkDrawFilter* getDrawFilter() const; |
| 1078 | 1065 |
| 1079 /** Set the new filter (or NULL). Pass NULL to clear any existing filter. | 1066 /** Set the new filter (or NULL). Pass NULL to clear any existing filter. |
| 1080 As a convenience, the parameter is returned. If an existing filter | 1067 As a convenience, the parameter is returned. If an existing filter |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 // If non-NULL, The imageFilter parameter will be used to expand the clip | 1230 // If non-NULL, The imageFilter parameter will be used to expand the clip |
| 1244 // and offscreen bounds for any margin required by the filter DAG. | 1231 // and offscreen bounds for any margin required by the filter DAG. |
| 1245 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, | 1232 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, |
| 1246 SkIRect* intersection, | 1233 SkIRect* intersection, |
| 1247 const SkImageFilter* imageFilter = NULL); | 1234 const SkImageFilter* imageFilter = NULL); |
| 1248 | 1235 |
| 1249 // notify our surface (if we have one) that we are about to draw, so it | 1236 // notify our surface (if we have one) that we are about to draw, so it |
| 1250 // can perform copy-on-write or invalidate any cached images | 1237 // can perform copy-on-write or invalidate any cached images |
| 1251 void predrawNotify(); | 1238 void predrawNotify(); |
| 1252 | 1239 |
| 1253 virtual void onPushCull(const SkRect& cullRect); | |
| 1254 virtual void onPopCull(); | |
| 1255 | |
| 1256 private: | 1240 private: |
| 1257 class MCRec; | 1241 class MCRec; |
| 1258 | 1242 |
| 1259 SkClipStack fClipStack; | 1243 SkClipStack fClipStack; |
| 1260 SkDeque fMCStack; | 1244 SkDeque fMCStack; |
| 1261 // points to top of stack | 1245 // points to top of stack |
| 1262 MCRec* fMCRec; | 1246 MCRec* fMCRec; |
| 1263 // the first N recs that can fit here mean we won't call malloc | 1247 // the first N recs that can fit here mean we won't call malloc |
| 1264 uint32_t fMCRecStorage[32]; | 1248 uint32_t fMCRecStorage[32]; |
| 1265 | 1249 |
| 1266 const SkSurfaceProps fProps; | 1250 const SkSurfaceProps fProps; |
| 1267 | 1251 |
| 1268 int fSaveCount; // value returned by getSaveCount() | 1252 int fSaveCount; // value returned by getSaveCount() |
| 1269 int fSaveLayerCount; // number of successful saveLayer calls | 1253 int fSaveLayerCount; // number of successful saveLayer calls |
| 1270 int fCullCount; // number of active culls | |
| 1271 | 1254 |
| 1272 SkMetaData* fMetaData; | 1255 SkMetaData* fMetaData; |
| 1273 | 1256 |
| 1274 SkSurface_Base* fSurfaceBase; | 1257 SkSurface_Base* fSurfaceBase; |
| 1275 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; } | 1258 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; } |
| 1276 void setSurfaceBase(SkSurface_Base* sb) { | 1259 void setSurfaceBase(SkSurface_Base* sb) { |
| 1277 fSurfaceBase = sb; | 1260 fSurfaceBase = sb; |
| 1278 } | 1261 } |
| 1279 friend class SkSurface_Base; | 1262 friend class SkSurface_Base; |
| 1280 friend class SkSurface_Gpu; | 1263 friend class SkSurface_Gpu; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 explicit AutoValidateClip(SkCanvas* canvas) : fCanvas(canvas) { | 1361 explicit AutoValidateClip(SkCanvas* canvas) : fCanvas(canvas) { |
| 1379 fCanvas->validateClip(); | 1362 fCanvas->validateClip(); |
| 1380 } | 1363 } |
| 1381 ~AutoValidateClip() { fCanvas->validateClip(); } | 1364 ~AutoValidateClip() { fCanvas->validateClip(); } |
| 1382 | 1365 |
| 1383 private: | 1366 private: |
| 1384 const SkCanvas* fCanvas; | 1367 const SkCanvas* fCanvas; |
| 1385 }; | 1368 }; |
| 1386 | 1369 |
| 1387 #ifdef SK_DEBUG | 1370 #ifdef SK_DEBUG |
| 1388 // The cull stack rects are in device-space | |
| 1389 SkTDArray<SkIRect> fCullStack; | |
| 1390 void validateCull(const SkIRect&); | |
| 1391 void validateClip() const; | 1371 void validateClip() const; |
| 1392 #else | 1372 #else |
| 1393 void validateClip() const {} | 1373 void validateClip() const {} |
| 1394 #endif | 1374 #endif |
| 1395 | 1375 |
| 1396 typedef SkRefCnt INHERITED; | 1376 typedef SkRefCnt INHERITED; |
| 1397 }; | 1377 }; |
| 1398 | 1378 |
| 1399 /** Stack helper class to automatically call restoreToCount() on the canvas | 1379 /** Stack helper class to automatically call restoreToCount() on the canvas |
| 1400 when this object goes out of scope. Use this to guarantee that the canvas | 1380 when this object goes out of scope. Use this to guarantee that the canvas |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 | 1491 |
| 1512 class SkCanvasClipVisitor { | 1492 class SkCanvasClipVisitor { |
| 1513 public: | 1493 public: |
| 1514 virtual ~SkCanvasClipVisitor(); | 1494 virtual ~SkCanvasClipVisitor(); |
| 1515 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1495 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
| 1516 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1496 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
| 1517 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1497 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
| 1518 }; | 1498 }; |
| 1519 | 1499 |
| 1520 #endif | 1500 #endif |
| OLD | NEW |