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

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

Issue 249253003: Hide SaveFlags from the public SkCanvas API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Suppress the canvas-state GM. Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « gyp/common_conditions.gypi ('k') | src/core/SkCanvas.cpp » ('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
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in t x, int y); 293 bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in t x, int y);
294 294
295 /** 295 /**
296 * Helper for calling writePixels(info, ...) by passing its pixels and rowb ytes. If the bitmap 296 * Helper for calling writePixels(info, ...) by passing its pixels and rowb ytes. If the bitmap
297 * is just wrapping a texture, returns false and does nothing. 297 * is just wrapping a texture, returns false and does nothing.
298 */ 298 */
299 bool writePixels(const SkBitmap& bitmap, int x, int y); 299 bool writePixels(const SkBitmap& bitmap, int x, int y);
300 300
301 /////////////////////////////////////////////////////////////////////////// 301 ///////////////////////////////////////////////////////////////////////////
302 302
303 #ifndef SK_SUPPORT_LEGACY_SAVEFLAGS
304 protected:
305 #endif
303 enum SaveFlags { 306 enum SaveFlags {
304 /** save the matrix state, restoring it on restore() */ 307 /** save the matrix state, restoring it on restore() */
305 kMatrix_SaveFlag = 0x01, 308 kMatrix_SaveFlag = 0x01,
306 /** save the clip state, restoring it on restore() */ 309 /** save the clip state, restoring it on restore() */
307 kClip_SaveFlag = 0x02, 310 kClip_SaveFlag = 0x02,
308 /** the layer needs to support per-pixel alpha */ 311 /** the layer needs to support per-pixel alpha */
309 kHasAlphaLayer_SaveFlag = 0x04, 312 kHasAlphaLayer_SaveFlag = 0x04,
310 /** the layer needs to support 8-bits per color component */ 313 /** the layer needs to support 8-bits per color component */
311 kFullColorLayer_SaveFlag = 0x08, 314 kFullColorLayer_SaveFlag = 0x08,
312 /** 315 /**
313 * the layer should clip against the bounds argument 316 * the layer should clip against the bounds argument
314 * 317 *
315 * if SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG is undefined, this is treated a s always on. 318 * if SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG is undefined, this is treated a s always on.
316 */ 319 */
317 kClipToLayer_SaveFlag = 0x10, 320 kClipToLayer_SaveFlag = 0x10,
318 321
319 // helper masks for common choices 322 // helper masks for common choices
320 kMatrixClip_SaveFlag = 0x03, 323 kMatrixClip_SaveFlag = 0x03,
321 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG 324 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
322 kARGB_NoClipLayer_SaveFlag = 0x0F, 325 kARGB_NoClipLayer_SaveFlag = 0x0F,
323 #endif 326 #endif
324 kARGB_ClipLayer_SaveFlag = 0x1F 327 kARGB_ClipLayer_SaveFlag = 0x1F
325 }; 328 };
329 public:
326 330
327 /** This call saves the current matrix, clip, and drawFilter, and pushes a 331 /** This call saves the current matrix, clip, and drawFilter, and pushes a
328 copy onto a private stack. Subsequent calls to translate, scale, 332 copy onto a private stack. Subsequent calls to translate, scale,
329 rotate, skew, concat or clipRect, clipPath, and setDrawFilter all 333 rotate, skew, concat or clipRect, clipPath, and setDrawFilter all
330 operate on this copy. 334 operate on this copy.
331 When the balancing call to restore() is made, the previous matrix, clip, 335 When the balancing call to restore() is made, the previous matrix, clip,
332 and drawFilter are restored. 336 and drawFilter are restored.
333 @param flags The flags govern what portion of the Matrix/Clip/drawFilter 337 @param flags (deprecated) The flags govern what portion of the Matrix/Cl ip/drawFilter
334 state the save (and matching restore) effect. For example, 338 state the save (and matching restore) effect. For example,
335 if only kMatrix is specified, then only the matrix state 339 if only kMatrix is specified, then only the matrix state
336 will be pushed and popped. Likewise for the clip if kClip 340 will be pushed and popped. Likewise for the clip if kClip
337 is specified. However, the drawFilter is always affected 341 is specified. However, the drawFilter is always affected
338 by calls to save/restore. 342 by calls to save/restore.
339 @return The value to pass to restoreToCount() to balance this save() 343 @return The value to pass to restoreToCount() to balance this save()
340 */ 344 */
345 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
341 int save(SaveFlags flags = kMatrixClip_SaveFlag); 346 int save(SaveFlags flags = kMatrixClip_SaveFlag);
347 #else
348 int save();
349 #endif
342 350
343 /** This behaves the same as save(), but in addition it allocates an 351 /** This behaves the same as save(), but in addition it allocates an
344 offscreen bitmap. All drawing calls are directed there, and only when 352 offscreen bitmap. All drawing calls are directed there, and only when
345 the balancing call to restore() is made is that offscreen transfered to 353 the balancing call to restore() is made is that offscreen transfered to
346 the canvas (or the previous layer). 354 the canvas (or the previous layer).
347 @param bounds (may be null) This rect, if non-null, is used as a hint to 355 @param bounds (may be null) This rect, if non-null, is used as a hint to
348 limit the size of the offscreen, and thus drawing may be 356 limit the size of the offscreen, and thus drawing may be
349 clipped to it, though that clipping is not guaranteed to 357 clipped to it, though that clipping is not guaranteed to
350 happen. If exact clipping is desired, use clipRect(). 358 happen. If exact clipping is desired, use clipRect().
351 @param paint (may be null) This is copied, and is applied to the 359 @param paint (may be null) This is copied, and is applied to the
352 offscreen when restore() is called 360 offscreen when restore() is called
353 @param flags LayerFlags 361 @param flags (deprecated) LayerFlags
354 @return The value to pass to restoreToCount() to balance this save() 362 @return The value to pass to restoreToCount() to balance this save()
355 */ 363 */
364 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
356 int saveLayer(const SkRect* bounds, const SkPaint* paint, 365 int saveLayer(const SkRect* bounds, const SkPaint* paint,
357 SaveFlags flags = kARGB_ClipLayer_SaveFlag); 366 SaveFlags flags = kARGB_ClipLayer_SaveFlag);
367 #else
368 int saveLayer(const SkRect* bounds, const SkPaint* paint);
369 #endif
358 370
359 /** This behaves the same as save(), but in addition it allocates an 371 /** This behaves the same as save(), but in addition it allocates an
360 offscreen bitmap. All drawing calls are directed there, and only when 372 offscreen bitmap. All drawing calls are directed there, and only when
361 the balancing call to restore() is made is that offscreen transfered to 373 the balancing call to restore() is made is that offscreen transfered to
362 the canvas (or the previous layer). 374 the canvas (or the previous layer).
363 @param bounds (may be null) This rect, if non-null, is used as a hint to 375 @param bounds (may be null) This rect, if non-null, is used as a hint to
364 limit the size of the offscreen, and thus drawing may be 376 limit the size of the offscreen, and thus drawing may be
365 clipped to it, though that clipping is not guaranteed to 377 clipped to it, though that clipping is not guaranteed to
366 happen. If exact clipping is desired, use clipRect(). 378 happen. If exact clipping is desired, use clipRect().
367 @param alpha This is applied to the offscreen when restore() is called. 379 @param alpha This is applied to the offscreen when restore() is called.
368 @param flags LayerFlags 380 @param flags (deprecated) LayerFlags
369 @return The value to pass to restoreToCount() to balance this save() 381 @return The value to pass to restoreToCount() to balance this save()
370 */ 382 */
383 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
371 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha, 384 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
372 SaveFlags flags = kARGB_ClipLayer_SaveFlag); 385 SaveFlags flags = kARGB_ClipLayer_SaveFlag);
386 #else
387 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha);
388 #endif
373 389
374 /** This call balances a previous call to save(), and is used to remove all 390 /** This call balances a previous call to save(), and is used to remove all
375 modifications to the matrix/clip/drawFilter state since the last save 391 modifications to the matrix/clip/drawFilter state since the last save
376 call. 392 call.
377 It is an error to call restore() more times than save() was called. 393 It is an error to call restore() more times than save() was called.
378 */ 394 */
379 void restore(); 395 void restore();
380 396
381 /** Returns the number of matrix/clip states on the SkCanvas' private stack. 397 /** Returns the number of matrix/clip states on the SkCanvas' private stack.
382 This will equal # save() calls - # restore() calls + 1. The save count o n 398 This will equal # save() calls - # restore() calls + 1. The save count o n
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 friend class SkSurface_Gpu; 1286 friend class SkSurface_Gpu;
1271 1287
1272 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() 1288 bool fDeviceCMDirty; // cleared by updateDeviceCMCache()
1273 void updateDeviceCMCache(); 1289 void updateDeviceCMCache();
1274 1290
1275 friend class SkDrawIter; // needs setupDrawForLayerDevice() 1291 friend class SkDrawIter; // needs setupDrawForLayerDevice()
1276 friend class AutoDrawLooper; 1292 friend class AutoDrawLooper;
1277 friend class SkLua; // needs top layer size and offset 1293 friend class SkLua; // needs top layer size and offset
1278 friend class SkDeferredDevice; // needs getTopDevice() 1294 friend class SkDeferredDevice; // needs getTopDevice()
1279 1295
1296 // These want to play with SaveFlags
1297 friend class SkMatrixClipStateMgr;
1298 friend class SkDrawCommand;
1299 friend class SkObjectParser;
1300
1280 SkBaseDevice* createLayerDevice(const SkImageInfo&); 1301 SkBaseDevice* createLayerDevice(const SkImageInfo&);
1281 1302
1282 SkBaseDevice* init(SkBaseDevice*); 1303 SkBaseDevice* init(SkBaseDevice*);
1283 1304
1284 /** 1305 /**
1285 * DEPRECATED 1306 * DEPRECATED
1286 * 1307 *
1287 * Specify a device for this canvas to draw into. If it is not null, its 1308 * Specify a device for this canvas to draw into. If it is not null, its
1288 * reference count is incremented. If the canvas was already holding a 1309 * reference count is incremented. If the canvas was already holding a
1289 * device, its reference count is decremented. The new device is returned. 1310 * device, its reference count is decremented. The new device is returned.
(...skipping 22 matching lines...) Expand all
1312 1333
1313 // shared by save() and saveLayer() 1334 // shared by save() and saveLayer()
1314 int internalSave(SaveFlags flags); 1335 int internalSave(SaveFlags flags);
1315 void internalRestore(); 1336 void internalRestore();
1316 static void DrawRect(const SkDraw& draw, const SkPaint& paint, 1337 static void DrawRect(const SkDraw& draw, const SkPaint& paint,
1317 const SkRect& r, SkScalar textSize); 1338 const SkRect& r, SkScalar textSize);
1318 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, 1339 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
1319 const char text[], size_t byteLength, 1340 const char text[], size_t byteLength,
1320 SkScalar x, SkScalar y); 1341 SkScalar x, SkScalar y);
1321 1342
1343 static bool bounds_affects_clip(SaveFlags);
1344
1322 /* These maintain a cache of the clip bounds in local coordinates, 1345 /* These maintain a cache of the clip bounds in local coordinates,
1323 (converted to 2s-compliment if floats are slow). 1346 (converted to 2s-compliment if floats are slow).
1324 */ 1347 */
1325 mutable SkRect fCachedLocalClipBounds; 1348 mutable SkRect fCachedLocalClipBounds;
1326 mutable bool fCachedLocalClipBoundsDirty; 1349 mutable bool fCachedLocalClipBoundsDirty;
1327 bool fAllowSoftClip; 1350 bool fAllowSoftClip;
1328 bool fAllowSimplifyClip; 1351 bool fAllowSimplifyClip;
1329 1352
1330 const SkRect& getLocalClipBounds() const { 1353 const SkRect& getLocalClipBounds() const {
1331 if (fCachedLocalClipBoundsDirty) { 1354 if (fCachedLocalClipBoundsDirty) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 bool asROBitmap(SkBitmap*) const; 1479 bool asROBitmap(SkBitmap*) const;
1457 1480
1458 private: 1481 private:
1459 SkBitmap fBitmap; // used if peekPixels() fails 1482 SkBitmap fBitmap; // used if peekPixels() fails
1460 const void* fAddr; // NULL on failure 1483 const void* fAddr; // NULL on failure
1461 SkImageInfo fInfo; 1484 SkImageInfo fInfo;
1462 size_t fRowBytes; 1485 size_t fRowBytes;
1463 }; 1486 };
1464 1487
1465 #endif 1488 #endif
OLDNEW
« no previous file with comments | « gyp/common_conditions.gypi ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698