blob: f481ea428644788af0add1c1fd1a1000214d8bca [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
11#include "GrResource.h"
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000012#include "GrResourceCache.h"
13#include "SkPath.h"
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000014#include "SkRect.h"
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000015#include "SkStrokeRec.h"
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000016
17class GrPath : public GrResource {
18public:
robertphillips@google.com7fa18762012-09-11 13:02:31 +000019 SK_DECLARE_INST_COUNT(GrPath);
20
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000021 GrPath(GrGpu* gpu, bool isWrapped, const SkPath& skPath, const SkStrokeRec& stroke)
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000022 : INHERITED(gpu, isWrapped),
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000023 fSkPath(skPath),
24 fStroke(stroke),
25 fBounds(skPath.getBounds()) {
26 }
27
28 static GrResourceKey ComputeKey(const SkPath& path, const SkStrokeRec& stroke);
29
30 bool isEqualTo(const SkPath& path, const SkStrokeRec& stroke) {
31 return fSkPath == path && fStroke == stroke;
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000032 }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000033
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000034 const SkRect& getBounds() const { return fBounds; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000035
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000036 const SkStrokeRec& getStroke() const { return fStroke; }
37
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000038protected:
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000039 SkPath fSkPath;
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000040 SkStrokeRec fStroke;
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000041 SkRect fBounds;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000042
43private:
44 typedef GrResource INHERITED;
45};
46
47#endif