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

Side by Side Diff: src/gpu/GrPath.cpp

Issue 1116123003: Improve caching of dashed paths in GrStencilAndCoverPathRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@dashing-nvpr-01
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrPath.h" 8 #include "GrPath.h"
9 9
10 template<int NumBits> static uint64_t get_top_n_float_bits(float f) { 10 void GrPath::ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUnique Key* key) {
11 char* floatData = reinterpret_cast<char*>(&f); 11 static const GrUniqueKey::Domain kPathDomain = GrUniqueKey::GenerateDomain() ;
12 uint32_t floatBits = *reinterpret_cast<uint32_t*>(floatData); 12 GrUniqueKey::Builder builder(key, kPathDomain,
13 return floatBits >> (32 - NumBits); 13 2 + stroke.computeUniqueKeyFragmentData32Cnt()) ;
14 builder[0] = path.getGenerationID();
15 builder[1] = path.getFillType();
16 stroke.asUniqueKeyFragment(&builder[2]);
egdaniel 2015/05/15 15:28:53 We should probably Assert here the computeUniqueKe
Kimmo Kinnunen 2015/05/18 06:48:40 Hmm. I expect you hint at the Builder operator[] a
egdaniel 2015/05/18 13:43:46 Yeah it was the builder[2] that I was worried abou
14 } 17 }
15 18
16 void GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrUniqueK ey* key) {
17 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
18 GrUniqueKey::Builder builder(key, kDomain, 3);
19 *reinterpret_cast<uint64_t*>(&builder[0]) = ComputeStrokeKey(stroke);
20 builder[2] = path.getGenerationID();
21 }
22
23 uint64_t GrPath::ComputeStrokeKey(const SkStrokeRec& stroke) {
24 enum {
25 kStyleBits = 2,
26 kJoinBits = 2,
27 kCapBits = 2,
28 kWidthBits = 29,
29 kMiterBits = 29,
30
31 kJoinShift = kStyleBits,
32 kCapShift = kJoinShift + kJoinBits,
33 kWidthShift = kCapShift + kCapBits,
34 kMiterShift = kWidthShift + kWidthBits,
35
36 kBitCount = kMiterShift + kMiterBits
37 };
38
39 SK_COMPILE_ASSERT(SkStrokeRec::kStyleCount <= (1 << kStyleBits), style_shift _will_be_wrong);
40 SK_COMPILE_ASSERT(SkPaint::kJoinCount <= (1 << kJoinBits), cap_shift_will_be _wrong);
41 SK_COMPILE_ASSERT(SkPaint::kCapCount <= (1 << kCapBits), miter_shift_will_be _wrong);
42 SK_COMPILE_ASSERT(kBitCount == 64, wrong_stroke_key_size);
43
44 if (!stroke.needToApply()) {
45 return SkStrokeRec::kFill_Style;
46 }
47
48 uint64_t key = stroke.getStyle();
49 key |= stroke.getJoin() << kJoinShift;
50 key |= stroke.getCap() << kCapShift;
51 key |= get_top_n_float_bits<kWidthBits>(stroke.getWidth()) << kWidthShift;
52 key |= get_top_n_float_bits<kMiterBits>(stroke.getMiter()) << kMiterShift;
53
54 return key;
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698