blob: ee3123f9b59a9c0ea4fa6c34d2c5a3d6c09f3cf7 [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"
kkinnunenc6e7a132015-12-07 23:39:01 -080012#include "GrPathRendering.h"
bsalomon6663acf2016-05-10 09:14:17 -070013#include "GrStyle.h"
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000014#include "SkPath.h"
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000015#include "SkRect.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:
cdaltonb85a0aa2014-07-21 15:32:44 -070019 /**
20 * Initialize to a path with a fixed stroke. Stroke must not be hairline.
21 */
bsalomon6663acf2016-05-10 09:14:17 -070022 GrPath(GrGpu* gpu, const SkPath& skPath, const GrStyle& style)
kkinnunen2e6055b2016-04-22 01:48:29 -070023 : INHERITED(gpu)
kkinnunenc6e7a132015-12-07 23:39:01 -080024 , fBounds(SkRect::MakeEmpty())
25 , fFillType(GrPathRendering::kWinding_FillType)
kkinnunen50b58e62015-05-18 23:02:07 -070026#ifdef SK_DEBUG
27 , fSkPath(skPath)
bsalomon6663acf2016-05-10 09:14:17 -070028 , fStyle(style)
kkinnunen50b58e62015-05-18 23:02:07 -070029#endif
30 {
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000031 }
32
bsalomon6663acf2016-05-10 09:14:17 -070033 static void ComputeKey(const SkPath& path, const GrStyle& style, GrUniqueKey* key,
kkinnunen070e0102015-05-21 00:37:30 -070034 bool* outIsVolatile);
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000035
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000036 const SkRect& getBounds() const { return fBounds; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000037
kkinnunenc6e7a132015-12-07 23:39:01 -080038 GrPathRendering::FillType getFillType() const { return fFillType; }
kkinnunen50b58e62015-05-18 23:02:07 -070039#ifdef SK_DEBUG
bsalomon6663acf2016-05-10 09:14:17 -070040 bool isEqualTo(const SkPath& path, const GrStyle& style) const;
kkinnunen50b58e62015-05-18 23:02:07 -070041#endif
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000042
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000043protected:
kkinnunenc6e7a132015-12-07 23:39:01 -080044 // Subclass should init these.
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000045 SkRect fBounds;
kkinnunenc6e7a132015-12-07 23:39:01 -080046 GrPathRendering::FillType fFillType;
kkinnunen50b58e62015-05-18 23:02:07 -070047#ifdef SK_DEBUG
48 SkPath fSkPath;
bsalomon6663acf2016-05-10 09:14:17 -070049 GrStyle fStyle;
kkinnunen50b58e62015-05-18 23:02:07 -070050#endif
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000051
52private:
bsalomon6d3fe022014-07-25 08:35:45 -070053 typedef GrGpuResource INHERITED;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000054};
55
56#endif