aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLPathRange.h
blob: 5cba9c79d760559dc826867d6ed933efd53f70f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

/*
 * Copyright 2014 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrGLPathRange_DEFINED
#define GrGLPathRange_DEFINED

#include "../GrPathRange.h"
#include "gl/GrGLFunctions.h"

class GrGLGpu;

/**
 * Currently this represents a range of GL_NV_path_rendering Path IDs. If we
 * support other GL path extensions then this would have to have a type enum
 * and/or be subclassed.
 */

class GrGLPathRange : public GrPathRange {
public:
    /**
     * Initialize a GL path range from a PathGenerator. This class will allocate
     * the GPU path objects and initialize them lazily.
     */
    GrGLPathRange(GrGLGpu*, PathGenerator*, const SkStrokeRec&);

    /**
     * Initialize a GL path range from an existing range of pre-initialized GPU
     * path objects. This class assumes ownership of the GPU path objects and
     * will delete them when done.
     */
    GrGLPathRange(GrGLGpu*,
                  GrGLuint basePathID,
                  int numPaths,
                  size_t gpuMemorySize,
                  const SkStrokeRec&);

    GrGLuint basePathID() const { return fBasePathID; }

protected:
    void onInitPath(int index, const SkPath&) const override;

    void onRelease() override;
    void onAbandon() override;

private:
    size_t onGpuMemorySize() const override { return fGpuMemorySize; }

    GrGLuint fBasePathID;
    mutable size_t fGpuMemorySize;

    typedef GrPathRange INHERITED;
};

#endif