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" |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 13 | #include "SkPath.h" |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 14 | #include "SkRect.h" |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 15 | |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 16 | class GrPath : public GrGpuResource { |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 17 | public: |
mtklein | 2766c00 | 2015-06-26 11:45:03 -0700 | [diff] [blame^] | 18 | |
robertphillips@google.com | 7fa1876 | 2012-09-11 13:02:31 +0000 | [diff] [blame] | 19 | |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 20 | /** |
| 21 | * Initialize to a path with a fixed stroke. Stroke must not be hairline. |
| 22 | */ |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 23 | GrPath(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo& stroke) |
| 24 | : INHERITED(gpu, kCached_LifeCycle) |
| 25 | , fBounds(skPath.getBounds()) |
| 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 | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 38 | #ifdef SK_DEBUG |
| 39 | bool isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) { |
| 40 | return fSkPath == path && fStroke.hasEqualEffect(stroke); |
| 41 | } |
| 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: |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 45 | SkRect fBounds; |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 46 | #ifdef SK_DEBUG |
| 47 | SkPath fSkPath; |
| 48 | GrStrokeInfo fStroke; |
| 49 | #endif |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 50 | |
| 51 | private: |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 52 | typedef GrGpuResource INHERITED; |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | #endif |