| Index: src/gpu/GrStyle.cpp
|
| diff --git a/src/gpu/GrStyle.cpp b/src/gpu/GrStyle.cpp
|
| index 68238dded9eeedb8a2a12ea98db524333c5fc46b..3698c31ff82094f6b2fa549a3550e4d527c57b48 100644
|
| --- a/src/gpu/GrStyle.cpp
|
| +++ b/src/gpu/GrStyle.cpp
|
| @@ -11,8 +11,8 @@ int GrStyle::KeySize(const GrStyle &style, Apply apply, uint32_t flags) {
|
| GR_STATIC_ASSERT(sizeof(uint32_t) == sizeof(SkScalar));
|
| int size = 0;
|
| if (style.isDashed()) {
|
| - // One scalar for dash phase and one for each dash value.
|
| - size += 1 + style.dashIntervalCnt();
|
| + // One scalar for scale, one for dash phase, and one for each dash value.
|
| + size += 2 + style.dashIntervalCnt();
|
| } else if (style.pathEffect()) {
|
| // No key for a generic path effect.
|
| return -1;
|
| @@ -23,21 +23,29 @@ int GrStyle::KeySize(const GrStyle &style, Apply apply, uint32_t flags) {
|
| }
|
|
|
| if (style.strokeRec().needToApply()) {
|
| - // One for style/cap/join, 2 for miter and width.
|
| - size += 3;
|
| + // One for res scale, one for style/cap/join, one for miter limit, and one for width.
|
| + size += 4;
|
| }
|
| return size;
|
| }
|
|
|
| -void GrStyle::WriteKey(uint32_t *key, const GrStyle &style, Apply apply, uint32_t flags) {
|
| +void GrStyle::WriteKey(uint32_t *key, const GrStyle &style, Apply apply, SkScalar scale,
|
| + uint32_t flags) {
|
| SkASSERT(key);
|
| SkASSERT(KeySize(style, apply) >= 0);
|
| GR_STATIC_ASSERT(sizeof(uint32_t) == sizeof(SkScalar));
|
|
|
| int i = 0;
|
| + // The scale can influence both the path effect and stroking. We want to preserve the
|
| + // property that the following two are equal:
|
| + // 1. WriteKey with apply == kPathEffectAndStrokeRec
|
| + // 2. WriteKey with apply == kPathEffectOnly followed by WriteKey of a GrStyle made
|
| + // from SkStrokeRec output by the the path effect (and no additional path effect).
|
| + // Since the scale can affect both parts of 2 we write it into the key twice.
|
| if (style.isDashed()) {
|
| GR_STATIC_ASSERT(sizeof(style.dashPhase()) == sizeof(uint32_t));
|
| SkScalar phase = style.dashPhase();
|
| + memcpy(&key[i++], &scale, sizeof(SkScalar));
|
| memcpy(&key[i++], &phase, sizeof(SkScalar));
|
|
|
| int32_t count = style.dashIntervalCnt();
|
| @@ -52,6 +60,7 @@ void GrStyle::WriteKey(uint32_t *key, const GrStyle &style, Apply apply, uint32_
|
| }
|
|
|
| if (Apply::kPathEffectAndStrokeRec == apply && style.strokeRec().needToApply()) {
|
| + memcpy(&key[i++], &scale, sizeof(SkScalar));
|
| enum {
|
| kStyleBits = 2,
|
| kJoinBits = 2,
|
| @@ -123,9 +132,10 @@ static inline bool apply_path_effect(SkPath* dst, SkStrokeRec* strokeRec,
|
| }
|
|
|
| bool GrStyle::applyPathEffectToPath(SkPath *dst, SkStrokeRec *remainingStroke,
|
| - const SkPath &src) const {
|
| + const SkPath &src, SkScalar resScale) const {
|
| SkASSERT(dst);
|
| SkStrokeRec strokeRec = fStrokeRec;
|
| + strokeRec.setResScale(resScale);
|
| if (!apply_path_effect(dst, &strokeRec, fPathEffect, src)) {
|
| return false;
|
| }
|
| @@ -133,10 +143,12 @@ bool GrStyle::applyPathEffectToPath(SkPath *dst, SkStrokeRec *remainingStroke,
|
| return true;
|
| }
|
|
|
| -bool GrStyle::applyToPath(SkPath* dst, SkStrokeRec::InitStyle* style, const SkPath& src) const {
|
| +bool GrStyle::applyToPath(SkPath* dst, SkStrokeRec::InitStyle* style, const SkPath& src,
|
| + SkScalar resScale) const {
|
| SkASSERT(style);
|
| SkASSERT(dst);
|
| SkStrokeRec strokeRec = fStrokeRec;
|
| + strokeRec.setResScale(resScale);
|
| const SkPath* pathForStrokeRec = &src;
|
| if (apply_path_effect(dst, &strokeRec, fPathEffect, src)) {
|
| pathForStrokeRec = dst;
|
|
|