cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 1 | |
| 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" |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 13 | #include "GrStrokeInfo.h" |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 14 | #include "gl/GrGLFunctions.h" |
| 15 | |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 16 | class GrGLGpu; |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 17 | |
| 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 | |
| 24 | class GrGLPathRange : public GrPathRange { |
| 25 | public: |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Initialize a GL path range from a PathGenerator. This class will allocate |
| 28 | * the GPU path objects and initialize them lazily. |
| 29 | */ |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 30 | GrGLPathRange(GrGLGpu*, PathGenerator*, const GrStrokeInfo&); |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 31 | |
| 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 | */ |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 37 | GrGLPathRange(GrGLGpu*, |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 38 | GrGLuint basePathID, |
| 39 | int numPaths, |
| 40 | size_t gpuMemorySize, |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 41 | const GrStrokeInfo&); |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 42 | |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 43 | GrGLuint basePathID() const { return fBasePathID; } |
bungeman | af13c7c | 2014-08-06 11:14:31 -0400 | [diff] [blame] | 44 | |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 45 | bool shouldStroke() const { return fShouldStroke; } |
| 46 | bool shouldFill() const { return fShouldFill; } |
| 47 | |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 48 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 49 | void onInitPath(int index, const SkPath&) const override; |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 50 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 51 | void onRelease() override; |
| 52 | void onAbandon() override; |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 53 | |
| 54 | private: |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 55 | void init(); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 56 | size_t onGpuMemorySize() const override { return fGpuMemorySize; } |
bsalomon | 69ed47f | 2014-11-12 11:13:39 -0800 | [diff] [blame] | 57 | |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 58 | const GrStrokeInfo fStroke; |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 59 | GrGLuint fBasePathID; |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 60 | mutable size_t fGpuMemorySize; |
kkinnunen | 50b58e6 | 2015-05-18 23:02:07 -0700 | [diff] [blame] | 61 | bool fShouldStroke; |
| 62 | bool fShouldFill; |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 63 | |
| 64 | typedef GrPathRange INHERITED; |
| 65 | }; |
| 66 | |
| 67 | #endif |