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

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: more cleanup 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 @param op The region op to apply to the current clip 441 @param op The region op to apply to the current clip
442 @return true if the canvas' new clip is non-empty 442 @return true if the canvas' new clip is non-empty
443 */ 443 */
444 virtual bool clipRegion(const SkRegion& deviceRgn, 444 virtual bool clipRegion(const SkRegion& deviceRgn,
445 SkRegion::Op op = SkRegion::kIntersect_Op); 445 SkRegion::Op op = SkRegion::kIntersect_Op);
446 446
447 /** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the 447 /** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the
448 specified region. This does not intersect or in any other way account 448 specified region. This does not intersect or in any other way account
449 for the existing clip region. 449 for the existing clip region.
450 @param deviceRgn The region to copy into the current clip. 450 @param deviceRgn The region to copy into the current clip.
451 @return true if the new clip region is non-empty
452 */ 451 */
453 bool setClipRegion(const SkRegion& deviceRgn) { 452 void setClipRegion(const SkRegion& deviceRgn) {
454 return this->clipRegion(deviceRgn, SkRegion::kReplace_Op); 453 this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
455 } 454 }
456 455
457 /** Return true if the specified rectangle, after being transformed by the 456 /** Return true if the specified rectangle, after being transformed by the
458 current matrix, would lie completely outside of the current clip. Call 457 current matrix, would lie completely outside of the current clip. Call
459 this to check if an area you intend to draw into is clipped out (and 458 this to check if an area you intend to draw into is clipped out (and
460 therefore you can skip making the draw calls). 459 therefore you can skip making the draw calls).
461 @param rect the rect to compare with the current clip 460 @param rect the rect to compare with the current clip
462 @return true if the rect (transformed by the canvas' matrix) does not 461 @return true if the rect (transformed by the canvas' matrix) does not
463 intersect with the canvas' clip 462 intersect with the canvas' clip
464 */ 463 */
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 971
973 ////////////////////////////////////////////////////////////////////////// 972 //////////////////////////////////////////////////////////////////////////
974 973
975 /** 974 /**
976 * Return true if the current clip is empty (i.e. nothing will draw). 975 * Return true if the current clip is empty (i.e. nothing will draw).
977 * Note: this is not always a free call, so it should not be used 976 * Note: this is not always a free call, so it should not be used
978 * more often than necessary. However, once the canvas has computed this 977 * more often than necessary. However, once the canvas has computed this
979 * result, subsequent calls will be cheap (until the clip state changes, 978 * result, subsequent calls will be cheap (until the clip state changes,
980 * which can happen on any clip..() or restore() call. 979 * which can happen on any clip..() or restore() call.
981 */ 980 */
982 bool isClipEmpty() const; 981 virtual bool isClipEmpty() const;
reed1 2014/02/27 18:43:50 Why does this need to be virtual, but not (also) g
robertphillips 2014/02/27 20:20:30 I learned about a new canvas entry point today. Pl
983 982
984 /** Return the current matrix on the canvas. 983 /** Return the current matrix on the canvas.
985 This does not account for the translate in any of the devices. 984 This does not account for the translate in any of the devices.
986 @return The current matrix on the canvas. 985 @return The current matrix on the canvas.
987 */ 986 */
988 const SkMatrix& getTotalMatrix() const; 987 const SkMatrix& getTotalMatrix() const;
989 988
990 enum ClipType { 989 enum ClipType {
991 kEmpty_ClipType = 0, 990 kEmpty_ClipType = 0,
992 kRect_ClipType, 991 kRect_ClipType,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 1070
1072 protected: 1071 protected:
1073 // default impl defers to getDevice()->newSurface(info) 1072 // default impl defers to getDevice()->newSurface(info)
1074 virtual SkSurface* onNewSurface(const SkImageInfo&); 1073 virtual SkSurface* onNewSurface(const SkImageInfo&);
1075 1074
1076 // default impl defers to its device 1075 // default impl defers to its device
1077 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes); 1076 virtual const void* onPeekPixels(SkImageInfo*, size_t* rowBytes);
1078 1077
1079 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); 1078 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
1080 1079
1080 enum ClipEdgeStyle {
1081 kHard_ClipEdgeStyle,
1082 kSoft_ClipEdgeStyle
1083 };
1084
1085 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle);
1086 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl e edgeStyle);
1087 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle);
1088 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op);
1089
1081 // Returns the canvas to be used by DrawIter. Default implementation 1090 // Returns the canvas to be used by DrawIter. Default implementation
1082 // returns this. Subclasses that encapsulate an indirect canvas may 1091 // returns this. Subclasses that encapsulate an indirect canvas may
1083 // need to overload this method. The impl must keep track of this, as it 1092 // need to overload this method. The impl must keep track of this, as it
1084 // is not released or deleted by the caller. 1093 // is not released or deleted by the caller.
1085 virtual SkCanvas* canvasForDrawIter(); 1094 virtual SkCanvas* canvasForDrawIter();
1086 1095
1087 // Clip rectangle bounds. Called internally by saveLayer. 1096 // Clip rectangle bounds. Called internally by saveLayer.
1088 // returns false if the entire rectangle is entirely clipped out 1097 // returns false if the entire rectangle is entirely clipped out
1089 // If non-NULL, The imageFilter parameter will be used to expand the clip 1098 // If non-NULL, The imageFilter parameter will be used to expand the clip
1090 // and offscreen bounds for any margin required by the filter DAG. 1099 // and offscreen bounds for any margin required by the filter DAG.
1091 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, 1100 bool clipRectBounds(const SkRect* bounds, SaveFlags flags,
1092 SkIRect* intersection, 1101 SkIRect* intersection,
1093 const SkImageFilter* imageFilter = NULL); 1102 const SkImageFilter* imageFilter = NULL);
1094 1103
1095 // Called by child classes that override clipPath and clipRRect to only 1104 // Called by child classes that override clipPath and clipRRect to only
1096 // track fast conservative clip bounds, rather than exact clips. 1105 // track fast conservative clip bounds, rather than exact clips.
1097 bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, 1106 void updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op,
1098 bool inverseFilled); 1107 bool inverseFilled);
1099 1108
1100 // notify our surface (if we have one) that we are about to draw, so it 1109 // notify our surface (if we have one) that we are about to draw, so it
1101 // can perform copy-on-write or invalidate any cached images 1110 // can perform copy-on-write or invalidate any cached images
1102 void predrawNotify(); 1111 void predrawNotify();
1103 1112
1104 private: 1113 private:
1105 class MCRec; 1114 class MCRec;
1106 1115
1107 SkClipStack fClipStack; 1116 SkClipStack fClipStack;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 bool asROBitmap(SkBitmap*) const; 1309 bool asROBitmap(SkBitmap*) const;
1301 1310
1302 private: 1311 private:
1303 SkBitmap fBitmap; // used if peekPixels() fails 1312 SkBitmap fBitmap; // used if peekPixels() fails
1304 const void* fAddr; // NULL on failure 1313 const void* fAddr; // NULL on failure
1305 SkImageInfo fInfo; 1314 SkImageInfo fInfo;
1306 size_t fRowBytes; 1315 size_t fRowBytes;
1307 }; 1316 };
1308 1317
1309 #endif 1318 #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