Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: include/core/SkCanvas.h

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add new file Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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...) Expand 10 before | Expand all | Expand 10 after
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 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.
203 */ 208 */
204 SkSurface* newSurface(const SkImageInfo&); 209 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL);
205 210
206 /** 211 /**
207 * Return the GPU context of the device that is associated with the canvas. 212 * Return the GPU context of the device that is associated with the canvas.
208 * For a canvas with non-GPU device, NULL is returned. 213 * For a canvas with non-GPU device, NULL is returned.
209 */ 214 */
210 GrContext* getGrContext(); 215 GrContext* getGrContext();
211 216
212 /////////////////////////////////////////////////////////////////////////// 217 ///////////////////////////////////////////////////////////////////////////
213 218
214 /** 219 /**
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 class SkDrawIter* fImpl; // this points at fStorage 1190 class SkDrawIter* fImpl; // this points at fStorage
1186 SkPaint fDefaultPaint; 1191 SkPaint fDefaultPaint;
1187 bool fDone; 1192 bool fDone;
1188 }; 1193 };
1189 1194
1190 // don't call 1195 // don't call
1191 GrRenderTarget* internal_private_accessTopLayerRenderTarget(); 1196 GrRenderTarget* internal_private_accessTopLayerRenderTarget();
1192 1197
1193 protected: 1198 protected:
1194 // default impl defers to getDevice()->newSurface(info) 1199 // default impl defers to getDevice()->newSurface(info)
1195 virtual SkSurface* onNewSurface(const SkImageInfo&); 1200 virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&);
1196 1201
1197 // default impl defers to its device 1202 // default impl defers to its device
1198 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes); 1203 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes);
1199 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); 1204 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes);
1200 1205
1201 // Subclass save/restore notifiers. 1206 // Subclass save/restore notifiers.
1202 // Overriders should call the corresponding INHERITED method up the inherita nce chain. 1207 // Overriders should call the corresponding INHERITED method up the inherita nce chain.
1203 // willSaveLayer()'s return value may suppress full layer allocation. 1208 // willSaveLayer()'s return value may suppress full layer allocation.
1204 enum SaveLayerStrategy { 1209 enum SaveLayerStrategy {
1205 kFullLayer_SaveLayerStrategy, 1210 kFullLayer_SaveLayerStrategy,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 private: 1280 private:
1276 class MCRec; 1281 class MCRec;
1277 1282
1278 SkClipStack fClipStack; 1283 SkClipStack fClipStack;
1279 SkDeque fMCStack; 1284 SkDeque fMCStack;
1280 // points to top of stack 1285 // points to top of stack
1281 MCRec* fMCRec; 1286 MCRec* fMCRec;
1282 // the first N recs that can fit here mean we won't call malloc 1287 // the first N recs that can fit here mean we won't call malloc
1283 uint32_t fMCRecStorage[32]; 1288 uint32_t fMCRecStorage[32];
1284 1289
1290 const SkSurfaceProps fProps;
1291
1285 int fSaveLayerCount; // number of successful saveLayer calls 1292 int fSaveLayerCount; // number of successful saveLayer calls
1286 int fCullCount; // number of active culls 1293 int fCullCount; // number of active culls
1287 1294
1288 SkMetaData* fMetaData; 1295 SkMetaData* fMetaData;
1289 1296
1290 SkSurface_Base* fSurfaceBase; 1297 SkSurface_Base* fSurfaceBase;
1291 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; } 1298 SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; }
1292 void setSurfaceBase(SkSurface_Base* sb) { 1299 void setSurfaceBase(SkSurface_Base* sb) {
1293 fSurfaceBase = sb; 1300 fSurfaceBase = sb;
1294 } 1301 }
1295 friend class SkSurface_Base; 1302 friend class SkSurface_Base;
1296 friend class SkSurface_Gpu; 1303 friend class SkSurface_Gpu;
1297 1304
1298 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() 1305 bool fDeviceCMDirty; // cleared by updateDeviceCMCache()
1299 void updateDeviceCMCache(); 1306 void updateDeviceCMCache();
1300 1307
1301 friend class SkDrawIter; // needs setupDrawForLayerDevice() 1308 friend class SkDrawIter; // needs setupDrawForLayerDevice()
1302 friend class AutoDrawLooper; 1309 friend class AutoDrawLooper;
1303 friend class SkLua; // needs top layer size and offset 1310 friend class SkLua; // needs top layer size and offset
1304 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip 1311 friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip
1305 friend class SkDeferredDevice; // needs getTopDevice() 1312 friend class SkDeferredDevice; // needs getTopDevice()
1306 friend class SkSurface_Raster; // needs getDevice() 1313 friend class SkSurface_Raster; // needs getDevice()
1307 friend class SkRecorder; // InitFlags 1314 friend class SkRecorder; // InitFlags
1308 friend class SkNoSaveLayerCanvas; // InitFlags 1315 friend class SkNoSaveLayerCanvas; // InitFlags
1309 1316
1310 enum InitFlags { 1317 enum InitFlags {
1311 kDefault_InitFlags = 0, 1318 kDefault_InitFlags = 0,
1312 kConservativeRasterClip_InitFlag = 1 << 0, 1319 kConservativeRasterClip_InitFlag = 1 << 0,
1313 }; 1320 };
1314 SkCanvas(int width, int height, InitFlags flags); 1321 SkCanvas(int width, int height, InitFlags);
1315 SkCanvas(SkBaseDevice*, InitFlags flags); 1322 SkCanvas(SkBaseDevice*, const SkSurfaceProps*, InitFlags);
1323 SkCanvas(const SkBitmap&, const SkSurfaceProps&);
1316 1324
1317 // needs gettotalclip() 1325 // needs gettotalclip()
1318 friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*); 1326 friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*);
1319 1327
1320 SkBaseDevice* createLayerDevice(const SkImageInfo&); 1328 SkBaseDevice* createLayerDevice(const SkImageInfo&);
1321 1329
1330 // call this each time we attach ourselves to a device
1331 // - constructor
1332 // - internalSaveLayer
1333 void setupDevice(SkBaseDevice*);
1334
1322 SkBaseDevice* init(SkBaseDevice*, InitFlags); 1335 SkBaseDevice* init(SkBaseDevice*, InitFlags);
1323 1336
1324 /** 1337 /**
1325 * DEPRECATED 1338 * DEPRECATED
1326 * 1339 *
1327 * Specify a device for this canvas to draw into. If it is not null, its 1340 * 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 1341 * reference count is incremented. If the canvas was already holding a
1329 * device, its reference count is decremented. The new device is returned. 1342 * device, its reference count is decremented. The new device is returned.
1330 */ 1343 */
1331 SkBaseDevice* setRootDevice(SkBaseDevice* device); 1344 SkBaseDevice* setRootDevice(SkBaseDevice* device);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 1532
1520 class SkCanvasClipVisitor { 1533 class SkCanvasClipVisitor {
1521 public: 1534 public:
1522 virtual ~SkCanvasClipVisitor(); 1535 virtual ~SkCanvasClipVisitor();
1523 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; 1536 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0;
1524 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; 1537 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0;
1525 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; 1538 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0;
1526 }; 1539 };
1527 1540
1528 #endif 1541 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698