| 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 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1318 |
| 1319 protected: | 1319 protected: |
| 1320 #ifdef SK_EXPERIMENTAL_SHADOWING | 1320 #ifdef SK_EXPERIMENTAL_SHADOWING |
| 1321 /** Returns the current (cumulative) draw depth of the canvas. | 1321 /** Returns the current (cumulative) draw depth of the canvas. |
| 1322 */ | 1322 */ |
| 1323 SkScalar getZ() const; | 1323 SkScalar getZ() const; |
| 1324 | 1324 |
| 1325 sk_sp<SkLights> fLights; | 1325 sk_sp<SkLights> fLights; |
| 1326 #endif | 1326 #endif |
| 1327 | 1327 |
| 1328 /** After calling saveLayer(), there can be any number of devices that make | |
| 1329 up the top-most drawing area. LayerIter can be used to iterate through | |
| 1330 those devices. Note that the iterator is only valid until the next API | |
| 1331 call made on the canvas. Ownership of all pointers in the iterator stays | |
| 1332 with the canvas, so none of them should be modified or deleted. | |
| 1333 */ | |
| 1334 class LayerIter /*: SkNoncopyable*/ { | |
| 1335 public: | |
| 1336 /** Initialize iterator with canvas, and set values for 1st device */ | |
| 1337 LayerIter(SkCanvas*, bool skipEmptyClips); | |
| 1338 ~LayerIter(); | |
| 1339 | |
| 1340 /** Return true if the iterator is done */ | |
| 1341 bool done() const { return fDone; } | |
| 1342 /** Cycle to the next device */ | |
| 1343 void next(); | |
| 1344 | |
| 1345 // These reflect the current device in the iterator | |
| 1346 | |
| 1347 SkBaseDevice* device() const; | |
| 1348 const SkMatrix& matrix() const; | |
| 1349 const SkRasterClip& clip() const; | |
| 1350 const SkPaint& paint() const; | |
| 1351 int x() const; | |
| 1352 int y() const; | |
| 1353 | |
| 1354 private: | |
| 1355 // used to embed the SkDrawIter object directly in our instance, w/o | |
| 1356 // having to expose that class def to the public. There is an assert | |
| 1357 // in our constructor to ensure that fStorage is large enough | |
| 1358 // (though needs to be a compile-time-assert!). We use intptr_t to work | |
| 1359 // safely with 32 and 64 bit machines (to ensure the storage is enough) | |
| 1360 intptr_t fStorage[32]; | |
| 1361 class SkDrawIter* fImpl; // this points at fStorage | |
| 1362 SkPaint fDefaultPaint; | |
| 1363 bool fDone; | |
| 1364 }; | |
| 1365 | |
| 1366 // default impl defers to getDevice()->newSurface(info) | 1328 // default impl defers to getDevice()->newSurface(info) |
| 1367 virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfacePro
ps&); | 1329 virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfacePro
ps&); |
| 1368 | 1330 |
| 1369 // default impl defers to its device | 1331 // default impl defers to its device |
| 1370 virtual bool onPeekPixels(SkPixmap*); | 1332 virtual bool onPeekPixels(SkPixmap*); |
| 1371 virtual bool onAccessTopLayerPixels(SkPixmap*); | 1333 virtual bool onAccessTopLayerPixels(SkPixmap*); |
| 1372 virtual SkImageInfo onImageInfo() const; | 1334 virtual SkImageInfo onImageInfo() const; |
| 1373 virtual bool onGetProps(SkSurfaceProps*) const; | 1335 virtual bool onGetProps(SkSurfaceProps*) const; |
| 1374 virtual void onFlush(); | 1336 virtual void onFlush(); |
| 1375 | 1337 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 virtual SkCanvas* canvasForDrawIter(); | 1439 virtual SkCanvas* canvasForDrawIter(); |
| 1478 | 1440 |
| 1479 // Clip rectangle bounds. Called internally by saveLayer. | 1441 // Clip rectangle bounds. Called internally by saveLayer. |
| 1480 // returns false if the entire rectangle is entirely clipped out | 1442 // returns false if the entire rectangle is entirely clipped out |
| 1481 // If non-NULL, The imageFilter parameter will be used to expand the clip | 1443 // If non-NULL, The imageFilter parameter will be used to expand the clip |
| 1482 // and offscreen bounds for any margin required by the filter DAG. | 1444 // and offscreen bounds for any margin required by the filter DAG. |
| 1483 bool clipRectBounds(const SkRect* bounds, SaveLayerFlags, SkIRect* intersect
ion, | 1445 bool clipRectBounds(const SkRect* bounds, SaveLayerFlags, SkIRect* intersect
ion, |
| 1484 const SkImageFilter* imageFilter = NULL); | 1446 const SkImageFilter* imageFilter = NULL); |
| 1485 | 1447 |
| 1486 private: | 1448 private: |
| 1449 /** After calling saveLayer(), there can be any number of devices that make |
| 1450 up the top-most drawing area. LayerIter can be used to iterate through |
| 1451 those devices. Note that the iterator is only valid until the next API |
| 1452 call made on the canvas. Ownership of all pointers in the iterator stays |
| 1453 with the canvas, so none of them should be modified or deleted. |
| 1454 */ |
| 1455 class LayerIter /*: SkNoncopyable*/ { |
| 1456 public: |
| 1457 /** Initialize iterator with canvas, and set values for 1st device */ |
| 1458 LayerIter(SkCanvas*); |
| 1459 ~LayerIter(); |
| 1460 |
| 1461 /** Return true if the iterator is done */ |
| 1462 bool done() const { return fDone; } |
| 1463 /** Cycle to the next device */ |
| 1464 void next(); |
| 1465 |
| 1466 // These reflect the current device in the iterator |
| 1467 |
| 1468 SkBaseDevice* device() const; |
| 1469 const SkMatrix& matrix() const; |
| 1470 const SkRasterClip& clip() const; |
| 1471 const SkPaint& paint() const; |
| 1472 int x() const; |
| 1473 int y() const; |
| 1474 |
| 1475 private: |
| 1476 // used to embed the SkDrawIter object directly in our instance, w/o |
| 1477 // having to expose that class def to the public. There is an assert |
| 1478 // in our constructor to ensure that fStorage is large enough |
| 1479 // (though needs to be a compile-time-assert!). We use intptr_t to work |
| 1480 // safely with 32 and 64 bit machines (to ensure the storage is enough) |
| 1481 intptr_t fStorage[32]; |
| 1482 class SkDrawIter* fImpl; // this points at fStorage |
| 1483 SkPaint fDefaultPaint; |
| 1484 bool fDone; |
| 1485 }; |
| 1486 |
| 1487 static bool BoundsAffectsClip(SaveLayerFlags); | 1487 static bool BoundsAffectsClip(SaveLayerFlags); |
| 1488 static SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFla
gs); | 1488 static SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFla
gs); |
| 1489 | 1489 |
| 1490 static void DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* fil
ter, | 1490 static void DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* fil
ter, |
| 1491 SkBaseDevice* dst, const SkMatrix& ctm, | 1491 SkBaseDevice* dst, const SkMatrix& ctm, |
| 1492 const SkClipStack* clipStack); | 1492 const SkClipStack* clipStack); |
| 1493 | 1493 |
| 1494 enum ShaderOverrideOpacity { | 1494 enum ShaderOverrideOpacity { |
| 1495 kNone_ShaderOverrideOpacity, //!< there is no overriding shader (
bitmap or image) | 1495 kNone_ShaderOverrideOpacity, //!< there is no overriding shader (
bitmap or image) |
| 1496 kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque | 1496 kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 friend class SkSurface_Base; | 1535 friend class SkSurface_Base; |
| 1536 friend class SkSurface_Gpu; | 1536 friend class SkSurface_Gpu; |
| 1537 | 1537 |
| 1538 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() | 1538 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() |
| 1539 void updateDeviceCMCache(); | 1539 void updateDeviceCMCache(); |
| 1540 | 1540 |
| 1541 void doSave(); | 1541 void doSave(); |
| 1542 void checkForDeferredSave(); | 1542 void checkForDeferredSave(); |
| 1543 void internalSetMatrix(const SkMatrix&); | 1543 void internalSetMatrix(const SkMatrix&); |
| 1544 | 1544 |
| 1545 friend class CanvasTestingAccess; // for testing | |
| 1546 friend class SkDrawIter; // needs setupDrawForLayerDevice() | 1545 friend class SkDrawIter; // needs setupDrawForLayerDevice() |
| 1547 friend class AutoDrawLooper; | 1546 friend class AutoDrawLooper; |
| 1548 friend class SkLua; // needs top layer size and offset | 1547 friend class SkLua; // needs top layer size and offset |
| 1549 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip | 1548 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip |
| 1550 friend class SkSurface_Raster; // needs getDevice() | 1549 friend class SkSurface_Raster; // needs getDevice() |
| 1551 friend class SkRecorder; // InitFlags | 1550 friend class SkRecorder; // InitFlags |
| 1552 friend class SkLiteRecorder; // InitFlags | 1551 friend class SkLiteRecorder; // InitFlags |
| 1553 friend class SkNoSaveLayerCanvas; // InitFlags | 1552 friend class SkNoSaveLayerCanvas; // InitFlags |
| 1554 friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProp
s*, InitFlags) | 1553 friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProp
s*, InitFlags) |
| 1555 friend class SkPictureRecord; // predrawNotify (why does it need it? <reed
>) | 1554 friend class SkPictureRecord; // predrawNotify (why does it need it? <reed
>) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 | 1681 |
| 1683 class SkCanvasClipVisitor { | 1682 class SkCanvasClipVisitor { |
| 1684 public: | 1683 public: |
| 1685 virtual ~SkCanvasClipVisitor(); | 1684 virtual ~SkCanvasClipVisitor(); |
| 1686 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1685 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
| 1687 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1686 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
| 1688 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1687 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
| 1689 }; | 1688 }; |
| 1690 | 1689 |
| 1691 #endif | 1690 #endif |
| OLD | NEW |