blob: 09d317ef2f2d3d0883c01933c67151091b68da20 [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"
kkinnunenc6e7a132015-12-07 23:39:01 -080013#include "GrPathRendering.h"
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000014#include "SkPath.h"
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000015#include "SkRect.h"
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000016
bsalomon6d3fe022014-07-25 08:35:45 -070017class GrPath : public GrGpuResource {
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000018public:
cdaltonb85a0aa2014-07-21 15:32:44 -070019 /**
20 * Initialize to a path with a fixed stroke. Stroke must not be hairline.
21 */
kkinnunen50b58e62015-05-18 23:02:07 -070022 GrPath(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo& stroke)
23 : INHERITED(gpu, kCached_LifeCycle)
kkinnunenc6e7a132015-12-07 23:39:01 -080024 , fBounds(SkRect::MakeEmpty())
25 , fFillType(GrPathRendering::kWinding_FillType)
kkinnunen50b58e62015-05-18 23:02:07 -070026#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
kkinnunenc6e7a132015-12-07 23:39:01 -080038 GrPathRendering::FillType getFillType() const { return fFillType; }
kkinnunen50b58e62015-05-18 23:02:07 -070039#ifdef SK_DEBUG
fmalitafbe1c112015-11-18 20:12:56 -080040 bool isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) const;
kkinnunen50b58e62015-05-18 23:02:07 -070041#endif
commit-bot@chromium.org32184d82013-10-09 15:14:18 +000042
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000043protected:
kkinnunenc6e7a132015-12-07 23:39:01 -080044 // Subclass should init these.
commit-bot@chromium.org5c8ee252013-11-01 15:23:44 +000045 SkRect fBounds;
kkinnunenc6e7a132015-12-07 23:39:01 -080046 GrPathRendering::FillType fFillType;
kkinnunen50b58e62015-05-18 23:02:07 -070047#ifdef SK_DEBUG
48 SkPath fSkPath;
49 GrStrokeInfo fStroke;
50#endif
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000051
52private:
bsalomon6d3fe022014-07-25 08:35:45 -070053 typedef GrGpuResource INHERITED;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000054};
55
56#endif