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 15 matching lines...) Expand all Loading... | |
26 class SkData; | 26 class SkData; |
27 class SkDraw; | 27 class SkDraw; |
28 class SkDrawable; | 28 class SkDrawable; |
29 class SkDrawFilter; | 29 class SkDrawFilter; |
30 class SkImageFilter; | 30 class SkImageFilter; |
31 class SkMetaData; | 31 class SkMetaData; |
32 class SkPath; | 32 class SkPath; |
33 class SkPicture; | 33 class SkPicture; |
34 class SkPixmap; | 34 class SkPixmap; |
35 class SkRasterClip; | 35 class SkRasterClip; |
36 class SkRasterCanvasLayerAllocator; | |
36 class SkRRect; | 37 class SkRRect; |
37 struct SkRSXform; | 38 struct SkRSXform; |
38 class SkSurface; | 39 class SkSurface; |
39 class SkSurface_Base; | 40 class SkSurface_Base; |
40 class SkTextBlob; | 41 class SkTextBlob; |
41 | 42 |
42 /** \class SkCanvas | 43 /** \class SkCanvas |
43 | 44 |
44 A Canvas encapsulates all of the state about drawing into a device (bitmap). | 45 A Canvas encapsulates all of the state about drawing into a device (bitmap). |
45 This includes a reference to the device itself, and a stack of matrix/clip | 46 This includes a reference to the device itself, and a stack of matrix/clip |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1212 } | 1213 } |
1213 | 1214 |
1214 typedef SkCanvasClipVisitor ClipVisitor; | 1215 typedef SkCanvasClipVisitor ClipVisitor; |
1215 /** | 1216 /** |
1216 * Replays the clip operations, back to front, that have been applied to | 1217 * Replays the clip operations, back to front, that have been applied to |
1217 * the canvas, calling the appropriate method on the visitor for each | 1218 * the canvas, calling the appropriate method on the visitor for each |
1218 * clip. All clips have already been transformed into device space. | 1219 * clip. All clips have already been transformed into device space. |
1219 */ | 1220 */ |
1220 void replayClips(ClipVisitor*) const; | 1221 void replayClips(ClipVisitor*) const; |
1221 | 1222 |
1223 /** | |
1224 * Returns any OS-specific native context backing this SkCanvas, | |
1225 * or nullptr. | |
1226 */ | |
1227 void* getTopLayerNative() const; | |
1228 | |
1222 /////////////////////////////////////////////////////////////////////////// | 1229 /////////////////////////////////////////////////////////////////////////// |
1223 | 1230 |
1224 // don't call | 1231 // don't call |
1225 GrDrawContext* internal_private_accessTopLayerDrawContext(); | 1232 GrDrawContext* internal_private_accessTopLayerDrawContext(); |
1226 | 1233 |
1227 // don't call | 1234 // don't call |
1228 static void Internal_Private_SetIgnoreSaveLayerBounds(bool); | 1235 static void Internal_Private_SetIgnoreSaveLayerBounds(bool); |
1229 static bool Internal_Private_GetIgnoreSaveLayerBounds(); | 1236 static bool Internal_Private_GetIgnoreSaveLayerBounds(); |
1230 static void Internal_Private_SetTreatSpriteAsBitmap(bool); | 1237 static void Internal_Private_SetTreatSpriteAsBitmap(bool); |
1231 static bool Internal_Private_GetTreatSpriteAsBitmap(); | 1238 static bool Internal_Private_GetTreatSpriteAsBitmap(); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1406 class MCRec; | 1413 class MCRec; |
1407 | 1414 |
1408 SkAutoTUnref<SkClipStack> fClipStack; | 1415 SkAutoTUnref<SkClipStack> fClipStack; |
1409 SkDeque fMCStack; | 1416 SkDeque fMCStack; |
1410 // points to top of stack | 1417 // points to top of stack |
1411 MCRec* fMCRec; | 1418 MCRec* fMCRec; |
1412 // the first N recs that can fit here mean we won't call malloc | 1419 // the first N recs that can fit here mean we won't call malloc |
1413 enum { | 1420 enum { |
1414 kMCRecSize = 128, // most recent measurement | 1421 kMCRecSize = 128, // most recent measurement |
1415 kMCRecCount = 32, // common depth for save/restores | 1422 kMCRecCount = 32, // common depth for save/restores |
1416 kDeviceCMSize = 176, // most recent measurement | 1423 kDeviceCMSize = 192, // most recent measurement |
1417 }; | 1424 }; |
1418 intptr_t fMCRecStorage[kMCRecSize * kMCRecCount / sizeof(intptr_t)]; | 1425 intptr_t fMCRecStorage[kMCRecSize * kMCRecCount / sizeof(intptr_t)]; |
1419 intptr_t fDeviceCMStorage[kDeviceCMSize / sizeof(intptr_t)]; | 1426 intptr_t fDeviceCMStorage[kDeviceCMSize / sizeof(intptr_t)]; |
1420 | 1427 |
1421 const SkSurfaceProps fProps; | 1428 const SkSurfaceProps fProps; |
1422 | 1429 |
1423 int fSaveCount; // value returned by getSaveCount() | 1430 int fSaveCount; // value returned by getSaveCount() |
1424 | 1431 |
1425 SkMetaData* fMetaData; | 1432 SkMetaData* fMetaData; |
1426 | 1433 |
(...skipping 16 matching lines...) Expand all Loading... | |
1443 friend class SkDrawIter; // needs setupDrawForLayerDevice() | 1450 friend class SkDrawIter; // needs setupDrawForLayerDevice() |
1444 friend class AutoDrawLooper; | 1451 friend class AutoDrawLooper; |
1445 friend class SkLua; // needs top layer size and offset | 1452 friend class SkLua; // needs top layer size and offset |
1446 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip | 1453 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip |
1447 friend class SkSurface_Raster; // needs getDevice() | 1454 friend class SkSurface_Raster; // needs getDevice() |
1448 friend class SkRecorder; // InitFlags | 1455 friend class SkRecorder; // InitFlags |
1449 friend class SkNoSaveLayerCanvas; // InitFlags | 1456 friend class SkNoSaveLayerCanvas; // InitFlags |
1450 friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProp s*, InitFlags) | 1457 friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProp s*, InitFlags) |
1451 friend class SkPictureRecord; // predrawNotify (why does it need it? <reed >) | 1458 friend class SkPictureRecord; // predrawNotify (why does it need it? <reed >) |
1452 friend class SkPicturePlayback; // SaveFlagsToSaveLayerFlags | 1459 friend class SkPicturePlayback; // SaveFlagsToSaveLayerFlags |
1460 friend class SkRasterCanvasLayerAllocator; | |
1453 | 1461 |
1454 enum InitFlags { | 1462 enum InitFlags { |
1455 kDefault_InitFlags = 0, | 1463 kDefault_InitFlags = 0, |
1456 kConservativeRasterClip_InitFlag = 1 << 0, | 1464 kConservativeRasterClip_InitFlag = 1 << 0, |
1457 }; | 1465 }; |
1458 SkCanvas(const SkIRect& bounds, InitFlags); | 1466 SkCanvas(const SkIRect& bounds, InitFlags); |
1459 SkCanvas(SkBaseDevice* device, InitFlags); | 1467 SkCanvas(SkBaseDevice* device, InitFlags); |
1468 SkCanvas(const SkBitmap& bitmap, sk_sp<SkRasterCanvasLayerAllocator>); | |
tomhudson
2016/05/26 16:36:17
Figuring out lifetime here is a little awkward - t
reed1
2016/07/12 19:52:39
I think unique_ptr as a parameter type is fine. No
| |
1460 | 1469 |
1461 void resetForNextPicture(const SkIRect& bounds); | 1470 void resetForNextPicture(const SkIRect& bounds); |
1462 | 1471 |
1463 // needs gettotalclip() | 1472 // needs gettotalclip() |
1464 friend class SkCanvasStateUtils; | 1473 friend class SkCanvasStateUtils; |
1465 | 1474 |
1466 // call this each time we attach ourselves to a device | 1475 // call this each time we attach ourselves to a device |
1467 // - constructor | 1476 // - constructor |
1468 // - internalSaveLayer | 1477 // - internalSaveLayer |
1469 void setupDevice(SkBaseDevice*); | 1478 void setupDevice(SkBaseDevice*); |
1470 | 1479 |
1471 SkBaseDevice* init(SkBaseDevice*, InitFlags); | 1480 SkBaseDevice* init(SkBaseDevice*, InitFlags, sk_sp<SkRasterCanvasLayerAlloca tor>); |
1472 | 1481 |
1473 /** | 1482 /** |
1474 * Gets the bounds of the top level layer in global canvas coordinates. We d on't want this | 1483 * Gets the bounds of the top level layer in global canvas coordinates. We d on't want this |
1475 * to be public because it exposes decisions about layer sizes that are inte rnal to the canvas. | 1484 * to be public because it exposes decisions about layer sizes that are inte rnal to the canvas. |
1476 */ | 1485 */ |
1477 SkIRect getTopLayerBounds() const; | 1486 SkIRect getTopLayerBounds() const; |
1478 | 1487 |
1479 void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, | 1488 void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
1480 const SkRect& dst, const SkPaint* paint, | 1489 const SkRect& dst, const SkPaint* paint, |
1481 SrcRectConstraint); | 1490 SrcRectConstraint); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1536 private: | 1545 private: |
1537 const SkCanvas* fCanvas; | 1546 const SkCanvas* fCanvas; |
1538 }; | 1547 }; |
1539 | 1548 |
1540 #ifdef SK_DEBUG | 1549 #ifdef SK_DEBUG |
1541 void validateClip() const; | 1550 void validateClip() const; |
1542 #else | 1551 #else |
1543 void validateClip() const {} | 1552 void validateClip() const {} |
1544 #endif | 1553 #endif |
1545 | 1554 |
1555 sk_sp<SkRasterCanvasLayerAllocator> fAllocator; | |
1556 | |
1546 typedef SkRefCnt INHERITED; | 1557 typedef SkRefCnt INHERITED; |
1547 }; | 1558 }; |
1548 | 1559 |
1549 /** Stack helper class to automatically call restoreToCount() on the canvas | 1560 /** Stack helper class to automatically call restoreToCount() on the canvas |
1550 when this object goes out of scope. Use this to guarantee that the canvas | 1561 when this object goes out of scope. Use this to guarantee that the canvas |
1551 is restored to a known state. | 1562 is restored to a known state. |
1552 */ | 1563 */ |
1553 class SkAutoCanvasRestore : SkNoncopyable { | 1564 class SkAutoCanvasRestore : SkNoncopyable { |
1554 public: | 1565 public: |
1555 SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveC ount(0) { | 1566 SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveC ount(0) { |
(...skipping 29 matching lines...) Expand all Loading... | |
1585 | 1596 |
1586 class SkCanvasClipVisitor { | 1597 class SkCanvasClipVisitor { |
1587 public: | 1598 public: |
1588 virtual ~SkCanvasClipVisitor(); | 1599 virtual ~SkCanvasClipVisitor(); |
1589 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1600 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1590 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1601 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1591 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1602 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1592 }; | 1603 }; |
1593 | 1604 |
1594 #endif | 1605 #endif |
OLD | NEW |