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

Side by Side Diff: src/gpu/GrShape.h

Issue 1971613004: Add isEmpty() query to GrShape and improve comments. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | tests/GrShapeTest.cpp » ('j') | tests/GrShapeTest.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
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 GrShape_DEFINED 8 #ifndef GrShape_DEFINED
9 #define GrShape_DEFINED 9 #define GrShape_DEFINED
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 /** 109 /**
110 * Returns a shape that has either applied the path effect or path effect an d stroking 110 * Returns a shape that has either applied the path effect or path effect an d stroking
111 * information from this shape's style to its geometry. Scale is used when a pproximating the 111 * information from this shape's style to its geometry. Scale is used when a pproximating the
112 * output geometry and typically is computed from the view matrix 112 * output geometry and typically is computed from the view matrix
113 */ 113 */
114 GrShape applyStyle(GrStyle::Apply apply, SkScalar scale) { 114 GrShape applyStyle(GrStyle::Apply apply, SkScalar scale) {
115 return GrShape(*this, apply, scale); 115 return GrShape(*this, apply, scale);
116 } 116 }
117 117
118 /** Returns the unstyled geometry as a rrect if possible. */
118 bool asRRect(SkRRect* rrect) const { 119 bool asRRect(SkRRect* rrect) const {
119 if (Type::kRRect != fType) { 120 if (Type::kRRect != fType) {
120 return false; 121 return false;
121 } 122 }
122 if (rrect) { 123 if (rrect) {
123 *rrect = fRRect; 124 *rrect = fRRect;
124 } 125 }
125 return true; 126 return true;
126 } 127 }
127 128
129 /** Returns the unstyled geometry as a path. */
128 void asPath(SkPath* out) const { 130 void asPath(SkPath* out) const {
129 switch (fType) { 131 switch (fType) {
130 case Type::kEmpty: 132 case Type::kEmpty:
131 out->reset(); 133 out->reset();
132 break; 134 break;
133 case Type::kRRect: 135 case Type::kRRect:
134 out->reset(); 136 out->reset();
135 out->addRRect(fRRect); 137 out->addRRect(fRRect);
136 break; 138 break;
137 case Type::kPath: 139 case Type::kPath:
138 *out = *fPath.get(); 140 *out = *fPath.get();
139 break; 141 break;
140 } 142 }
141 } 143 }
142 144
143 /** 145 /**
144 * Is it known that the shape has no unclosed contours. This means that it w ill not have 146 * Returns whether the geometry is empty. Note that applying the style could produce a
145 * any caps if stroked (modulo the effect of any path effect). 147 * non-empty shape.
148 */
149 bool isEmpty() const { return Type::kEmpty == fType; }
150
151 /**
152 * Is it known that the unstyled geometry has no unclosed contours. This mea ns that it will
153 * not have any caps if stroked (modulo the effect of any path effect).
146 */ 154 */
147 bool knownToBeClosed() const { 155 bool knownToBeClosed() const {
148 switch (fType) { 156 switch (fType) {
149 case Type::kEmpty: 157 case Type::kEmpty:
150 return true; 158 return true;
151 case Type::kRRect: 159 case Type::kRRect:
152 return true; 160 return true;
153 case Type::kPath: 161 case Type::kPath:
154 return false; 162 return false;
155 } 163 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return Type::kPath; 236 return Type::kPath;
229 } 237 }
230 238
231 Type fType; 239 Type fType;
232 SkRRect fRRect; 240 SkRRect fRRect;
233 SkTLazy<SkPath> fPath; 241 SkTLazy<SkPath> fPath;
234 GrStyle fStyle; 242 GrStyle fStyle;
235 SkAutoSTArray<8, uint32_t> fInheritedKey; 243 SkAutoSTArray<8, uint32_t> fInheritedKey;
236 }; 244 };
237 #endif 245 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/GrShapeTest.cpp » ('j') | tests/GrShapeTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698