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

Unified Diff: src/gpu/GrShape.cpp

Issue 1970003003: Add bounds to GrShape (Closed) Base URL: https://chromium.googlesource.com/skia.git@grshapeisempty
Patch Set: put back const& 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
« no previous file with comments | « src/gpu/GrShape.h ('k') | src/gpu/GrStyle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrShape.cpp
diff --git a/src/gpu/GrShape.cpp b/src/gpu/GrShape.cpp
index 8462d4d41db6c3365d9145d288f7fc4fc8bb8f26..e0ddc55e028e2a1b1ce24be5bd831dc9ea4d0620 100644
--- a/src/gpu/GrShape.cpp
+++ b/src/gpu/GrShape.cpp
@@ -37,6 +37,28 @@ GrShape& GrShape::operator=(const GrShape& that) {
return *this;
}
+const SkRect& GrShape::bounds() const {
+ static constexpr SkRect kEmpty = SkRect::MakeEmpty();
+ switch (fType) {
+ case Type::kEmpty:
+ return kEmpty;
+ case Type::kRRect:
+ return fRRect.getBounds();
+ case Type::kPath:
+ return fPath.get()->getBounds();
+ }
+ SkFAIL("Unknown shape type");
+ return kEmpty;
+}
+
+void GrShape::styledBounds(SkRect* bounds) const {
+ if (Type::kEmpty == fType && !fStyle.hasNonDashPathEffect()) {
+ *bounds = SkRect::MakeEmpty();
+ } else {
+ fStyle.adjustBounds(bounds, this->bounds());
+ }
+}
+
int GrShape::unstyledKeySize() const {
if (fInheritedKey.count()) {
return fInheritedKey.count();
« no previous file with comments | « src/gpu/GrShape.h ('k') | src/gpu/GrStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698