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

Unified Diff: src/gpu/GrShape.h

Issue 1929643002: Detect empty (r)rects in GrShape. (Closed) Base URL: https://chromium.googlesource.com/skia.git@volatileshape
Patch Set: a->an Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/GrShapeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrShape.h
diff --git a/src/gpu/GrShape.h b/src/gpu/GrShape.h
index 57b1d8a9bf06af2ee1bd542497824ee4efdcd215..0e863e2c6e9167368f98523ab8a11e25dc917c3a 100644
--- a/src/gpu/GrShape.h
+++ b/src/gpu/GrShape.h
@@ -33,16 +33,25 @@
*/
class GrShape {
public:
- GrShape(const SkPath& path)
+ GrShape() : fType(Type::kEmpty) {}
+
+ explicit GrShape(const SkPath& path)
: fType(Type::kPath)
, fPath(&path) {
this->attemptToReduceFromPath();
}
- GrShape() : fType(Type::kEmpty) {}
+ explicit GrShape(const SkRRect& rrect)
+ : fType(Type::kRRect)
+ , fRRect(rrect) {
+ this->attemptToReduceFromRRect();
+ }
- explicit GrShape(const SkRRect& rrect) : fType(Type::kRRect), fRRect(rrect) {}
- explicit GrShape(const SkRect& rect) : fType(Type::kRRect), fRRect(SkRRect::MakeRect(rect)) {}
+ explicit GrShape(const SkRect& rect)
+ : fType(Type::kRRect)
+ , fRRect(SkRRect::MakeRect(rect)) {
+ this->attemptToReduceFromRRect();
+ }
GrShape(const SkPath& path, const GrStyle& style)
: fType(Type::kPath)
@@ -54,12 +63,16 @@ public:
GrShape(const SkRRect& rrect, const GrStyle& style)
: fType(Type::kRRect)
, fRRect(rrect)
- , fStyle(style) {}
+ , fStyle(style) {
+ this->attemptToReduceFromRRect();
+ }
GrShape(const SkRect& rect, const GrStyle& style)
: fType(Type::kRRect)
, fRRect(SkRRect::MakeRect(rect))
- , fStyle(style) {}
+ , fStyle(style) {
+ this->attemptToReduceFromRRect();
+ }
GrShape(const SkPath& path, const SkPaint& paint)
: fType(Type::kPath)
@@ -71,12 +84,16 @@ public:
GrShape(const SkRRect& rrect, const SkPaint& paint)
: fType(Type::kRRect)
, fRRect(rrect)
- , fStyle(paint) {}
+ , fStyle(paint) {
+ this->attemptToReduceFromRRect();
+ }
GrShape(const SkRect& rect, const SkPaint& paint)
: fType(Type::kRRect)
, fRRect(SkRRect::MakeRect(rect))
- , fStyle(paint) {}
+ , fStyle(paint) {
+ this->attemptToReduceFromRRect();
+ }
GrShape(const GrShape&);
GrShape& operator=(const GrShape& that);
@@ -182,12 +199,21 @@ private:
}
}
+ void attemptToReduceFromRRect() {
+ SkASSERT(Type::kRRect == fType);
+ SkASSERT(!fInheritedKey.count());
+ if (fRRect.isEmpty()) {
+ fType = Type::kEmpty;
+ }
+ }
+
static Type AttemptToReduceFromPathImpl(const SkPath& path, SkRRect* rrect,
const SkPathEffect* pe, const SkStrokeRec& strokeRec) {
if (path.isEmpty()) {
return Type::kEmpty;
}
if (path.isRRect(rrect)) {
+ SkASSERT(!rrect->isEmpty());
return Type::kRRect;
}
SkRect rect;
« no previous file with comments | « no previous file | tests/GrShapeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698