OLD | NEW |
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 SK_DEFINE_INST_COUNT(GrPath) | |
11 | |
12 GrResourceKey GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke)
{ | 10 GrResourceKey GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke)
{ |
13 static const GrResourceKey::ResourceType gPathResourceType = GrResourceKey::
GenerateResourceType(); | 11 static const GrResourceKey::ResourceType gPathResourceType = GrResourceKey::
GenerateResourceType(); |
14 static const GrCacheID::Domain gPathDomain = GrCacheID::GenerateDomain(); | 12 static const GrCacheID::Domain gPathDomain = GrCacheID::GenerateDomain(); |
15 | 13 |
16 GrCacheID::Key key; | 14 GrCacheID::Key key; |
17 uint32_t* keyData = key.fData32; | 15 uint32_t* keyData = key.fData32; |
18 keyData[0] = path.getGenerationID(); | 16 keyData[0] = path.getGenerationID(); |
19 | 17 |
20 SK_COMPILE_ASSERT(SkPaint::kJoinCount <= 3, cap_shift_will_be_wrong); | 18 SK_COMPILE_ASSERT(SkPaint::kJoinCount <= 3, cap_shift_will_be_wrong); |
21 keyData[1] = stroke.needToApply(); | 19 keyData[1] = stroke.needToApply(); |
22 if (0 != keyData[1]) { | 20 if (0 != keyData[1]) { |
23 keyData[1] |= stroke.getJoin() << 1; | 21 keyData[1] |= stroke.getJoin() << 1; |
24 keyData[1] |= stroke.getCap() << 3; | 22 keyData[1] |= stroke.getCap() << 3; |
25 keyData[2] = static_cast<uint32_t>(stroke.getMiter()); | 23 keyData[2] = static_cast<uint32_t>(stroke.getMiter()); |
26 keyData[3] = static_cast<uint32_t>(stroke.getWidth()); | 24 keyData[3] = static_cast<uint32_t>(stroke.getWidth()); |
27 } else { | 25 } else { |
28 keyData[2] = 0; | 26 keyData[2] = 0; |
29 keyData[3] = 0; | 27 keyData[3] = 0; |
30 } | 28 } |
31 | 29 |
32 return GrResourceKey(GrCacheID(gPathDomain, key), gPathResourceType, 0); | 30 return GrResourceKey(GrCacheID(gPathDomain, key), gPathResourceType, 0); |
33 } | 31 } |
OLD | NEW |