GrPath.h revision 070e01056acdd9980619e71e2da390efb94e912e
1/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrPath_DEFINED
9#define GrPath_DEFINED
10
11#include "GrGpuResource.h"
12#include "GrStrokeInfo.h"
13#include "SkPath.h"
14#include "SkRect.h"
15
16class GrPath : public GrGpuResource {
17public:
18    SK_DECLARE_INST_COUNT(GrPath);
19
20    /**
21     * Initialize to a path with a fixed stroke. Stroke must not be hairline.
22     */
23    GrPath(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo& stroke)
24        : INHERITED(gpu, kCached_LifeCycle)
25        , fBounds(skPath.getBounds())
26#ifdef SK_DEBUG
27        , fSkPath(skPath)
28        , fStroke(stroke)
29#endif
30    {
31    }
32
33    static void ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUniqueKey* key,
34                           bool* outIsVolatile);
35
36    const SkRect& getBounds() const { return fBounds; }
37
38#ifdef SK_DEBUG
39    bool isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) {
40        return fSkPath == path && fStroke.hasEqualEffect(stroke);
41    }
42#endif
43
44protected:
45    SkRect fBounds;
46#ifdef SK_DEBUG
47    SkPath fSkPath;
48    GrStrokeInfo fStroke;
49#endif
50
51private:
52    typedef GrGpuResource INHERITED;
53};
54
55#endif
56