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 |
11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
13 #include "SkDeque.h" | 13 #include "SkDeque.h" |
14 #include "SkClipStack.h" | 14 #include "SkClipStack.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
17 #include "SkPath.h" | 17 #include "SkPath.h" |
18 #include "SkRegion.h" | 18 #include "SkRegion.h" |
19 #include "SkSurfaceProps.h" | |
20 #include "SkXfermode.h" | 19 #include "SkXfermode.h" |
21 | 20 |
22 #ifdef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL | 21 #ifdef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL |
23 #define SK_LEGACY_DRAWTEXT_VIRTUAL virtual | 22 #define SK_LEGACY_DRAWTEXT_VIRTUAL virtual |
24 #else | 23 #else |
25 #define SK_LEGACY_DRAWTEXT_VIRTUAL | 24 #define SK_LEGACY_DRAWTEXT_VIRTUAL |
26 #endif | 25 #endif |
27 | 26 |
28 class SkCanvasClipVisitor; | 27 class SkCanvasClipVisitor; |
29 class SkBaseDevice; | 28 class SkBaseDevice; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 #ifndef SK_SUPPORT_LEGACY_GETTOPDEVICE | 193 #ifndef SK_SUPPORT_LEGACY_GETTOPDEVICE |
195 private: | 194 private: |
196 #endif | 195 #endif |
197 SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const; | 196 SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const; |
198 public: | 197 public: |
199 | 198 |
200 /** | 199 /** |
201 * Create a new surface matching the specified info, one that attempts to | 200 * Create a new surface matching the specified info, one that attempts to |
202 * be maximally compatible when used with this canvas. If there is no match
ing Surface type, | 201 * be maximally compatible when used with this canvas. If there is no match
ing Surface type, |
203 * NULL is returned. | 202 * NULL is returned. |
204 * | |
205 * If surfaceprops is specified, those are passed to the new surface, other
wise the new surface | |
206 * inherits the properties of the surface that owns this canvas. If this ca
nvas has no parent | |
207 * surface, then the new surface is created with default properties. | |
208 */ | 203 */ |
209 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL); | 204 SkSurface* newSurface(const SkImageInfo&); |
210 | 205 |
211 /** | 206 /** |
212 * Return the GPU context of the device that is associated with the canvas. | 207 * Return the GPU context of the device that is associated with the canvas. |
213 * For a canvas with non-GPU device, NULL is returned. | 208 * For a canvas with non-GPU device, NULL is returned. |
214 */ | 209 */ |
215 GrContext* getGrContext(); | 210 GrContext* getGrContext(); |
216 | 211 |
217 /////////////////////////////////////////////////////////////////////////// | 212 /////////////////////////////////////////////////////////////////////////// |
218 | 213 |
219 /** | 214 /** |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 class SkDrawIter* fImpl; // this points at fStorage | 1185 class SkDrawIter* fImpl; // this points at fStorage |
1191 SkPaint fDefaultPaint; | 1186 SkPaint fDefaultPaint; |
1192 bool fDone; | 1187 bool fDone; |
1193 }; | 1188 }; |
1194 | 1189 |
1195 // don't call | 1190 // don't call |
1196 GrRenderTarget* internal_private_accessTopLayerRenderTarget(); | 1191 GrRenderTarget* internal_private_accessTopLayerRenderTarget(); |
1197 | 1192 |
1198 protected: | 1193 protected: |
1199 // default impl defers to getDevice()->newSurface(info) | 1194 // default impl defers to getDevice()->newSurface(info) |
1200 virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&); | 1195 virtual SkSurface* onNewSurface(const SkImageInfo&); |
1201 | 1196 |
1202 // default impl defers to its device | 1197 // default impl defers to its device |
1203 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes); | 1198 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes); |
1204 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); | 1199 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); |
1205 | 1200 |
1206 // Subclass save/restore notifiers. | 1201 // Subclass save/restore notifiers. |
1207 // Overriders should call the corresponding INHERITED method up the inherita
nce chain. | 1202 // Overriders should call the corresponding INHERITED method up the inherita
nce chain. |
1208 // willSaveLayer()'s return value may suppress full layer allocation. | 1203 // willSaveLayer()'s return value may suppress full layer allocation. |
1209 enum SaveLayerStrategy { | 1204 enum SaveLayerStrategy { |
1210 kFullLayer_SaveLayerStrategy, | 1205 kFullLayer_SaveLayerStrategy, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 private: | 1275 private: |
1281 class MCRec; | 1276 class MCRec; |
1282 | 1277 |
1283 SkClipStack fClipStack; | 1278 SkClipStack fClipStack; |
1284 SkDeque fMCStack; | 1279 SkDeque fMCStack; |
1285 // points to top of stack | 1280 // points to top of stack |
1286 MCRec* fMCRec; | 1281 MCRec* fMCRec; |
1287 // the first N recs that can fit here mean we won't call malloc | 1282 // the first N recs that can fit here mean we won't call malloc |
1288 uint32_t fMCRecStorage[32]; | 1283 uint32_t fMCRecStorage[32]; |
1289 | 1284 |
1290 const SkSurfaceProps fProps; | |
1291 | |
1292 int fSaveLayerCount; // number of successful saveLayer calls | 1285 int fSaveLayerCount; // number of successful saveLayer calls |
1293 int fCullCount; // number of active culls | 1286 int fCullCount; // number of active culls |
1294 | 1287 |
1295 SkMetaData* fMetaData; | 1288 SkMetaData* fMetaData; |
1296 | 1289 |
1297 SkSurface_Base* fSurfaceBase; | 1290 SkSurface_Base* fSurfaceBase; |
1298 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; } | 1291 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; } |
1299 void setSurfaceBase(SkSurface_Base* sb) { | 1292 void setSurfaceBase(SkSurface_Base* sb) { |
1300 fSurfaceBase = sb; | 1293 fSurfaceBase = sb; |
1301 } | 1294 } |
1302 friend class SkSurface_Base; | 1295 friend class SkSurface_Base; |
1303 friend class SkSurface_Gpu; | 1296 friend class SkSurface_Gpu; |
1304 | 1297 |
1305 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() | 1298 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() |
1306 void updateDeviceCMCache(); | 1299 void updateDeviceCMCache(); |
1307 | 1300 |
1308 friend class SkDrawIter; // needs setupDrawForLayerDevice() | 1301 friend class SkDrawIter; // needs setupDrawForLayerDevice() |
1309 friend class AutoDrawLooper; | 1302 friend class AutoDrawLooper; |
1310 friend class SkLua; // needs top layer size and offset | 1303 friend class SkLua; // needs top layer size and offset |
1311 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip | 1304 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip |
1312 friend class SkDeferredDevice; // needs getTopDevice() | 1305 friend class SkDeferredDevice; // needs getTopDevice() |
1313 friend class SkSurface_Raster; // needs getDevice() | 1306 friend class SkSurface_Raster; // needs getDevice() |
1314 friend class SkRecorder; // InitFlags | 1307 friend class SkRecorder; // InitFlags |
1315 friend class SkNoSaveLayerCanvas; // InitFlags | 1308 friend class SkNoSaveLayerCanvas; // InitFlags |
1316 | 1309 |
1317 enum InitFlags { | 1310 enum InitFlags { |
1318 kDefault_InitFlags = 0, | 1311 kDefault_InitFlags = 0, |
1319 kConservativeRasterClip_InitFlag = 1 << 0, | 1312 kConservativeRasterClip_InitFlag = 1 << 0, |
1320 }; | 1313 }; |
1321 SkCanvas(int width, int height, InitFlags); | 1314 SkCanvas(int width, int height, InitFlags flags); |
1322 SkCanvas(SkBaseDevice*, const SkSurfaceProps*, InitFlags); | 1315 SkCanvas(SkBaseDevice*, InitFlags flags); |
1323 SkCanvas(const SkBitmap&, const SkSurfaceProps&); | |
1324 | 1316 |
1325 // needs gettotalclip() | 1317 // needs gettotalclip() |
1326 friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*); | 1318 friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*); |
1327 | 1319 |
1328 SkBaseDevice* createLayerDevice(const SkImageInfo&); | 1320 SkBaseDevice* createLayerDevice(const SkImageInfo&); |
1329 | 1321 |
1330 // call this each time we attach ourselves to a device | |
1331 // - constructor | |
1332 // - internalSaveLayer | |
1333 void setupDevice(SkBaseDevice*); | |
1334 | |
1335 SkBaseDevice* init(SkBaseDevice*, InitFlags); | 1322 SkBaseDevice* init(SkBaseDevice*, InitFlags); |
1336 | 1323 |
1337 /** | 1324 /** |
1338 * DEPRECATED | 1325 * DEPRECATED |
1339 * | 1326 * |
1340 * Specify a device for this canvas to draw into. If it is not null, its | 1327 * Specify a device for this canvas to draw into. If it is not null, its |
1341 * reference count is incremented. If the canvas was already holding a | 1328 * reference count is incremented. If the canvas was already holding a |
1342 * device, its reference count is decremented. The new device is returned. | 1329 * device, its reference count is decremented. The new device is returned. |
1343 */ | 1330 */ |
1344 SkBaseDevice* setRootDevice(SkBaseDevice* device); | 1331 SkBaseDevice* setRootDevice(SkBaseDevice* device); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 | 1519 |
1533 class SkCanvasClipVisitor { | 1520 class SkCanvasClipVisitor { |
1534 public: | 1521 public: |
1535 virtual ~SkCanvasClipVisitor(); | 1522 virtual ~SkCanvasClipVisitor(); |
1536 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1523 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1537 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1524 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1538 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1525 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1539 }; | 1526 }; |
1540 | 1527 |
1541 #endif | 1528 #endif |
OLD | NEW |