bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 1 | /* |
| 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 Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkPath.h" |
| 12 | #include "include/core/SkRect.h" |
Greg Daniel | 456f9b5 | 2020-03-05 19:14:18 +0000 | [diff] [blame] | 13 | #include "src/gpu/GrGpuResource.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "src/gpu/GrPathRendering.h" |
| 15 | #include "src/gpu/GrStyle.h" |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 16 | |
Michael Ludwig | 2686d69 | 2020-04-17 20:21:37 +0000 | [diff] [blame] | 17 | class GrStyledShape; |
bsalomon | 7bffcd2 | 2016-09-15 13:55:33 -0700 | [diff] [blame] | 18 | |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 19 | class GrPath : public GrGpuResource { |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 20 | public: |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 21 | /** |
| 22 | * Initialize to a path with a fixed stroke. Stroke must not be hairline. |
| 23 | */ |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 24 | GrPath(GrGpu* gpu, const SkPath& skPath, const GrStyle& style) |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 25 | : INHERITED(gpu) |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 26 | , fBounds(SkRect::MakeEmpty()) |
| 27 | , fFillType(GrPathRendering::kWinding_FillType) |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 28 | #ifdef SK_DEBUG |
| 29 | , fSkPath(skPath) |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 30 | , fStyle(style) |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 31 | #endif |
| 32 | { |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Michael Ludwig | 2686d69 | 2020-04-17 20:21:37 +0000 | [diff] [blame] | 35 | static void ComputeKey(const GrStyledShape&, GrUniqueKey* key, bool* outIsVolatile); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 36 | |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 37 | const SkRect& getBounds() const { return fBounds; } |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 38 | |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 39 | GrPathRendering::FillType getFillType() const { return fFillType; } |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 40 | #ifdef SK_DEBUG |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 41 | bool isEqualTo(const SkPath& path, const GrStyle& style) const; |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 42 | #endif |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 43 | |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 44 | protected: |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 45 | // Subclass should init these. |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 46 | SkRect fBounds; |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 47 | GrPathRendering::FillType fFillType; |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 48 | #ifdef SK_DEBUG |
| 49 | SkPath fSkPath; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 50 | GrStyle fStyle; |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 51 | #endif |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 52 | |
| 53 | private: |
Derek Sollenberger | cf6da8c | 2018-03-29 13:40:02 -0400 | [diff] [blame] | 54 | const char* getResourceType() const override { return "Path Data"; } |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 55 | using INHERITED = GrGpuResource; |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #endif |