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

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

Issue 947443003: Move clip off of draw target (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 5 years, 10 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
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrClip.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 SkRect_DEFINED 8 #ifndef SkRect_DEFINED
9 #define SkRect_DEFINED 9 #define SkRect_DEFINED
10 10
11 #include "SkPoint.h" 11 #include "SkPoint.h"
12 #include "SkSize.h" 12 #include "SkSize.h"
13 13
14 struct SkRect;
15
14 /** \struct SkIRect 16 /** \struct SkIRect
15 17
16 SkIRect holds four 32 bit integer coordinates for a rectangle 18 SkIRect holds four 32 bit integer coordinates for a rectangle
17 */ 19 */
18 struct SK_API SkIRect { 20 struct SK_API SkIRect {
19 int32_t fLeft, fTop, fRight, fBottom; 21 int32_t fLeft, fTop, fRight, fBottom;
20 22
21 static SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() { 23 static SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() {
22 SkIRect r; 24 SkIRect r;
23 r.setEmpty(); 25 r.setEmpty();
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 239 }
238 240
239 /** Returns true if the specified rectangle r is inside or equal to this rec tangle. 241 /** Returns true if the specified rectangle r is inside or equal to this rec tangle.
240 */ 242 */
241 bool contains(const SkIRect& r) const { 243 bool contains(const SkIRect& r) const {
242 return !r.isEmpty() && !this->isEmpty() && // check for empties 244 return !r.isEmpty() && !this->isEmpty() && // check for empties
243 fLeft <= r.fLeft && fTop <= r.fTop && 245 fLeft <= r.fLeft && fTop <= r.fTop &&
244 fRight >= r.fRight && fBottom >= r.fBottom; 246 fRight >= r.fRight && fBottom >= r.fBottom;
245 } 247 }
246 248
249 /** Returns true if the specified rectangle r is inside or equal to this rec tangle.
250 */
251 bool contains(const SkRect& r) const;
252
247 /** Return true if this rectangle contains the specified rectangle. 253 /** Return true if this rectangle contains the specified rectangle.
248 For speed, this method does not check if either this or the specified 254 For speed, this method does not check if either this or the specified
249 rectangles are empty, and if either is, its return value is undefined. 255 rectangles are empty, and if either is, its return value is undefined.
250 In the debugging build however, we assert that both this and the 256 In the debugging build however, we assert that both this and the
251 specified rectangles are non-empty. 257 specified rectangles are non-empty.
252 */ 258 */
253 bool containsNoEmptyCheck(int32_t left, int32_t top, 259 bool containsNoEmptyCheck(int32_t left, int32_t top,
254 int32_t right, int32_t bottom) const { 260 int32_t right, int32_t bottom) const {
255 SkASSERT(fLeft < fRight && fTop < fBottom); 261 SkASSERT(fLeft < fRight && fTop < fBottom);
256 SkASSERT(left < right && top < bottom); 262 SkASSERT(left < right && top < bottom);
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 /** 879 /**
874 * cast-safe way to treat the rect as an array of (4) SkScalars. 880 * cast-safe way to treat the rect as an array of (4) SkScalars.
875 */ 881 */
876 const SkScalar* asScalars() const { return &fLeft; } 882 const SkScalar* asScalars() const { return &fLeft; }
877 883
878 void dump(bool asHex) const; 884 void dump(bool asHex) const;
879 void dump() const { this->dump(false); } 885 void dump() const { this->dump(false); }
880 void dumpHex() const { this->dump(true); } 886 void dumpHex() const { this->dump(true); }
881 }; 887 };
882 888
889 inline bool SkIRect::contains(const SkRect& r) const {
890 return !r.isEmpty() && !this->isEmpty() && // check for empties
891 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop &&
892 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom;
893 }
894
883 #endif 895 #endif
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrClip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698