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 19 matching lines...) Expand all Loading... |
30 class SkDrawFilter; | 30 class SkDrawFilter; |
31 class SkMetaData; | 31 class SkMetaData; |
32 class SkPicture; | 32 class SkPicture; |
33 class SkRRect; | 33 class SkRRect; |
34 class SkSurface; | 34 class SkSurface; |
35 class SkSurface_Base; | 35 class SkSurface_Base; |
36 class SkTextBlob; | 36 class SkTextBlob; |
37 class GrContext; | 37 class GrContext; |
38 class GrRenderTarget; | 38 class GrRenderTarget; |
39 | 39 |
| 40 class SkCanvasState; |
| 41 |
| 42 namespace SkCanvasStateUtils { |
| 43 SkCanvasState* CaptureCanvasState(SkCanvas*);// needs gettotalclip() |
| 44 } |
| 45 |
40 /** \class SkCanvas | 46 /** \class SkCanvas |
41 | 47 |
42 A Canvas encapsulates all of the state about drawing into a device (bitmap). | 48 A Canvas encapsulates all of the state about drawing into a device (bitmap). |
43 This includes a reference to the device itself, and a stack of matrix/clip | 49 This includes a reference to the device itself, and a stack of matrix/clip |
44 values. For any given draw call (e.g. drawRect), the geometry of the object | 50 values. For any given draw call (e.g. drawRect), the geometry of the object |
45 being drawn is transformed by the concatenation of all the matrices in the | 51 being drawn is transformed by the concatenation of all the matrices in the |
46 stack. The transformed geometry is clipped by the intersection of all of | 52 stack. The transformed geometry is clipped by the intersection of all of |
47 the clips in the stack. | 53 the clips in the stack. |
48 | 54 |
49 While the Canvas holds the state of the drawing device, the state (style) | 55 While the Canvas holds the state of the drawing device, the state (style) |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 // in our constructor to ensure that fStorage is large enough | 1181 // in our constructor to ensure that fStorage is large enough |
1176 // (though needs to be a compile-time-assert!). We use intptr_t to work | 1182 // (though needs to be a compile-time-assert!). We use intptr_t to work |
1177 // safely with 32 and 64 bit machines (to ensure the storage is enough) | 1183 // safely with 32 and 64 bit machines (to ensure the storage is enough) |
1178 intptr_t fStorage[32]; | 1184 intptr_t fStorage[32]; |
1179 class SkDrawIter* fImpl; // this points at fStorage | 1185 class SkDrawIter* fImpl; // this points at fStorage |
1180 SkPaint fDefaultPaint; | 1186 SkPaint fDefaultPaint; |
1181 bool fDone; | 1187 bool fDone; |
1182 }; | 1188 }; |
1183 | 1189 |
1184 // don't call | 1190 // don't call |
1185 const SkRegion& internal_private_getTotalClip() const; | |
1186 // don't call | |
1187 void internal_private_getTotalClipAsPath(SkPath*) const; | |
1188 // don't call | |
1189 GrRenderTarget* internal_private_accessTopLayerRenderTarget(); | 1191 GrRenderTarget* internal_private_accessTopLayerRenderTarget(); |
1190 | 1192 |
1191 protected: | 1193 protected: |
1192 // default impl defers to getDevice()->newSurface(info) | 1194 // default impl defers to getDevice()->newSurface(info) |
1193 virtual SkSurface* onNewSurface(const SkImageInfo&); | 1195 virtual SkSurface* onNewSurface(const SkImageInfo&); |
1194 | 1196 |
1195 // default impl defers to its device | 1197 // default impl defers to its device |
1196 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes); | 1198 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes); |
1197 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); | 1199 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); |
1198 | 1200 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 | 1302 |
1301 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() | 1303 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() |
1302 void updateDeviceCMCache(); | 1304 void updateDeviceCMCache(); |
1303 | 1305 |
1304 friend class SkDrawIter; // needs setupDrawForLayerDevice() | 1306 friend class SkDrawIter; // needs setupDrawForLayerDevice() |
1305 friend class AutoDrawLooper; | 1307 friend class AutoDrawLooper; |
1306 friend class SkLua; // needs top layer size and offset | 1308 friend class SkLua; // needs top layer size and offset |
1307 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip | 1309 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip |
1308 friend class SkDeferredDevice; // needs getTopDevice() | 1310 friend class SkDeferredDevice; // needs getTopDevice() |
1309 friend class SkSurface_Raster; // needs getDevice() | 1311 friend class SkSurface_Raster; // needs getDevice() |
1310 | 1312 |
| 1313 friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*);// n
eeds gettotalclip() |
| 1314 |
1311 SkBaseDevice* createLayerDevice(const SkImageInfo&); | 1315 SkBaseDevice* createLayerDevice(const SkImageInfo&); |
1312 | 1316 |
1313 SkBaseDevice* init(SkBaseDevice*); | 1317 SkBaseDevice* init(SkBaseDevice*); |
1314 | 1318 |
1315 /** | 1319 /** |
1316 * DEPRECATED | 1320 * DEPRECATED |
1317 * | 1321 * |
1318 * Specify a device for this canvas to draw into. If it is not null, its | 1322 * Specify a device for this canvas to draw into. If it is not null, its |
1319 * reference count is incremented. If the canvas was already holding a | 1323 * reference count is incremented. If the canvas was already holding a |
1320 * device, its reference count is decremented. The new device is returned. | 1324 * device, its reference count is decremented. The new device is returned. |
(...skipping 22 matching lines...) Expand all Loading... |
1343 | 1347 |
1344 // shared by save() and saveLayer() | 1348 // shared by save() and saveLayer() |
1345 int internalSave(); | 1349 int internalSave(); |
1346 void internalRestore(); | 1350 void internalRestore(); |
1347 static void DrawRect(const SkDraw& draw, const SkPaint& paint, | 1351 static void DrawRect(const SkDraw& draw, const SkPaint& paint, |
1348 const SkRect& r, SkScalar textSize); | 1352 const SkRect& r, SkScalar textSize); |
1349 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, | 1353 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, |
1350 const char text[], size_t byteLength, | 1354 const char text[], size_t byteLength, |
1351 SkScalar x, SkScalar y); | 1355 SkScalar x, SkScalar y); |
1352 | 1356 |
| 1357 // only for canvasutils |
| 1358 const SkRegion& internal_private_getTotalClip() const; |
| 1359 |
1353 /* These maintain a cache of the clip bounds in local coordinates, | 1360 /* These maintain a cache of the clip bounds in local coordinates, |
1354 (converted to 2s-compliment if floats are slow). | 1361 (converted to 2s-compliment if floats are slow). |
1355 */ | 1362 */ |
1356 mutable SkRect fCachedLocalClipBounds; | 1363 mutable SkRect fCachedLocalClipBounds; |
1357 mutable bool fCachedLocalClipBoundsDirty; | 1364 mutable bool fCachedLocalClipBoundsDirty; |
1358 bool fAllowSoftClip; | 1365 bool fAllowSoftClip; |
1359 bool fAllowSimplifyClip; | 1366 bool fAllowSimplifyClip; |
1360 | 1367 |
1361 const SkRect& getLocalClipBounds() const { | 1368 const SkRect& getLocalClipBounds() const { |
1362 if (fCachedLocalClipBoundsDirty) { | 1369 if (fCachedLocalClipBoundsDirty) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 | 1513 |
1507 class SkCanvasClipVisitor { | 1514 class SkCanvasClipVisitor { |
1508 public: | 1515 public: |
1509 virtual ~SkCanvasClipVisitor(); | 1516 virtual ~SkCanvasClipVisitor(); |
1510 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1517 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1511 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1518 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1512 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1519 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1513 }; | 1520 }; |
1514 | 1521 |
1515 #endif | 1522 #endif |
OLD | NEW |