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