blob: a6193bbfae8364c4276891338ff5e0fd3e811068 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkPath.h"
12#include "include/core/SkRect.h"
Greg Daniel456f9b52020-03-05 19:14:18 +000013#include "src/gpu/GrGpuResource.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "src/gpu/GrPathRendering.h"
15#include "src/gpu/GrStyle.h"
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000016
Michael Ludwig2686d692020-04-17 20:21:37 +000017class GrStyledShape;
bsalomon7bffcd22016-09-15 13:55:33 -070018
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
Michael Ludwig2686d692020-04-17 20:21:37 +000035 static void ComputeKey(const GrStyledShape&, 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"; }
John Stiles7571f9e2020-09-02 22:42:33 -040055 using INHERITED = GrGpuResource;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000056};
57
58#endif