blob: a5719353905ec6e6837f20ed3606d65cade46d24 [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 "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
bsalomon6d3fe022014-07-25 08:35:45 -070017class GrPath : public GrGpuResource {
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000018public:
robertphillips@google.com7fa18762012-09-11 13:02:31 +000019 SK_DECLARE_INST_COUNT(GrPath);
20
cdaltonb85a0aa2014-07-21 15:32:44 -070021 /**
22 * Initialize to a path with a fixed stroke. Stroke must not be hairline.
23 */
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000024 GrPath(GrGpu* gpu, bool isWrapped, const SkPath& skPath, const SkStrokeRec& stroke)
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000025 : INHERITED(gpu, isWrapped),
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000026 fSkPath(skPath),
27 fStroke(stroke),
28 fBounds(skPath.getBounds()) {
29 }
30
31 static GrResourceKey ComputeKey(const SkPath& path, const SkStrokeRec& stroke);
cdaltonb85a0aa2014-07-21 15:32:44 -070032 static uint64_t ComputeStrokeKey(const SkStrokeRec&);
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000033
34 bool isEqualTo(const SkPath& path, const SkStrokeRec& stroke) {
35 return fSkPath == path && fStroke == stroke;
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000036 }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000037
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000038 const SkRect& getBounds() const { return fBounds; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000039
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000040 const SkStrokeRec& getStroke() const { return fStroke; }
41
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000042protected:
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000043 SkPath fSkPath;
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000044 SkStrokeRec fStroke;
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000045 SkRect fBounds;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000046
47private:
bsalomon6d3fe022014-07-25 08:35:45 -070048 typedef GrGpuResource INHERITED;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000049};
50
51#endif