aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPath.h
blob: 975dad0afdd2ccb8dcb05824646797b4f3941e2b (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrPath_DEFINED
#define GrPath_DEFINED

#include "GrGpuResource.h"
#include "GrStrokeInfo.h"
#include "GrPathRendering.h"
#include "SkPath.h"
#include "SkRect.h"

class GrPath : public GrGpuResource {
public:
    /**
     * Initialize to a path with a fixed stroke. Stroke must not be hairline.
     */
    GrPath(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo& stroke)
        : INHERITED(gpu)
        , fBounds(SkRect::MakeEmpty())
        , fFillType(GrPathRendering::kWinding_FillType)
#ifdef SK_DEBUG
        , fSkPath(skPath)
        , fStroke(stroke)
#endif
    {
    }

    static void ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUniqueKey* key,
                           bool* outIsVolatile);

    const SkRect& getBounds() const { return fBounds; }

    GrPathRendering::FillType getFillType() const { return fFillType; }

    /**
     * Returns true if a path can be drawn in the same draw paths operation as the other
     * path. Should return true only when the condition holds transitively with all other paths in
     * the same group.
     * E.g.
     * canCombineDrawPathBatchWith(a) AND canCombineDrawPathBatchWith(b)
     * canCombineDrawPathBatchWith(a) AND canCombineDrawPathBatchWith(c)
     *  implies
     * canCombineDrawPathBatchWith(b) AND canCombineDrawPathBatchWith(c)
     */
    virtual bool canCombineDrawPathBatchWith(const GrPath& other) const = 0;
#ifdef SK_DEBUG
    bool isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) const;
#endif

protected:
    // Subclass should init these.
    SkRect fBounds;
    GrPathRendering::FillType fFillType;
#ifdef SK_DEBUG
    SkPath fSkPath;
    GrStrokeInfo fStroke;
#endif

private:
    typedef GrGpuResource INHERITED;
};

#endif