blob: ce13a3a03f58e4e7e49b97d9d21a01dd32f89c77 [file] [log] [blame]
cdaltonb85a0aa2014-07-21 15:32:44 -07001
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef GrGLPathRange_DEFINED
10#define GrGLPathRange_DEFINED
11
12#include "../GrPathRange.h"
13#include "gl/GrGLFunctions.h"
14
bsalomon861e1032014-12-16 07:33:49 -080015class GrGLGpu;
cdaltonb85a0aa2014-07-21 15:32:44 -070016
17/**
18 * Currently this represents a range of GL_NV_path_rendering Path IDs. 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 GrGLPathRange : public GrPathRange {
24public:
cdalton855d83f2014-09-18 13:51:53 -070025 /**
26 * Initialize a GL path range from a PathGenerator. This class will allocate
27 * the GPU path objects and initialize them lazily.
28 */
bsalomon861e1032014-12-16 07:33:49 -080029 GrGLPathRange(GrGLGpu*, PathGenerator*, const SkStrokeRec&);
cdalton855d83f2014-09-18 13:51:53 -070030
31 /**
32 * Initialize a GL path range from an existing range of pre-initialized GPU
33 * path objects. This class assumes ownership of the GPU path objects and
34 * will delete them when done.
35 */
bsalomon861e1032014-12-16 07:33:49 -080036 GrGLPathRange(GrGLGpu*,
cdalton855d83f2014-09-18 13:51:53 -070037 GrGLuint basePathID,
38 int numPaths,
39 size_t gpuMemorySize,
40 const SkStrokeRec&);
41
cdaltonb85a0aa2014-07-21 15:32:44 -070042 GrGLuint basePathID() const { return fBasePathID; }
bungemanaf13c7c2014-08-06 11:14:31 -040043
cdaltonb85a0aa2014-07-21 15:32:44 -070044protected:
mtklein72c9faa2015-01-09 10:06:39 -080045 void onInitPath(int index, const SkPath&) const SK_OVERRIDE;
cdalton855d83f2014-09-18 13:51:53 -070046
mtklein72c9faa2015-01-09 10:06:39 -080047 void onRelease() SK_OVERRIDE;
48 void onAbandon() SK_OVERRIDE;
cdaltonb85a0aa2014-07-21 15:32:44 -070049
50private:
mtklein72c9faa2015-01-09 10:06:39 -080051 size_t onGpuMemorySize() const SK_OVERRIDE { return fGpuMemorySize; }
bsalomon69ed47f2014-11-12 11:13:39 -080052
cdaltonb85a0aa2014-07-21 15:32:44 -070053 GrGLuint fBasePathID;
cdalton855d83f2014-09-18 13:51:53 -070054 mutable size_t fGpuMemorySize;
cdaltonb85a0aa2014-07-21 15:32:44 -070055
56 typedef GrPathRange INHERITED;
57};
58
59#endif