blob: cf4a11d4fd679f5ae32a459f3b94bfc1725196b1 [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
bsalomon7bffcd22016-09-15 13:55:33 -070017class GrShape;
18
bsalomon6d3fe022014-07-25 08:35:45 -070019class GrPath : public GrGpuResource {
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000020public:
cdaltonb85a0aa2014-07-21 15:32:44 -070021 /**
22 * Initialize to a path with a fixed stroke. Stroke must not be hairline.
23 */
bsalomon6663acf2016-05-10 09:14:17 -070024 GrPath(GrGpu* gpu, const SkPath& skPath, const GrStyle& style)
kkinnunen2e6055b2016-04-22 01:48:29 -070025 : INHERITED(gpu)
kkinnunenc6e7a132015-12-07 23:39:01 -080026 , fBounds(SkRect::MakeEmpty())
27 , fFillType(GrPathRendering::kWinding_FillType)
kkinnunen50b58e62015-05-18 23:02:07 -070028#ifdef SK_DEBUG
29 , fSkPath(skPath)
bsalomon6663acf2016-05-10 09:14:17 -070030 , fStyle(style)
kkinnunen50b58e62015-05-18 23:02:07 -070031#endif
32 {
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000033 }
34
bsalomon7bffcd22016-09-15 13:55:33 -070035 static void ComputeKey(const GrShape&, GrUniqueKey* key, bool* outIsVolatile);
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
kkinnunenc6e7a132015-12-07 23:39:01 -080039 GrPathRendering::FillType getFillType() const { return fFillType; }
kkinnunen50b58e62015-05-18 23:02:07 -070040#ifdef SK_DEBUG
bsalomon6663acf2016-05-10 09:14:17 -070041 bool isEqualTo(const SkPath& path, const GrStyle& style) const;
kkinnunen50b58e62015-05-18 23:02:07 -070042#endif
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000043
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000044protected:
kkinnunenc6e7a132015-12-07 23:39:01 -080045 // Subclass should init these.
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000046 SkRect fBounds;
kkinnunenc6e7a132015-12-07 23:39:01 -080047 GrPathRendering::FillType fFillType;
kkinnunen50b58e62015-05-18 23:02:07 -070048#ifdef SK_DEBUG
49 SkPath fSkPath;
bsalomon6663acf2016-05-10 09:14:17 -070050 GrStyle fStyle;
kkinnunen50b58e62015-05-18 23:02:07 -070051#endif
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000052
53private:
Derek Sollenbergercf6da8c2018-03-29 13:40:02 -040054 const char* getResourceType() const override { return "Path Data"; }
bsalomon6d3fe022014-07-25 08:35:45 -070055 typedef GrGpuResource INHERITED;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000056};
57
58#endif