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

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

Issue 815833004: Add a simpler key type for scratch resource keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: final fix Created 5 years, 11 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
« no previous file with comments | « src/gpu/GrGpuResourceCacheAccess.h ('k') | src/gpu/GrPathRange.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 template<int NumBits> static uint64_t get_top_n_float_bits(float f) {
11 char* floatData = reinterpret_cast<char*>(&f); 11 char* floatData = reinterpret_cast<char*>(&f);
12 uint32_t floatBits = *reinterpret_cast<uint32_t*>(floatData); 12 uint32_t floatBits = *reinterpret_cast<uint32_t*>(floatData);
13 return floatBits >> (32 - NumBits); 13 return floatBits >> (32 - NumBits);
14 } 14 }
15 15
16 GrResourceKey GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke) { 16 GrResourceKey GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke) {
17 static const GrResourceKey::ResourceType gPathResourceType = GrResourceKey:: GenerateResourceType();
18 static const GrCacheID::Domain gPathDomain = GrCacheID::GenerateDomain(); 17 static const GrCacheID::Domain gPathDomain = GrCacheID::GenerateDomain();
19 18
20 GrCacheID::Key key; 19 GrCacheID::Key key;
21 uint64_t* keyData = key.fData64; 20 uint64_t* keyData = key.fData64;
22 keyData[0] = path.getGenerationID(); 21 keyData[0] = path.getGenerationID();
23 keyData[1] = ComputeStrokeKey(stroke); 22 keyData[1] = ComputeStrokeKey(stroke);
24 23
25 return GrResourceKey(GrCacheID(gPathDomain, key), gPathResourceType, 0); 24 return GrResourceKey(GrCacheID(gPathDomain, key), 0);
26 } 25 }
27 26
28 uint64_t GrPath::ComputeStrokeKey(const SkStrokeRec& stroke) { 27 uint64_t GrPath::ComputeStrokeKey(const SkStrokeRec& stroke) {
29 enum { 28 enum {
30 kStyleBits = 2, 29 kStyleBits = 2,
31 kJoinBits = 2, 30 kJoinBits = 2,
32 kCapBits = 2, 31 kCapBits = 2,
33 kWidthBits = 29, 32 kWidthBits = 29,
34 kMiterBits = 29, 33 kMiterBits = 29,
35 34
(...skipping 15 matching lines...) Expand all
51 } 50 }
52 51
53 uint64_t key = stroke.getStyle(); 52 uint64_t key = stroke.getStyle();
54 key |= stroke.getJoin() << kJoinShift; 53 key |= stroke.getJoin() << kJoinShift;
55 key |= stroke.getCap() << kCapShift; 54 key |= stroke.getCap() << kCapShift;
56 key |= get_top_n_float_bits<kWidthBits>(stroke.getWidth()) << kWidthShift; 55 key |= get_top_n_float_bits<kWidthBits>(stroke.getWidth()) << kWidthShift;
57 key |= get_top_n_float_bits<kMiterBits>(stroke.getMiter()) << kMiterShift; 56 key |= get_top_n_float_bits<kMiterBits>(stroke.getMiter()) << kMiterShift;
58 57
59 return key; 58 return key;
60 } 59 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpuResourceCacheAccess.h ('k') | src/gpu/GrPathRange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698