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 | |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 11 | #include "GrGpuResource.h" |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 12 | #include "GrStrokeInfo.h" |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 13 | #include "GrPathRendering.h" |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 14 | #include "SkPath.h" |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 15 | #include "SkRect.h" |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 16 | |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 17 | class GrPath : public GrGpuResource { |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 18 | public: |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 19 | /** |
| 20 | * Initialize to a path with a fixed stroke. Stroke must not be hairline. |
| 21 | */ |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 22 | GrPath(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo& stroke) |
| 23 | : INHERITED(gpu, kCached_LifeCycle) |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 24 | , fBounds(SkRect::MakeEmpty()) |
| 25 | , fFillType(GrPathRendering::kWinding_FillType) |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 26 | #ifdef SK_DEBUG |
| 27 | , fSkPath(skPath) |
| 28 | , fStroke(stroke) |
| 29 | #endif |
| 30 | { |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 31 | } |
| 32 | |
kkinnunen | 070e010 | 2015-05-21 00:37:30 -0700 | [diff] [blame] | 33 | static void ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUniqueKey* key, |
| 34 | bool* outIsVolatile); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 35 | |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 36 | const SkRect& getBounds() const { return fBounds; } |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 37 | |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 38 | GrPathRendering::FillType getFillType() const { return fFillType; } |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 39 | #ifdef SK_DEBUG |
fmalita | fbe1c11 | 2015-11-18 20:12:56 -0800 | [diff] [blame] | 40 | bool isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) const; |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 41 | #endif |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 42 | |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 43 | protected: |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 44 | // Subclass should init these. |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 45 | SkRect fBounds; |
kkinnunen | c6e7a13 | 2015-12-07 23:39:01 -0800 | [diff] [blame] | 46 | GrPathRendering::FillType fFillType; |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 47 | #ifdef SK_DEBUG |
| 48 | SkPath fSkPath; |
| 49 | GrStrokeInfo fStroke; |
| 50 | #endif |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 51 | |
| 52 | private: |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 53 | typedef GrGpuResource INHERITED; |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | #endif |