blob: 22dd1c0572321fa7a13fb8647f2183349843d146 [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"
kkinnunen50b58e62015-05-18 23:02:07 -070013#include "GrStrokeInfo.h"
cdaltonb85a0aa2014-07-21 15:32:44 -070014#include "gl/GrGLFunctions.h"
15
bsalomon861e1032014-12-16 07:33:49 -080016class GrGLGpu;
cdaltonb85a0aa2014-07-21 15:32:44 -070017
18/**
19 * Currently this represents a range of GL_NV_path_rendering Path IDs. If we
20 * support other GL path extensions then this would have to have a type enum
21 * and/or be subclassed.
22 */
23
24class GrGLPathRange : public GrPathRange {
25public:
cdalton855d83f2014-09-18 13:51:53 -070026 /**
27 * Initialize a GL path range from a PathGenerator. This class will allocate
28 * the GPU path objects and initialize them lazily.
29 */
kkinnunen50b58e62015-05-18 23:02:07 -070030 GrGLPathRange(GrGLGpu*, PathGenerator*, const GrStrokeInfo&);
cdalton855d83f2014-09-18 13:51:53 -070031
32 /**
33 * Initialize a GL path range from an existing range of pre-initialized GPU
34 * path objects. This class assumes ownership of the GPU path objects and
35 * will delete them when done.
36 */
bsalomon861e1032014-12-16 07:33:49 -080037 GrGLPathRange(GrGLGpu*,
cdalton855d83f2014-09-18 13:51:53 -070038 GrGLuint basePathID,
39 int numPaths,
40 size_t gpuMemorySize,
kkinnunen50b58e62015-05-18 23:02:07 -070041 const GrStrokeInfo&);
cdalton855d83f2014-09-18 13:51:53 -070042
cdaltonb85a0aa2014-07-21 15:32:44 -070043 GrGLuint basePathID() const { return fBasePathID; }
bungemanaf13c7c2014-08-06 11:14:31 -040044
kkinnunen50b58e62015-05-18 23:02:07 -070045 bool shouldStroke() const { return fShouldStroke; }
46 bool shouldFill() const { return fShouldFill; }
47
cdaltonb85a0aa2014-07-21 15:32:44 -070048protected:
mtklein36352bf2015-03-25 18:17:31 -070049 void onInitPath(int index, const SkPath&) const override;
cdalton855d83f2014-09-18 13:51:53 -070050
mtklein36352bf2015-03-25 18:17:31 -070051 void onRelease() override;
52 void onAbandon() override;
cdaltonb85a0aa2014-07-21 15:32:44 -070053
54private:
kkinnunen50b58e62015-05-18 23:02:07 -070055 void init();
mtklein36352bf2015-03-25 18:17:31 -070056 size_t onGpuMemorySize() const override { return fGpuMemorySize; }
bsalomon69ed47f2014-11-12 11:13:39 -080057
kkinnunen50b58e62015-05-18 23:02:07 -070058 const GrStrokeInfo fStroke;
cdaltonb85a0aa2014-07-21 15:32:44 -070059 GrGLuint fBasePathID;
cdalton855d83f2014-09-18 13:51:53 -070060 mutable size_t fGpuMemorySize;
kkinnunen50b58e62015-05-18 23:02:07 -070061 bool fShouldStroke;
62 bool fShouldFill;
cdaltonb85a0aa2014-07-21 15:32:44 -070063
64 typedef GrPathRange INHERITED;
65};
66
67#endif