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" |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 12 | #include "GrResourceCache.h" |
| 13 | #include "SkPath.h" |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 14 | #include "SkRect.h" |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 15 | #include "SkStrokeRec.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: |
robertphillips@google.com | 7fa1876 | 2012-09-11 13:02:31 +0000 | [diff] [blame] | 19 | SK_DECLARE_INST_COUNT(GrPath); |
| 20 | |
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 | */ |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 24 | GrPath(GrGpu* gpu, bool isWrapped, const SkPath& skPath, const SkStrokeRec& stroke) |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 25 | : INHERITED(gpu, isWrapped), |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 26 | fSkPath(skPath), |
| 27 | fStroke(stroke), |
| 28 | fBounds(skPath.getBounds()) { |
| 29 | } |
| 30 | |
| 31 | static GrResourceKey ComputeKey(const SkPath& path, const SkStrokeRec& stroke); |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 32 | static uint64_t ComputeStrokeKey(const SkStrokeRec&); |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 33 | |
| 34 | bool isEqualTo(const SkPath& path, const SkStrokeRec& stroke) { |
| 35 | return fSkPath == path && fStroke == stroke; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 36 | } |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 37 | |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 38 | const SkRect& getBounds() const { return fBounds; } |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 39 | |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 40 | const SkStrokeRec& getStroke() const { return fStroke; } |
| 41 | |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 42 | protected: |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 43 | SkPath fSkPath; |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 44 | SkStrokeRec fStroke; |
commit-bot@chromium.org | 5c8ee25 | 2013-11-01 15:23:44 +0000 | [diff] [blame] | 45 | SkRect fBounds; |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 46 | |
| 47 | private: |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 48 | typedef GrGpuResource INHERITED; |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | #endif |