1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/gpu/GrPath.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +/* 1.5 + * Copyright 2012 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#include "GrPath.h" 1.12 + 1.13 +GrResourceKey GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke) { 1.14 + static const GrResourceKey::ResourceType gPathResourceType = GrResourceKey::GenerateResourceType(); 1.15 + static const GrCacheID::Domain gPathDomain = GrCacheID::GenerateDomain(); 1.16 + 1.17 + GrCacheID::Key key; 1.18 + uint32_t* keyData = key.fData32; 1.19 + keyData[0] = path.getGenerationID(); 1.20 + 1.21 + SK_COMPILE_ASSERT(SkPaint::kJoinCount <= 3, cap_shift_will_be_wrong); 1.22 + keyData[1] = stroke.needToApply(); 1.23 + if (0 != keyData[1]) { 1.24 + keyData[1] |= stroke.getJoin() << 1; 1.25 + keyData[1] |= stroke.getCap() << 3; 1.26 + keyData[2] = static_cast<uint32_t>(stroke.getMiter()); 1.27 + keyData[3] = static_cast<uint32_t>(stroke.getWidth()); 1.28 + } else { 1.29 + keyData[2] = 0; 1.30 + keyData[3] = 0; 1.31 + } 1.32 + 1.33 + return GrResourceKey(GrCacheID(gPathDomain, key), gPathResourceType, 0); 1.34 +}