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

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

Issue 183453002: add new onClip* methods to SkCanvas (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: remove debug 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 | « experimental/PdfViewer/SkNulCanvas.h ('k') | include/utils/SkDeferredCanvas.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
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 @param op The region op to apply to the current clip 474 @param op The region op to apply to the current clip
475 @return true if the canvas' new clip is non-empty 475 @return true if the canvas' new clip is non-empty
476 */ 476 */
477 virtual bool clipRegion(const SkRegion& deviceRgn, 477 virtual bool clipRegion(const SkRegion& deviceRgn,
478 SkRegion::Op op = SkRegion::kIntersect_Op); 478 SkRegion::Op op = SkRegion::kIntersect_Op);
479 479
480 /** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the 480 /** 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 481 specified region. This does not intersect or in any other way account
482 for the existing clip region. 482 for the existing clip region.
483 @param deviceRgn The region to copy into the current clip. 483 @param deviceRgn The region to copy into the current clip.
484 @return true if the new clip region is non-empty
485 */ 484 */
486 bool setClipRegion(const SkRegion& deviceRgn) { 485 void setClipRegion(const SkRegion& deviceRgn) {
487 return this->clipRegion(deviceRgn, SkRegion::kReplace_Op); 486 this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
488 } 487 }
489 488
490 /** Return true if the specified rectangle, after being transformed by the 489 /** Return true if the specified rectangle, after being transformed by the
491 current matrix, would lie completely outside of the current clip. Call 490 current matrix, would lie completely outside of the current clip. Call
492 this to check if an area you intend to draw into is clipped out (and 491 this to check if an area you intend to draw into is clipped out (and
493 therefore you can skip making the draw calls). 492 therefore you can skip making the draw calls).
494 @param rect the rect to compare with the current clip 493 @param rect the rect to compare with the current clip
495 @return true if the rect (transformed by the canvas' matrix) does not 494 @return true if the rect (transformed by the canvas' matrix) does not
496 intersect with the canvas' clip 495 intersect with the canvas' clip
497 */ 496 */
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // false even though it will be clipped. We have chosen to exclude that 540 // false even though it will be clipped. We have chosen to exclude that
542 // check as it is rare and would result double the comparisons. 541 // check as it is rare and would result double the comparisons.
543 return top >= clipR.fBottom || bottom <= clipR.fTop; 542 return top >= clipR.fBottom || bottom <= clipR.fTop;
544 } 543 }
545 544
546 /** Return the bounds of the current clip (in local coordinates) in the 545 /** Return the bounds of the current clip (in local coordinates) in the
547 bounds parameter, and return true if it is non-empty. This can be useful 546 bounds parameter, and return true if it is non-empty. This can be useful
548 in a way similar to quickReject, in that it tells you that drawing 547 in a way similar to quickReject, in that it tells you that drawing
549 outside of these bounds will be clipped out. 548 outside of these bounds will be clipped out.
550 */ 549 */
551 bool getClipBounds(SkRect* bounds) const; 550 virtual bool getClipBounds(SkRect* bounds) const;
552 551
553 /** Return the bounds of the current clip, in device coordinates; returns 552 /** Return the bounds of the current clip, in device coordinates; returns
554 true if non-empty. Maybe faster than getting the clip explicitly and 553 true if non-empty. Maybe faster than getting the clip explicitly and
555 then taking its bounds. 554 then taking its bounds.
556 */ 555 */
557 bool getClipDeviceBounds(SkIRect* bounds) const; 556 virtual bool getClipDeviceBounds(SkIRect* bounds) const;
558 557
559 558
560 /** Fill the entire canvas' bitmap (restricted to the current clip) with the 559 /** Fill the entire canvas' bitmap (restricted to the current clip) with the
561 specified ARGB color, using the specified mode. 560 specified ARGB color, using the specified mode.
562 @param a the alpha component (0..255) of the color to fill the canvas 561 @param a the alpha component (0..255) of the color to fill the canvas
563 @param r the red component (0..255) of the color to fill the canvas 562 @param r the red component (0..255) of the color to fill the canvas
564 @param g the green component (0..255) of the color to fill the canvas 563 @param g the green component (0..255) of the color to fill the canvas
565 @param b the blue component (0..255) of the color to fill the canvas 564 @param b the blue component (0..255) of the color to fill the canvas
566 @param mode the mode to apply the color in (defaults to SrcOver) 565 @param mode the mode to apply the color in (defaults to SrcOver)
567 */ 566 */
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1023
1025 ////////////////////////////////////////////////////////////////////////// 1024 //////////////////////////////////////////////////////////////////////////
1026 1025
1027 /** 1026 /**
1028 * Return true if the current clip is empty (i.e. nothing will draw). 1027 * Return true if the current clip is empty (i.e. nothing will draw).
1029 * Note: this is not always a free call, so it should not be used 1028 * Note: this is not always a free call, so it should not be used
1030 * more often than necessary. However, once the canvas has computed this 1029 * more often than necessary. However, once the canvas has computed this
1031 * result, subsequent calls will be cheap (until the clip state changes, 1030 * result, subsequent calls will be cheap (until the clip state changes,
1032 * which can happen on any clip..() or restore() call. 1031 * which can happen on any clip..() or restore() call.
1033 */ 1032 */
1034 bool isClipEmpty() const; 1033 virtual bool isClipEmpty() const;
1035 1034
1036 /** Return the current matrix on the canvas. 1035 /** Return the current matrix on the canvas.
1037 This does not account for the translate in any of the devices. 1036 This does not account for the translate in any of the devices.
1038 @return The current matrix on the canvas. 1037 @return The current matrix on the canvas.
1039 */ 1038 */
1040 const SkMatrix& getTotalMatrix() const; 1039 const SkMatrix& getTotalMatrix() const;
1041 1040
1042 enum ClipType { 1041 enum ClipType {
1043 kEmpty_ClipType = 0, 1042 kEmpty_ClipType = 0,
1044 kRect_ClipType, 1043 kRect_ClipType,
1045 kComplex_ClipType 1044 kComplex_ClipType
1046 }; 1045 };
1047 1046
1048 /** Returns a description of the total clip; may be cheaper than 1047 /** Returns a description of the total clip; may be cheaper than
1049 getting the clip and querying it directly. 1048 getting the clip and querying it directly.
1050 */ 1049 */
1051 ClipType getClipType() const; 1050 virtual ClipType getClipType() const;
1052 1051
1053 /** DEPRECATED -- need to move this guy to private/friend 1052 /** DEPRECATED -- need to move this guy to private/friend
1054 * Return the current device clip (concatenation of all clip calls). 1053 * Return the current device clip (concatenation of all clip calls).
1055 * This does not account for the translate in any of the devices. 1054 * This does not account for the translate in any of the devices.
1056 * @return the current device clip (concatenation of all clip calls). 1055 * @return the current device clip (concatenation of all clip calls).
1057 */ 1056 */
1058 const SkRegion& getTotalClip() const; 1057 const SkRegion& getTotalClip() const;
1059 1058
1060 /** Return the clip stack. The clip stack stores all the individual 1059 /** Return the clip stack. The clip stack stores all the individual
1061 * clips organized by the save/restore frame in which they were 1060 * clips organized by the save/restore frame in which they were
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 1122
1124 protected: 1123 protected:
1125 // default impl defers to getDevice()->newSurface(info) 1124 // default impl defers to getDevice()->newSurface(info)
1126 virtual SkSurface* onNewSurface(const SkImageInfo&); 1125 virtual SkSurface* onNewSurface(const SkImageInfo&);
1127 1126
1128 // default impl defers to its device 1127 // default impl defers to its device
1129 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes); 1128 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes);
1130 1129
1131 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); 1130 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
1132 1131
1132 enum ClipEdgeStyle {
1133 kHard_ClipEdgeStyle,
1134 kSoft_ClipEdgeStyle
1135 };
1136
1137 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle);
1138 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl e edgeStyle);
1139 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle);
1140 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op);
1141
1133 // Returns the canvas to be used by DrawIter. Default implementation 1142 // Returns the canvas to be used by DrawIter. Default implementation
1134 // returns this. Subclasses that encapsulate an indirect canvas may 1143 // returns this. Subclasses that encapsulate an indirect canvas may
1135 // need to overload this method. The impl must keep track of this, as it 1144 // need to overload this method. The impl must keep track of this, as it
1136 // is not released or deleted by the caller. 1145 // is not released or deleted by the caller.
1137 virtual SkCanvas* canvasForDrawIter(); 1146 virtual SkCanvas* canvasForDrawIter();
1138 1147
1139 // Clip rectangle bounds. Called internally by saveLayer. 1148 // Clip rectangle bounds. Called internally by saveLayer.
1140 // returns false if the entire rectangle is entirely clipped out 1149 // returns false if the entire rectangle is entirely clipped out
1141 // If non-NULL, The imageFilter parameter will be used to expand the clip 1150 // If non-NULL, The imageFilter parameter will be used to expand the clip
1142 // and offscreen bounds for any margin required by the filter DAG. 1151 // and offscreen bounds for any margin required by the filter DAG.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 bool asROBitmap(SkBitmap*) const; 1372 bool asROBitmap(SkBitmap*) const;
1364 1373
1365 private: 1374 private:
1366 SkBitmap fBitmap; // used if peekPixels() fails 1375 SkBitmap fBitmap; // used if peekPixels() fails
1367 const void* fAddr; // NULL on failure 1376 const void* fAddr; // NULL on failure
1368 SkImageInfo fInfo; 1377 SkImageInfo fInfo;
1369 size_t fRowBytes; 1378 size_t fRowBytes;
1370 }; 1379 };
1371 1380
1372 #endif 1381 #endif
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkNulCanvas.h ('k') | include/utils/SkDeferredCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698