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

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

Issue 187553003: Clean up SkCanvas::clip* API (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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 | « no previous file | 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 /** Helper for setMatrix(identity). Sets the current matrix to identity. 417 /** Helper for setMatrix(identity). Sets the current matrix to identity.
418 */ 418 */
419 void resetMatrix(); 419 void resetMatrix();
420 420
421 /** 421 /**
422 * Modify the current clip with the specified rectangle. 422 * Modify the current clip with the specified rectangle.
423 * @param rect The rect to combine with the current clip 423 * @param rect The rect to combine with the current clip
424 * @param op The region op to apply to the current clip 424 * @param op The region op to apply to the current clip
425 * @param doAntiAlias true if the clip should be antialiased 425 * @param doAntiAlias true if the clip should be antialiased
426 * @return true if the canvas' clip is non-empty
427 */ 426 */
428 virtual bool clipRect(const SkRect& rect, 427 void clipRect(const SkRect& rect,
429 SkRegion::Op op = SkRegion::kIntersect_Op, 428 SkRegion::Op op = SkRegion::kIntersect_Op,
430 bool doAntiAlias = false); 429 bool doAntiAlias = false);
431 430
432 /** 431 /**
433 * Modify the current clip with the specified SkRRect. 432 * Modify the current clip with the specified SkRRect.
434 * @param rrect The rrect to combine with the current clip 433 * @param rrect The rrect to combine with the current clip
435 * @param op The region op to apply to the current clip 434 * @param op The region op to apply to the current clip
436 * @param doAntiAlias true if the clip should be antialiased 435 * @param doAntiAlias true if the clip should be antialiased
437 * @return true if the canvas' clip is non-empty
438 */ 436 */
439 virtual bool clipRRect(const SkRRect& rrect, 437 void clipRRect(const SkRRect& rrect,
440 SkRegion::Op op = SkRegion::kIntersect_Op, 438 SkRegion::Op op = SkRegion::kIntersect_Op,
441 bool doAntiAlias = false); 439 bool doAntiAlias = false);
442 440
443 /** 441 /**
444 * Modify the current clip with the specified path. 442 * Modify the current clip with the specified path.
445 * @param path The path to combine with the current clip 443 * @param path The path to combine with the current clip
446 * @param op The region op to apply to the current clip 444 * @param op The region op to apply to the current clip
447 * @param doAntiAlias true if the clip should be antialiased 445 * @param doAntiAlias true if the clip should be antialiased
448 * @return true if the canvas' new clip is non-empty
449 */ 446 */
450 virtual bool clipPath(const SkPath& path, 447 void clipPath(const SkPath& path,
451 SkRegion::Op op = SkRegion::kIntersect_Op, 448 SkRegion::Op op = SkRegion::kIntersect_Op,
452 bool doAntiAlias = false); 449 bool doAntiAlias = false);
453 450
454 /** EXPERIMENTAL -- only used for testing 451 /** EXPERIMENTAL -- only used for testing
455 Set to false to force clips to be hard, even if doAntiAlias=true is 452 Set to false to force clips to be hard, even if doAntiAlias=true is
456 passed to clipRect or clipPath. 453 passed to clipRect or clipPath.
457 */ 454 */
458 void setAllowSoftClip(bool allow) { 455 void setAllowSoftClip(bool allow) {
459 fAllowSoftClip = allow; 456 fAllowSoftClip = allow;
460 } 457 }
461 458
462 /** EXPERIMENTAL -- only used for testing 459 /** EXPERIMENTAL -- only used for testing
463 Set to simplify clip stack using path ops. 460 Set to simplify clip stack using path ops.
464 */ 461 */
465 void setAllowSimplifyClip(bool allow) { 462 void setAllowSimplifyClip(bool allow) {
466 fAllowSimplifyClip = allow; 463 fAllowSimplifyClip = allow;
467 } 464 }
468 465
469 /** Modify the current clip with the specified region. Note that unlike 466 /** Modify the current clip with the specified region. Note that unlike
470 clipRect() and clipPath() which transform their arguments by the current 467 clipRect() and clipPath() which transform their arguments by the current
471 matrix, clipRegion() assumes its argument is already in device 468 matrix, clipRegion() assumes its argument is already in device
472 coordinates, and so no transformation is performed. 469 coordinates, and so no transformation is performed.
473 @param deviceRgn The region to apply to the current clip 470 @param deviceRgn The region to apply to the current clip
474 @param op The region op to apply to the current clip 471 @param op The region op to apply to the current clip
475 @return true if the canvas' new clip is non-empty
476 */ 472 */
477 virtual bool clipRegion(const SkRegion& deviceRgn, 473 void clipRegion(const SkRegion& deviceRgn,
478 SkRegion::Op op = SkRegion::kIntersect_Op); 474 SkRegion::Op op = SkRegion::kIntersect_Op);
479 475
480 /** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the 476 /** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the
481 specified region. This does not intersect or in any other way account 477 specified region. This does not intersect or in any other way account
482 for the existing clip region. 478 for the existing clip region.
483 @param deviceRgn The region to copy into the current clip. 479 @param deviceRgn The region to copy into the current clip.
484 */ 480 */
485 void setClipRegion(const SkRegion& deviceRgn) { 481 void setClipRegion(const SkRegion& deviceRgn) {
486 this->clipRegion(deviceRgn, SkRegion::kReplace_Op); 482 this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
487 } 483 }
488 484
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 // Clip rectangle bounds. Called internally by saveLayer. 1144 // Clip rectangle bounds. Called internally by saveLayer.
1149 // returns false if the entire rectangle is entirely clipped out 1145 // returns false if the entire rectangle is entirely clipped out
1150 // If non-NULL, The imageFilter parameter will be used to expand the clip 1146 // If non-NULL, The imageFilter parameter will be used to expand the clip
1151 // and offscreen bounds for any margin required by the filter DAG. 1147 // and offscreen bounds for any margin required by the filter DAG.
1152 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, 1148 bool clipRectBounds(const SkRect* bounds, SaveFlags flags,
1153 SkIRect* intersection, 1149 SkIRect* intersection,
1154 const SkImageFilter* imageFilter = NULL); 1150 const SkImageFilter* imageFilter = NULL);
1155 1151
1156 // Called by child classes that override clipPath and clipRRect to only 1152 // Called by child classes that override clipPath and clipRRect to only
1157 // track fast conservative clip bounds, rather than exact clips. 1153 // track fast conservative clip bounds, rather than exact clips.
1158 bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, 1154 void updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op,
1159 bool inverseFilled); 1155 bool inverseFilled);
1160 1156
1161 // notify our surface (if we have one) that we are about to draw, so it 1157 // notify our surface (if we have one) that we are about to draw, so it
1162 // can perform copy-on-write or invalidate any cached images 1158 // can perform copy-on-write or invalidate any cached images
1163 void predrawNotify(); 1159 void predrawNotify();
1164 1160
1165 virtual void onPushCull(const SkRect& cullRect); 1161 virtual void onPushCull(const SkRect& cullRect);
1166 virtual void onPopCull(); 1162 virtual void onPopCull();
1167 1163
1168 private: 1164 private:
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 bool asROBitmap(SkBitmap*) const; 1368 bool asROBitmap(SkBitmap*) const;
1373 1369
1374 private: 1370 private:
1375 SkBitmap fBitmap; // used if peekPixels() fails 1371 SkBitmap fBitmap; // used if peekPixels() fails
1376 const void* fAddr; // NULL on failure 1372 const void* fAddr; // NULL on failure
1377 SkImageInfo fInfo; 1373 SkImageInfo fInfo;
1378 size_t fRowBytes; 1374 size_t fRowBytes;
1379 }; 1375 };
1380 1376
1381 #endif 1377 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698