aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrShape.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-05-13 09:23:38 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-13 09:23:38 -0700
commit9fb420393ee1c24fc3282b7155985fa8fa7bcad4 (patch)
tree4112171b2d2ae213d239178af89e7ce8f55d1b4d /src/gpu/GrShape.cpp
parent4ca5539df5c02fabac9ec1a8d0a0f58a9966347e (diff)
Add bounds to GrShape
Diffstat (limited to 'src/gpu/GrShape.cpp')
-rw-r--r--src/gpu/GrShape.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gpu/GrShape.cpp b/src/gpu/GrShape.cpp
index 8462d4d41d..e0ddc55e02 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();