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