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 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 virtual SkCanvas* canvasForDrawIter(); | 1348 virtual SkCanvas* canvasForDrawIter(); |
1349 | 1349 |
1350 // Clip rectangle bounds. Called internally by saveLayer. | 1350 // Clip rectangle bounds. Called internally by saveLayer. |
1351 // returns false if the entire rectangle is entirely clipped out | 1351 // returns false if the entire rectangle is entirely clipped out |
1352 // If non-NULL, The imageFilter parameter will be used to expand the clip | 1352 // If non-NULL, The imageFilter parameter will be used to expand the clip |
1353 // and offscreen bounds for any margin required by the filter DAG. | 1353 // and offscreen bounds for any margin required by the filter DAG. |
1354 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, | 1354 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, |
1355 SkIRect* intersection, | 1355 SkIRect* intersection, |
1356 const SkImageFilter* imageFilter = NULL); | 1356 const SkImageFilter* imageFilter = NULL); |
1357 | 1357 |
1358 private: | |
1359 enum ShaderOverrideOpacity { | |
1360 kNone_ShaderOverrideOpacity, //!< there is no overriding shader ( bitmap or image) | |
1361 kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque | |
1362 kNotOpaque_ShaderOverrideOpacity, //!< the overriding shader may not b e opaque | |
1363 }; | |
1364 | |
1358 // notify our surface (if we have one) that we are about to draw, so it | 1365 // notify our surface (if we have one) that we are about to draw, so it |
1359 // can perform copy-on-write or invalidate any cached images | 1366 // can perform copy-on-write or invalidate any cached images |
robertphillips
2015/07/20 15:15:29
willOverwriteEntireSurface (no extra 's') ?
| |
1360 void predrawNotify(); | 1367 void predrawNotify(bool willOverwritesEntireSurface = false); |
1368 void predrawNotify(const SkRect* rect, const SkPaint* paint, ShaderOverrideO pacity); | |
1369 void predrawNotify(const SkRect* rect, const SkPaint* paint, bool shaderOver rideIsOpaque) { | |
1370 this->predrawNotify(rect, paint, shaderOverrideIsOpaque ? kOpaque_Shader OverrideOpacity | |
1371 : kNotOpaque_Sha derOverrideOpacity); | |
1372 } | |
1361 | 1373 |
1362 private: | |
1363 class MCRec; | 1374 class MCRec; |
1364 | 1375 |
1365 SkAutoTUnref<SkClipStack> fClipStack; | 1376 SkAutoTUnref<SkClipStack> fClipStack; |
1366 SkDeque fMCStack; | 1377 SkDeque fMCStack; |
1367 // points to top of stack | 1378 // points to top of stack |
1368 MCRec* fMCRec; | 1379 MCRec* fMCRec; |
1369 // the first N recs that can fit here mean we won't call malloc | 1380 // the first N recs that can fit here mean we won't call malloc |
1370 enum { | 1381 enum { |
1371 kMCRecSize = 128, // most recent measurement | 1382 kMCRecSize = 128, // most recent measurement |
1372 kMCRecCount = 8, // common depth for save/restores | 1383 kMCRecCount = 8, // common depth for save/restores |
(...skipping 24 matching lines...) Expand all Loading... | |
1397 | 1408 |
1398 friend class SkDrawIter; // needs setupDrawForLayerDevice() | 1409 friend class SkDrawIter; // needs setupDrawForLayerDevice() |
1399 friend class AutoDrawLooper; | 1410 friend class AutoDrawLooper; |
1400 friend class SkLua; // needs top layer size and offset | 1411 friend class SkLua; // needs top layer size and offset |
1401 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip | 1412 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip |
1402 friend class SkDeferredDevice; // needs getTopDevice() | 1413 friend class SkDeferredDevice; // needs getTopDevice() |
1403 friend class SkSurface_Raster; // needs getDevice() | 1414 friend class SkSurface_Raster; // needs getDevice() |
1404 friend class SkRecorder; // InitFlags | 1415 friend class SkRecorder; // InitFlags |
1405 friend class SkNoSaveLayerCanvas; // InitFlags | 1416 friend class SkNoSaveLayerCanvas; // InitFlags |
1406 friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProp s*, InitFlags) | 1417 friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProp s*, InitFlags) |
1418 friend class SkPictureRecord; // predrawNotify (why does it need it? <reed >) | |
1407 | 1419 |
1408 enum InitFlags { | 1420 enum InitFlags { |
1409 kDefault_InitFlags = 0, | 1421 kDefault_InitFlags = 0, |
1410 kConservativeRasterClip_InitFlag = 1 << 0, | 1422 kConservativeRasterClip_InitFlag = 1 << 0, |
1411 }; | 1423 }; |
1412 SkCanvas(const SkIRect& bounds, InitFlags); | 1424 SkCanvas(const SkIRect& bounds, InitFlags); |
1413 SkCanvas(SkBaseDevice* device, InitFlags); | 1425 SkCanvas(SkBaseDevice* device, InitFlags); |
1414 | 1426 |
1415 void resetForNextPicture(const SkIRect& bounds); | 1427 void resetForNextPicture(const SkIRect& bounds); |
1416 | 1428 |
(...skipping 29 matching lines...) Expand all Loading... | |
1446 void internalRestore(); | 1458 void internalRestore(); |
1447 static void DrawRect(const SkDraw& draw, const SkPaint& paint, | 1459 static void DrawRect(const SkDraw& draw, const SkPaint& paint, |
1448 const SkRect& r, SkScalar textSize); | 1460 const SkRect& r, SkScalar textSize); |
1449 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, | 1461 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, |
1450 const char text[], size_t byteLength, | 1462 const char text[], size_t byteLength, |
1451 SkScalar x, SkScalar y); | 1463 SkScalar x, SkScalar y); |
1452 | 1464 |
1453 // only for canvasutils | 1465 // only for canvasutils |
1454 const SkRegion& internal_private_getTotalClip() const; | 1466 const SkRegion& internal_private_getTotalClip() const; |
1455 | 1467 |
1468 /* | |
1469 * Returns true if drawing the specified rect (or all if it is null) with t he specified | |
1470 * paint (or default if null) would overwrite the entire root device of the canvas | |
1471 * (i.e. the canvas' surface if it had one). | |
1472 */ | |
1473 bool wouldOverwriteEntireSurface(const SkRect*, const SkPaint*, ShaderOverri deOpacity) const; | |
1474 | |
1475 | |
1456 /* These maintain a cache of the clip bounds in local coordinates, | 1476 /* These maintain a cache of the clip bounds in local coordinates, |
1457 (converted to 2s-compliment if floats are slow). | 1477 (converted to 2s-compliment if floats are slow). |
1458 */ | 1478 */ |
1459 mutable SkRect fCachedLocalClipBounds; | 1479 mutable SkRect fCachedLocalClipBounds; |
1460 mutable bool fCachedLocalClipBoundsDirty; | 1480 mutable bool fCachedLocalClipBoundsDirty; |
1461 bool fAllowSoftClip; | 1481 bool fAllowSoftClip; |
1462 bool fAllowSimplifyClip; | 1482 bool fAllowSimplifyClip; |
1463 bool fConservativeRasterClip; | 1483 bool fConservativeRasterClip; |
1464 | 1484 |
1465 const SkRect& getLocalClipBounds() const { | 1485 const SkRect& getLocalClipBounds() const { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1585 | 1605 |
1586 class SkCanvasClipVisitor { | 1606 class SkCanvasClipVisitor { |
1587 public: | 1607 public: |
1588 virtual ~SkCanvasClipVisitor(); | 1608 virtual ~SkCanvasClipVisitor(); |
1589 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1609 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1590 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1610 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1591 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1611 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1592 }; | 1612 }; |
1593 | 1613 |
1594 #endif | 1614 #endif |
OLD | NEW |