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

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

Issue 19775006: Implement crop rect for SkImageFilter (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix comments Created 7 years, 5 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 | « include/core/SkImageFilter.h ('k') | include/effects/SkBlurImageFilter.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkRect_DEFINED 10 #ifndef SkRect_DEFINED
11 #define SkRect_DEFINED 11 #define SkRect_DEFINED
12 12
13 #include "SkPoint.h" 13 #include "SkPoint.h"
14 #include "SkSize.h" 14 #include "SkSize.h"
15 15
16 /** \struct SkIRect 16 /** \struct SkIRect
17 17
18 SkIRect holds four 32 bit integer coordinates for a rectangle 18 SkIRect holds four 32 bit integer coordinates for a rectangle
19 */ 19 */
20 struct SK_API SkIRect { 20 struct SK_API SkIRect {
21 int32_t fLeft, fTop, fRight, fBottom; 21 int32_t fLeft, fTop, fRight, fBottom;
22 22
23 static SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() { 23 static SkIRect SK_WARN_UNUSED_RESULT MakeEmpty() {
24 SkIRect r; 24 SkIRect r;
25 r.setEmpty(); 25 r.setEmpty();
26 return r; 26 return r;
27 } 27 }
28 28
29 static SkIRect SK_WARN_UNUSED_RESULT MakeLargest() {
30 SkIRect r;
31 r.setLargest();
32 return r;
33 }
34
29 static SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h) { 35 static SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h) {
30 SkIRect r; 36 SkIRect r;
31 r.set(0, 0, w, h); 37 r.set(0, 0, w, h);
32 return r; 38 return r;
33 } 39 }
34 40
35 static SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size) { 41 static SkIRect SK_WARN_UNUSED_RESULT MakeSize(const SkISize& size) {
36 SkIRect r; 42 SkIRect r;
37 r.set(0, 0, size.width(), size.height()); 43 r.set(0, 0, size.width(), size.height());
38 return r; 44 return r;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * This is a specific "truncation" of the average, which is different than 93 * This is a specific "truncation" of the average, which is different than
88 * (bottom + top) / 2 when the sum is negative. 94 * (bottom + top) / 2 when the sum is negative.
89 */ 95 */
90 int centerY() const { return (fBottom + fTop) >> 1; } 96 int centerY() const { return (fBottom + fTop) >> 1; }
91 97
92 /** 98 /**
93 * Return true if the rectangle's width or height are <= 0 99 * Return true if the rectangle's width or height are <= 0
94 */ 100 */
95 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } 101 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
96 102
103 bool isLargest() const { return SK_MinS32 == fLeft &&
104 SK_MinS32 == fTop &&
105 SK_MaxS32 == fRight &&
106 SK_MaxS32 == fBottom; }
107
97 friend bool operator==(const SkIRect& a, const SkIRect& b) { 108 friend bool operator==(const SkIRect& a, const SkIRect& b) {
98 return !memcmp(&a, &b, sizeof(a)); 109 return !memcmp(&a, &b, sizeof(a));
99 } 110 }
100 111
101 friend bool operator!=(const SkIRect& a, const SkIRect& b) { 112 friend bool operator!=(const SkIRect& a, const SkIRect& b) {
102 return !(a == b); 113 return !(a == b);
103 } 114 }
104 115
105 bool is16Bit() const { 116 bool is16Bit() const {
106 return SkIsS16(fLeft) && SkIsS16(fTop) && 117 return SkIsS16(fLeft) && SkIsS16(fTop) &&
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 */ 781 */
771 void sort(); 782 void sort();
772 783
773 /** 784 /**
774 * cast-safe way to treat the rect as an array of (4) SkScalars. 785 * cast-safe way to treat the rect as an array of (4) SkScalars.
775 */ 786 */
776 const SkScalar* asScalars() const { return &fLeft; } 787 const SkScalar* asScalars() const { return &fLeft; }
777 }; 788 };
778 789
779 #endif 790 #endif
OLDNEW
« no previous file with comments | « include/core/SkImageFilter.h ('k') | include/effects/SkBlurImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698