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 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 virtual SkCanvas* canvasForDrawIter(); | 1258 virtual SkCanvas* canvasForDrawIter(); |
1259 | 1259 |
1260 // Clip rectangle bounds. Called internally by saveLayer. | 1260 // Clip rectangle bounds. Called internally by saveLayer. |
1261 // returns false if the entire rectangle is entirely clipped out | 1261 // returns false if the entire rectangle is entirely clipped out |
1262 // If non-NULL, The imageFilter parameter will be used to expand the clip | 1262 // If non-NULL, The imageFilter parameter will be used to expand the clip |
1263 // and offscreen bounds for any margin required by the filter DAG. | 1263 // and offscreen bounds for any margin required by the filter DAG. |
1264 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, | 1264 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, |
1265 SkIRect* intersection, | 1265 SkIRect* intersection, |
1266 const SkImageFilter* imageFilter = NULL); | 1266 const SkImageFilter* imageFilter = NULL); |
1267 | 1267 |
| 1268 // Called by child classes that override clipPath and clipRRect to only |
| 1269 // track fast conservative clip bounds, rather than exact clips. |
| 1270 void updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, |
| 1271 bool inverseFilled); |
| 1272 |
1268 // notify our surface (if we have one) that we are about to draw, so it | 1273 // notify our surface (if we have one) that we are about to draw, so it |
1269 // can perform copy-on-write or invalidate any cached images | 1274 // can perform copy-on-write or invalidate any cached images |
1270 void predrawNotify(); | 1275 void predrawNotify(); |
1271 | 1276 |
1272 virtual void onPushCull(const SkRect& cullRect); | 1277 virtual void onPushCull(const SkRect& cullRect); |
1273 virtual void onPopCull(); | 1278 virtual void onPopCull(); |
1274 | 1279 |
1275 private: | 1280 private: |
1276 class MCRec; | 1281 class MCRec; |
1277 | 1282 |
(...skipping 19 matching lines...) Expand all Loading... |
1297 | 1302 |
1298 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() | 1303 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() |
1299 void updateDeviceCMCache(); | 1304 void updateDeviceCMCache(); |
1300 | 1305 |
1301 friend class SkDrawIter; // needs setupDrawForLayerDevice() | 1306 friend class SkDrawIter; // needs setupDrawForLayerDevice() |
1302 friend class AutoDrawLooper; | 1307 friend class AutoDrawLooper; |
1303 friend class SkLua; // needs top layer size and offset | 1308 friend class SkLua; // needs top layer size and offset |
1304 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip | 1309 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip |
1305 friend class SkDeferredDevice; // needs getTopDevice() | 1310 friend class SkDeferredDevice; // needs getTopDevice() |
1306 friend class SkSurface_Raster; // needs getDevice() | 1311 friend class SkSurface_Raster; // needs getDevice() |
1307 friend class SkRecorder; // InitFlags | |
1308 friend class SkNoSaveLayerCanvas; // InitFlags | |
1309 | 1312 |
1310 enum InitFlags { | |
1311 kDefault_InitFlags = 0, | |
1312 kConservativeRasterClip_InitFlag = 1 << 0, | |
1313 }; | |
1314 SkCanvas(int width, int height, InitFlags flags); | |
1315 SkCanvas(SkBaseDevice*, InitFlags flags); | |
1316 | |
1317 // needs gettotalclip() | 1313 // needs gettotalclip() |
1318 friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*); | 1314 friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*); |
1319 | 1315 |
1320 SkBaseDevice* createLayerDevice(const SkImageInfo&); | 1316 SkBaseDevice* createLayerDevice(const SkImageInfo&); |
1321 | 1317 |
1322 SkBaseDevice* init(SkBaseDevice*, InitFlags); | 1318 SkBaseDevice* init(SkBaseDevice*); |
1323 | 1319 |
1324 /** | 1320 /** |
1325 * DEPRECATED | 1321 * DEPRECATED |
1326 * | 1322 * |
1327 * Specify a device for this canvas to draw into. If it is not null, its | 1323 * Specify a device for this canvas to draw into. If it is not null, its |
1328 * reference count is incremented. If the canvas was already holding a | 1324 * reference count is incremented. If the canvas was already holding a |
1329 * device, its reference count is decremented. The new device is returned. | 1325 * device, its reference count is decremented. The new device is returned. |
1330 */ | 1326 */ |
1331 SkBaseDevice* setRootDevice(SkBaseDevice* device); | 1327 SkBaseDevice* setRootDevice(SkBaseDevice* device); |
1332 | 1328 |
(...skipping 29 matching lines...) Expand all Loading... |
1362 // only for canvasutils | 1358 // only for canvasutils |
1363 const SkRegion& internal_private_getTotalClip() const; | 1359 const SkRegion& internal_private_getTotalClip() const; |
1364 | 1360 |
1365 /* These maintain a cache of the clip bounds in local coordinates, | 1361 /* These maintain a cache of the clip bounds in local coordinates, |
1366 (converted to 2s-compliment if floats are slow). | 1362 (converted to 2s-compliment if floats are slow). |
1367 */ | 1363 */ |
1368 mutable SkRect fCachedLocalClipBounds; | 1364 mutable SkRect fCachedLocalClipBounds; |
1369 mutable bool fCachedLocalClipBoundsDirty; | 1365 mutable bool fCachedLocalClipBoundsDirty; |
1370 bool fAllowSoftClip; | 1366 bool fAllowSoftClip; |
1371 bool fAllowSimplifyClip; | 1367 bool fAllowSimplifyClip; |
1372 bool fConservativeRasterClip; | |
1373 | 1368 |
1374 const SkRect& getLocalClipBounds() const { | 1369 const SkRect& getLocalClipBounds() const { |
1375 if (fCachedLocalClipBoundsDirty) { | 1370 if (fCachedLocalClipBoundsDirty) { |
1376 if (!this->getClipBounds(&fCachedLocalClipBounds)) { | 1371 if (!this->getClipBounds(&fCachedLocalClipBounds)) { |
1377 fCachedLocalClipBounds.setEmpty(); | 1372 fCachedLocalClipBounds.setEmpty(); |
1378 } | 1373 } |
1379 fCachedLocalClipBoundsDirty = false; | 1374 fCachedLocalClipBoundsDirty = false; |
1380 } | 1375 } |
1381 return fCachedLocalClipBounds; | 1376 return fCachedLocalClipBounds; |
1382 } | 1377 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 | 1514 |
1520 class SkCanvasClipVisitor { | 1515 class SkCanvasClipVisitor { |
1521 public: | 1516 public: |
1522 virtual ~SkCanvasClipVisitor(); | 1517 virtual ~SkCanvasClipVisitor(); |
1523 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1518 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1524 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1519 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1525 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1520 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1526 }; | 1521 }; |
1527 | 1522 |
1528 #endif | 1523 #endif |
OLD | NEW |