blob: ddcee533ee6b831bea448053ac8458e1cdafc789 [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;
bsalomon6663acf2016-05-10 09:14:17 -070015class GrStyle;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000016
17/**
18 * Currently this represents a path built using GL_NV_path_rendering. If we
19 * support other GL path extensions then this would have to have a type enum
20 * and/or be subclassed.
21 */
22
23class GrGLPath : public GrPath {
24public:
kkinnunen1e2913e2015-12-01 04:35:37 -080025 static bool InitPathObjectPathDataCheckingDegenerates(GrGLGpu*,
26 GrGLuint pathID,
27 const SkPath&);
28 static void InitPathObjectPathData(GrGLGpu*,
29 GrGLuint pathID,
30 const SkPath&);
bsalomon6663acf2016-05-10 09:14:17 -070031 static void InitPathObjectStroke(GrGLGpu*, GrGLuint pathID, const SkStrokeRec&);
kkinnunen1e2913e2015-12-01 04:35:37 -080032
33 static void InitPathObjectEmptyPath(GrGLGpu*, GrGLuint pathID);
34
cdaltonb85a0aa2014-07-21 15:32:44 -070035
bsalomon6663acf2016-05-10 09:14:17 -070036 GrGLPath(GrGLGpu*, const SkPath&, const GrStyle&);
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000037 GrGLuint pathID() const { return fPathID; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000038
kkinnunen50b58e62015-05-18 23:02:07 -070039 bool shouldStroke() const { return fShouldStroke; }
40 bool shouldFill() const { return fShouldFill; }
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000041protected:
mtklein36352bf2015-03-25 18:17:31 -070042 void onRelease() override;
43 void onAbandon() override;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000044
45private:
bsalomon69ed47f2014-11-12 11:13:39 -080046 // TODO: Figure out how to get an approximate size of the path in Gpu memory.
mtklein36352bf2015-03-25 18:17:31 -070047 size_t onGpuMemorySize() const override { return 100; }
bsalomon69ed47f2014-11-12 11:13:39 -080048
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000049 GrGLuint fPathID;
kkinnunen50b58e62015-05-18 23:02:07 -070050 bool fShouldStroke;
51 bool fShouldFill;
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000052
53 typedef GrPath INHERITED;
54};
55
56#endif