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