blob: f74baf317d0f37eaf8c5552f24e6751873f7eb32 [file] [log] [blame]
bsalomon@google.com64aef2b2012-06-11 15:36:13 +00001/*
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
bsalomon6d3fe022014-07-25 08:35:45 -070011#include "GrGpuResource.h"
kkinnunen50b58e62015-05-18 23:02:07 -070012#include "GrStrokeInfo.h"
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000013#include "SkPath.h"
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000014#include "SkRect.h"
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000015
bsalomon6d3fe022014-07-25 08:35:45 -070016class GrPath : public GrGpuResource {
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000017public:
mtklein2766c002015-06-26 11:45:03 -070018
robertphillips@google.com7fa18762012-09-11 13:02:31 +000019
cdaltonb85a0aa2014-07-21 15:32:44 -070020 /**
21 * Initialize to a path with a fixed stroke. Stroke must not be hairline.
22 */
kkinnunen50b58e62015-05-18 23:02:07 -070023 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.org5c8ee252013-11-01 15:23:44 +000031 }
32
kkinnunen070e0102015-05-21 00:37:30 -070033 static void ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUniqueKey* key,
34 bool* outIsVolatile);
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000035
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000036 const SkRect& getBounds() const { return fBounds; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000037
kkinnunen50b58e62015-05-18 23:02:07 -070038#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.org32184d82013-10-09 15:14:18 +000043
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000044protected:
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000045 SkRect fBounds;
kkinnunen50b58e62015-05-18 23:02:07 -070046#ifdef SK_DEBUG
47 SkPath fSkPath;
48 GrStrokeInfo fStroke;
49#endif
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000050
51private:
bsalomon6d3fe022014-07-25 08:35:45 -070052 typedef GrGpuResource INHERITED;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000053};
54
55#endif