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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 #endif | 316 #endif |
317 kARGB_ClipLayer_SaveFlag = 0x1F | 317 kARGB_ClipLayer_SaveFlag = 0x1F |
318 }; | 318 }; |
319 | 319 |
320 /** This call saves the current matrix, clip, and drawFilter, and pushes a | 320 /** This call saves the current matrix, clip, and drawFilter, and pushes a |
321 copy onto a private stack. Subsequent calls to translate, scale, | 321 copy onto a private stack. Subsequent calls to translate, scale, |
322 rotate, skew, concat or clipRect, clipPath, and setDrawFilter all | 322 rotate, skew, concat or clipRect, clipPath, and setDrawFilter all |
323 operate on this copy. | 323 operate on this copy. |
324 When the balancing call to restore() is made, the previous matrix, clip, | 324 When the balancing call to restore() is made, the previous matrix, clip, |
325 and drawFilter are restored. | 325 and drawFilter are restored. |
| 326 |
| 327 @return The value to pass to restoreToCount() to balance this save() |
| 328 */ |
| 329 int save(); |
| 330 |
| 331 /** DEPRECATED - use save() instead. |
| 332 |
| 333 This behaves the same as save(), but it allows fine-grained control of |
| 334 which state bits to be saved (and subsequently restored). |
| 335 |
326 @param flags The flags govern what portion of the Matrix/Clip/drawFilter | 336 @param flags The flags govern what portion of the Matrix/Clip/drawFilter |
327 state the save (and matching restore) effect. For example, | 337 state the save (and matching restore) effect. For example, |
328 if only kMatrix is specified, then only the matrix state | 338 if only kMatrix is specified, then only the matrix state |
329 will be pushed and popped. Likewise for the clip if kClip | 339 will be pushed and popped. Likewise for the clip if kClip |
330 is specified. However, the drawFilter is always affected | 340 is specified. However, the drawFilter is always affected |
331 by calls to save/restore. | 341 by calls to save/restore. |
332 @return The value to pass to restoreToCount() to balance this save() | 342 @return The value to pass to restoreToCount() to balance this save() |
333 */ | 343 */ |
334 int save(SaveFlags flags = kMatrixClip_SaveFlag); | 344 SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated") |
| 345 int save(SaveFlags flags); |
335 | 346 |
336 /** This behaves the same as save(), but in addition it allocates an | 347 /** This behaves the same as save(), but in addition it allocates an |
337 offscreen bitmap. All drawing calls are directed there, and only when | 348 offscreen bitmap. All drawing calls are directed there, and only when |
338 the balancing call to restore() is made is that offscreen transfered to | 349 the balancing call to restore() is made is that offscreen transfered to |
339 the canvas (or the previous layer). | 350 the canvas (or the previous layer). |
340 @param bounds (may be null) This rect, if non-null, is used as a hint to | 351 @param bounds (may be null) This rect, if non-null, is used as a hint to |
341 limit the size of the offscreen, and thus drawing may be | 352 limit the size of the offscreen, and thus drawing may be |
342 clipped to it, though that clipping is not guaranteed to | 353 clipped to it, though that clipping is not guaranteed to |
343 happen. If exact clipping is desired, use clipRect(). | 354 happen. If exact clipping is desired, use clipRect(). |
344 @param paint (may be null) This is copied, and is applied to the | 355 @param paint (may be null) This is copied, and is applied to the |
345 offscreen when restore() is called | 356 offscreen when restore() is called |
| 357 @return The value to pass to restoreToCount() to balance this save() |
| 358 */ |
| 359 int saveLayer(const SkRect* bounds, const SkPaint* paint); |
| 360 |
| 361 /** DEPRECATED - use saveLayer(const SkRect*, const SkPaint*) instead. |
| 362 |
| 363 This behaves the same as saveLayer(const SkRect*, const SkPaint*), |
| 364 but it allows fine-grained control of which state bits to be saved |
| 365 (and subsequently restored). |
| 366 |
| 367 @param bounds (may be null) This rect, if non-null, is used as a hint to |
| 368 limit the size of the offscreen, and thus drawing may be |
| 369 clipped to it, though that clipping is not guaranteed to |
| 370 happen. If exact clipping is desired, use clipRect(). |
| 371 @param paint (may be null) This is copied, and is applied to the |
| 372 offscreen when restore() is called |
346 @param flags LayerFlags | 373 @param flags LayerFlags |
347 @return The value to pass to restoreToCount() to balance this save() | 374 @return The value to pass to restoreToCount() to balance this save() |
348 */ | 375 */ |
349 int saveLayer(const SkRect* bounds, const SkPaint* paint, | 376 SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated") |
350 SaveFlags flags = kARGB_ClipLayer_SaveFlag); | 377 int saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags); |
351 | 378 |
352 /** This behaves the same as save(), but in addition it allocates an | 379 /** This behaves the same as save(), but in addition it allocates an |
353 offscreen bitmap. All drawing calls are directed there, and only when | 380 offscreen bitmap. All drawing calls are directed there, and only when |
354 the balancing call to restore() is made is that offscreen transfered to | 381 the balancing call to restore() is made is that offscreen transfered to |
355 the canvas (or the previous layer). | 382 the canvas (or the previous layer). |
356 @param bounds (may be null) This rect, if non-null, is used as a hint to | 383 @param bounds (may be null) This rect, if non-null, is used as a hint to |
357 limit the size of the offscreen, and thus drawing may be | 384 limit the size of the offscreen, and thus drawing may be |
358 clipped to it, though that clipping is not guaranteed to | 385 clipped to it, though that clipping is not guaranteed to |
359 happen. If exact clipping is desired, use clipRect(). | 386 happen. If exact clipping is desired, use clipRect(). |
360 @param alpha This is applied to the offscreen when restore() is called. | 387 @param alpha This is applied to the offscreen when restore() is called. |
| 388 @return The value to pass to restoreToCount() to balance this save() |
| 389 */ |
| 390 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha); |
| 391 |
| 392 /** DEPRECATED - use saveLayerAlpha(const SkRect*, U8CPU) instead. |
| 393 |
| 394 This behaves the same as saveLayerAlpha(const SkRect*, U8CPU), |
| 395 but it allows fine-grained control of which state bits to be saved |
| 396 (and subsequently restored). |
| 397 |
| 398 @param bounds (may be null) This rect, if non-null, is used as a hint to |
| 399 limit the size of the offscreen, and thus drawing may be |
| 400 clipped to it, though that clipping is not guaranteed to |
| 401 happen. If exact clipping is desired, use clipRect(). |
| 402 @param alpha This is applied to the offscreen when restore() is called. |
361 @param flags LayerFlags | 403 @param flags LayerFlags |
362 @return The value to pass to restoreToCount() to balance this save() | 404 @return The value to pass to restoreToCount() to balance this save() |
363 */ | 405 */ |
364 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha, | 406 SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated") |
365 SaveFlags flags = kARGB_ClipLayer_SaveFlag); | 407 int saveLayerAlpha(const SkRect* bounds, U8CPU alpha, SaveFlags flags); |
366 | 408 |
367 /** This call balances a previous call to save(), and is used to remove all | 409 /** This call balances a previous call to save(), and is used to remove all |
368 modifications to the matrix/clip/drawFilter state since the last save | 410 modifications to the matrix/clip/drawFilter state since the last save |
369 call. | 411 call. |
370 It is an error to call restore() more times than save() was called. | 412 It is an error to call restore() more times than save() was called. |
371 */ | 413 */ |
372 void restore(); | 414 void restore(); |
373 | 415 |
374 /** Returns the number of matrix/clip states on the SkCanvas' private stack. | 416 /** Returns the number of matrix/clip states on the SkCanvas' private stack. |
375 This will equal # save() calls - # restore() calls + 1. The save count o
n | 417 This will equal # save() calls - # restore() calls + 1. The save count o
n |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 bool asROBitmap(SkBitmap*) const; | 1477 bool asROBitmap(SkBitmap*) const; |
1436 | 1478 |
1437 private: | 1479 private: |
1438 SkBitmap fBitmap; // used if peekPixels() fails | 1480 SkBitmap fBitmap; // used if peekPixels() fails |
1439 const void* fAddr; // NULL on failure | 1481 const void* fAddr; // NULL on failure |
1440 SkImageInfo fInfo; | 1482 SkImageInfo fInfo; |
1441 size_t fRowBytes; | 1483 size_t fRowBytes; |
1442 }; | 1484 }; |
1443 | 1485 |
1444 #endif | 1486 #endif |
OLD | NEW |