diff options
author | 2015-05-18 23:02:07 -0700 | |
---|---|---|
committer | 2015-05-18 23:02:07 -0700 | |
commit | 50b58e6fbcc50785ceffacb2c51b22c6e67a7ab7 (patch) | |
tree | 90e4c1dbf12534523f1f7e8a1cece158bd58cb45 /src/gpu/GrPath.cpp | |
parent | 54b8511189bb5da6bfd248fa63f5c4156e9e2bd6 (diff) |
Improve caching of dashed paths in GrStencilAndCoverPathRenderer
Improve caching of dashed paths in GrStencilAndCoverPathRenderer.
Look up the (NVPR specific) GrGLPath based on GrStrokeInfo and
the original path.
Use unique keys for all GrPaths.
Dash the path with Skia dash stroker and use that path geometry for
NVPR path.
NVPR internal dashing stroke is not used, because the dashing
implementation of NVPR does not match Skia implementation.
Review URL: https://codereview.chromium.org/1116123003
Diffstat (limited to 'src/gpu/GrPath.cpp')
-rw-r--r-- | src/gpu/GrPath.cpp | 53 |
1 files changed, 9 insertions, 44 deletions
diff --git a/src/gpu/GrPath.cpp b/src/gpu/GrPath.cpp index 3a66865c6e..e76bdf2466 100644 --- a/src/gpu/GrPath.cpp +++ b/src/gpu/GrPath.cpp @@ -7,49 +7,14 @@ #include "GrPath.h" -template<int NumBits> static uint64_t get_top_n_float_bits(float f) { - char* floatData = reinterpret_cast<char*>(&f); - uint32_t floatBits = *reinterpret_cast<uint32_t*>(floatData); - return floatBits >> (32 - NumBits); -} - -void GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrUniqueKey* key) { - static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); - GrUniqueKey::Builder builder(key, kDomain, 3); - *reinterpret_cast<uint64_t*>(&builder[0]) = ComputeStrokeKey(stroke); - builder[2] = path.getGenerationID(); -} - -uint64_t GrPath::ComputeStrokeKey(const SkStrokeRec& stroke) { - enum { - kStyleBits = 2, - kJoinBits = 2, - kCapBits = 2, - kWidthBits = 29, - kMiterBits = 29, - - kJoinShift = kStyleBits, - kCapShift = kJoinShift + kJoinBits, - kWidthShift = kCapShift + kCapBits, - kMiterShift = kWidthShift + kWidthBits, - - kBitCount = kMiterShift + kMiterBits - }; - - SK_COMPILE_ASSERT(SkStrokeRec::kStyleCount <= (1 << kStyleBits), style_shift_will_be_wrong); - SK_COMPILE_ASSERT(SkPaint::kJoinCount <= (1 << kJoinBits), cap_shift_will_be_wrong); - SK_COMPILE_ASSERT(SkPaint::kCapCount <= (1 << kCapBits), miter_shift_will_be_wrong); - SK_COMPILE_ASSERT(kBitCount == 64, wrong_stroke_key_size); - - if (!stroke.needToApply()) { - return SkStrokeRec::kFill_Style; +void GrPath::ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUniqueKey* key) { + static const GrUniqueKey::Domain kPathDomain = GrUniqueKey::GenerateDomain(); + int strokeDataCnt = stroke.computeUniqueKeyFragmentData32Cnt(); + GrUniqueKey::Builder builder(key, kPathDomain, 2 + strokeDataCnt); + builder[0] = path.getGenerationID(); + builder[1] = path.getFillType(); + if (strokeDataCnt > 0) { + stroke.asUniqueKeyFragment(&builder[2]); } - - uint64_t key = stroke.getStyle(); - key |= stroke.getJoin() << kJoinShift; - key |= stroke.getCap() << kCapShift; - key |= get_top_n_float_bits<kWidthBits>(stroke.getWidth()) << kWidthShift; - key |= get_top_n_float_bits<kMiterBits>(stroke.getMiter()) << kMiterShift; - - return key; } + |