aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrShape.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-08-31 13:27:15 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-31 18:14:21 +0000
commitd5a3f7f9673a152928332a38e53a5fc55f590f40 (patch)
tree044a846a2f3755e5bfa47ea22335c9df61b10d64 /src/gpu/GrShape.cpp
parent5d303ed44b611708784f7b05cfa35a270c8d0c09 (diff)
Add a GrShape::Type value for an inverted empty path
Change-Id: Ib34a608db07a2ff1d7bdfbd96867fa5ff0ac9782 Reviewed-on: https://skia-review.googlesource.com/41540 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrShape.cpp')
-rw-r--r--src/gpu/GrShape.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/gpu/GrShape.cpp b/src/gpu/GrShape.cpp
index eb07ffc558..221247808b 100644
--- a/src/gpu/GrShape.cpp
+++ b/src/gpu/GrShape.cpp
@@ -13,6 +13,8 @@ GrShape& GrShape::operator=(const GrShape& that) {
switch (fType) {
case Type::kEmpty:
break;
+ case Type::kInvertedEmpty:
+ break;
case Type::kRRect:
fRRectData = that.fRRectData;
break;
@@ -36,6 +38,8 @@ SkRect GrShape::bounds() const {
switch (fType) {
case Type::kEmpty:
return kInverted;
+ case Type::kInvertedEmpty:
+ return kInverted;
case Type::kLine: {
SkRect bounds;
if (fLineData.fPts[0].fX < fLineData.fPts[1].fX) {
@@ -64,9 +68,10 @@ SkRect GrShape::bounds() const {
}
SkRect GrShape::styledBounds() const {
- if (Type::kEmpty == fType && !fStyle.hasNonDashPathEffect()) {
+ if (this->isEmpty() && !fStyle.hasNonDashPathEffect()) {
return SkRect::MakeEmpty();
}
+
SkRect bounds;
fStyle.adjustBounds(&bounds, this->bounds());
return bounds;
@@ -122,6 +127,8 @@ int GrShape::unstyledKeySize() const {
switch (fType) {
case Type::kEmpty:
return 1;
+ case Type::kInvertedEmpty:
+ return 1;
case Type::kRRect:
SkASSERT(!fInheritedKey.count());
SkASSERT(0 == SkRRect::kSizeInMemory % sizeof(uint32_t));
@@ -158,6 +165,9 @@ void GrShape::writeUnstyledKey(uint32_t* key) const {
case Type::kEmpty:
*key++ = 1;
break;
+ case Type::kInvertedEmpty:
+ *key++ = 2;
+ break;
case Type::kRRect:
fRRectData.fRRect.writeToMemory(key);
key += SkRRect::kSizeInMemory / sizeof(uint32_t);
@@ -244,6 +254,8 @@ GrShape::GrShape(const GrShape& that) : fStyle(that.fStyle) {
switch (fType) {
case Type::kEmpty:
break;
+ case Type::kInvertedEmpty:
+ break;
case Type::kRRect:
fRRectData = that.fRRectData;
break;
@@ -354,7 +366,9 @@ void GrShape::attemptToSimplifyPath() {
bool inverted = this->path().isInverseFillType();
SkPoint pts[2];
if (this->path().isEmpty()) {
- this->changeType(Type::kEmpty);
+ // Dashing ignores inverseness skbug.com/5421.
+ this->changeType(inverted && !this->style().isDashed() ? Type::kInvertedEmpty
+ : Type::kEmpty);
} else if (this->path().isLine(pts)) {
this->changeType(Type::kLine);
fLineData.fPts[0] = pts[0];
@@ -442,7 +456,8 @@ void GrShape::attemptToSimplifyRRect() {
SkASSERT(Type::kRRect == fType);
SkASSERT(!fInheritedKey.count());
if (fRRectData.fRRect.isEmpty()) {
- fType = Type::kEmpty;
+ // Dashing ignores the inverseness currently. skbug.com/5421
+ fType = fRRectData.fInverted && !fStyle.isDashed() ? Type::kInvertedEmpty : Type::kEmpty;
return;
}
if (!this->style().hasPathEffect()) {
@@ -480,8 +495,8 @@ void GrShape::attemptToSimplifyLine() {
rec.setStrokeStyle(fStyle.strokeRec().getWidth(), false);
fStyle = GrStyle(rec, nullptr);
}
- if (fStyle.isSimpleFill() && !fLineData.fInverted) {
- this->changeType(Type::kEmpty);
+ if (fStyle.isSimpleFill()) {
+ this->changeType(fLineData.fInverted ? Type::kInvertedEmpty : Type::kEmpty);
return;
}
SkPoint* pts = fLineData.fPts;
@@ -525,7 +540,7 @@ void GrShape::attemptToSimplifyLine() {
fRRectData.fStart = kDefaultRRectStart;
if (fRRectData.fRRect.isEmpty()) {
// This can happen when r is very small relative to the rect edges.
- this->changeType(Type::kEmpty);
+ this->changeType(inverted ? Type::kInvertedEmpty : Type::kEmpty);
return;
}
fStyle = GrStyle::SimpleFill();