aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPath.cpp
blob: f928dffaa85c950a234dd23c9992937a98f12933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "GrPath.h"

SK_DEFINE_INST_COUNT(GrPath)

GrResourceKey GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke) {
    static const GrResourceKey::ResourceType gPathResourceType = GrResourceKey::GenerateResourceType();
    static const GrCacheID::Domain gPathDomain = GrCacheID::GenerateDomain();

    GrCacheID::Key key;
    uint32_t* keyData = key.fData32;
    keyData[0] = path.getGenerationID();

    SK_COMPILE_ASSERT(SkPaint::kJoinCount <= 3, cap_shift_will_be_wrong);
    keyData[1] = stroke.needToApply();
    if (0 != keyData[1]) {
        keyData[1] |= stroke.getJoin() << 1;
        keyData[1] |= stroke.getCap() << 3;
        keyData[2] = static_cast<uint32_t>(stroke.getMiter());
        keyData[3] = static_cast<uint32_t>(stroke.getWidth());
    } else {
        keyData[2] = 0;
        keyData[3] = 0;
    }

    return GrResourceKey(GrCacheID(gPathDomain, key), gPathResourceType, 0);
}