blob: 394db6f5c2e1a7625afcf809ce09ac335a8129a1 [file] [log] [blame]
bsalomon@google.com64aef2b2012-06-11 15:36:13 +00001/*
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
bsalomon6d3fe022014-07-25 08:35:45 -070011#include "GrGpuResource.h"
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000012#include "SkPath.h"
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000013#include "SkRect.h"
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000014#include "SkStrokeRec.h"
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000015
bsalomon6d3fe022014-07-25 08:35:45 -070016class GrPath : public GrGpuResource {
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000017public:
robertphillips@google.com7fa18762012-09-11 13:02:31 +000018 SK_DECLARE_INST_COUNT(GrPath);
19
cdaltonb85a0aa2014-07-21 15:32:44 -070020 /**
21 * Initialize to a path with a fixed stroke. Stroke must not be hairline.
22 */
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000023 GrPath(GrGpu* gpu, bool isWrapped, const SkPath& skPath, const SkStrokeRec& stroke)
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000024 : INHERITED(gpu, isWrapped),
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000025 fSkPath(skPath),
26 fStroke(stroke),
27 fBounds(skPath.getBounds()) {
28 }
29
30 static GrResourceKey ComputeKey(const SkPath& path, const SkStrokeRec& stroke);
cdaltonb85a0aa2014-07-21 15:32:44 -070031 static uint64_t ComputeStrokeKey(const SkStrokeRec&);
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000032
33 bool isEqualTo(const SkPath& path, const SkStrokeRec& stroke) {
34 return fSkPath == path && fStroke == stroke;
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000035 }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000036
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000037 const SkRect& getBounds() const { return fBounds; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000038
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000039 const SkStrokeRec& getStroke() const { return fStroke; }
40
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000041protected:
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000042 SkPath fSkPath;
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000043 SkStrokeRec fStroke;
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000044 SkRect fBounds;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000045
46private:
bsalomon6d3fe022014-07-25 08:35:45 -070047 typedef GrGpuResource INHERITED;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000048};
49
50#endif