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

Unified Diff: src/gpu/GrShape.cpp

Issue 1970003003: Add bounds to GrShape (Closed) Base URL: https://chromium.googlesource.com/skia.git@grshapeisempty
Patch Set: minor 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrShape.cpp
diff --git a/src/gpu/GrShape.cpp b/src/gpu/GrShape.cpp
index 8462d4d41db6c3365d9145d288f7fc4fc8bb8f26..ef923cf8b9088c31d03328fa51c2927e2f8c4266 100644
--- a/src/gpu/GrShape.cpp
+++ b/src/gpu/GrShape.cpp
@@ -37,6 +37,26 @@ GrShape& GrShape::operator=(const GrShape& that) {
return *this;
}
+const SkRect& GrShape::bounds() {
+ static constexpr SkRect kEmpty = SkRect::MakeEmpty();
+ switch (fType) {
+ case Type::kEmpty:
robertphillips 2016/05/12 17:18:47 Why not just return SkRect::MakeEmpty here ?
bsalomon 2016/05/12 18:37:57 Becausethe return is a const& to a SkRect, so I ca
+ return kEmpty;
+ case Type::kRRect:
+ return fRRect.getBounds();
+ case Type::kPath:
+ return fPath.get()->getBounds();
+ }
+}
+
+void GrShape::styledBounds(SkRect* bounds) {
+ if (Type::kEmpty == fType && !fStyle.hasNonDashPathEffect()) {
robertphillips 2016/05/12 17:18:47 Is it an empty path or a path with a single point
+ *bounds = SkRect::MakeEmpty();
+ } else {
+ fStyle.adjustBounds(bounds, this->bounds());
+ }
+}
+
int GrShape::unstyledKeySize() const {
if (fInheritedKey.count()) {
return fInheritedKey.count();

Powered by Google App Engine
This is Rietveld 408576698