blob: 1ef1346133c92e9ade79320b32c33e4919aa53a6 [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 GrGLPath_DEFINED
9#define GrGLPath_DEFINED
10
11#include "../GrPath.h"
bsalomon2fc11d32015-10-19 09:03:23 -070012#include "gl/GrGLTypes.h"
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000013
bsalomon861e1032014-12-16 07:33:49 -080014class GrGLGpu;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000015
16/**
17 * Currently this represents a path built using GL_NV_path_rendering. If we
18 * support other GL path extensions then this would have to have a type enum
19 * and/or be subclassed.
20 */
21
22class GrGLPath : public GrPath {
23public:
kkinnunen1e2913e2015-12-01 04:35:37 -080024 static bool InitPathObjectPathDataCheckingDegenerates(GrGLGpu*,
25 GrGLuint pathID,
26 const SkPath&);
27 static void InitPathObjectPathData(GrGLGpu*,
28 GrGLuint pathID,
29 const SkPath&);
bsalomon85d96672016-05-10 06:19:21 -070030 static void InitPathObjectStroke(GrGLGpu* gpu, GrGLuint pathID, const GrStrokeInfo& stroke);
kkinnunen1e2913e2015-12-01 04:35:37 -080031
32 static void InitPathObjectEmptyPath(GrGLGpu*, GrGLuint pathID);
33
cdaltonb85a0aa2014-07-21 15:32:44 -070034
bsalomon85d96672016-05-10 06:19:21 -070035 GrGLPath(GrGLGpu* gpu, const SkPath& path, const GrStrokeInfo& stroke);
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000036 GrGLuint pathID() const { return fPathID; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000037
kkinnunen50b58e62015-05-18 23:02:07 -070038 bool shouldStroke() const { return fShouldStroke; }
39 bool shouldFill() const { return fShouldFill; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000040protected:
mtklein36352bf2015-03-25 18:17:31 -070041 void onRelease() override;
42 void onAbandon() override;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000043
44private:
bsalomon69ed47f2014-11-12 11:13:39 -080045 // TODO: Figure out how to get an approximate size of the path in Gpu memory.
mtklein36352bf2015-03-25 18:17:31 -070046 size_t onGpuMemorySize() const override { return 100; }
bsalomon69ed47f2014-11-12 11:13:39 -080047
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000048 GrGLuint fPathID;
kkinnunen50b58e62015-05-18 23:02:07 -070049 bool fShouldStroke;
50 bool fShouldFill;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000051
52 typedef GrPath INHERITED;
53};
54
55#endif