| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef GrGLPathRange_DEFINED | 9 #ifndef GrGLPathRange_DEFINED |
| 10 #define GrGLPathRange_DEFINED | 10 #define GrGLPathRange_DEFINED |
| 11 | 11 |
| 12 #include "../GrPathRange.h" | 12 #include "../GrPathRange.h" |
| 13 #include "gl/GrGLFunctions.h" | 13 #include "gl/GrGLFunctions.h" |
| 14 | 14 |
| 15 class GrGpuGL; | 15 class GrGpuGL; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Currently this represents a range of GL_NV_path_rendering Path IDs. If we | 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 | 19 * support other GL path extensions then this would have to have a type enum |
| 20 * and/or be subclassed. | 20 * and/or be subclassed. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 class GrGLPathRange : public GrPathRange { | 23 class GrGLPathRange : public GrPathRange { |
| 24 public: | 24 public: |
| 25 GrGLPathRange(GrGpuGL*, size_t size, const SkStrokeRec&); | 25 /** |
| 26 * Initialize a GL path range from a PathGenerator. This class will allocate |
| 27 * the GPU path objects and initialize them lazily. It also assumes ownershi
p |
| 28 * of the PathGenerator and will delete it when done. |
| 29 */ |
| 30 GrGLPathRange(GrGpuGL*, PathGenerator*, const SkStrokeRec&); |
| 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 path objects and will |
| 35 * delete them when done. |
| 36 */ |
| 37 GrGLPathRange(GrGpuGL*, |
| 38 GrGLuint basePathID, |
| 39 uint32_t numPaths, |
| 40 size_t gpuMemorySize, |
| 41 const SkStrokeRec&); |
| 42 |
| 26 virtual ~GrGLPathRange(); | 43 virtual ~GrGLPathRange(); |
| 27 | 44 |
| 28 GrGLuint basePathID() const { return fBasePathID; } | 45 GrGLuint basePathID() const { return fBasePathID; } |
| 29 | 46 |
| 30 virtual void initAt(size_t index, const SkPath&); | 47 virtual size_t gpuMemorySize() const SK_OVERRIDE { return fGpuMemorySize; } |
| 31 | |
| 32 // TODO: Use a better approximation for the individual path sizes. | |
| 33 virtual size_t gpuMemorySize() const SK_OVERRIDE { | |
| 34 return 100 * fNumDefinedPaths; | |
| 35 } | |
| 36 | 48 |
| 37 protected: | 49 protected: |
| 50 virtual void onInitPath(uint32_t index, const SkPath&) const; |
| 51 |
| 38 virtual void onRelease() SK_OVERRIDE; | 52 virtual void onRelease() SK_OVERRIDE; |
| 39 virtual void onAbandon() SK_OVERRIDE; | 53 virtual void onAbandon() SK_OVERRIDE; |
| 40 | 54 |
| 41 private: | 55 private: |
| 42 GrGLuint fBasePathID; | 56 GrGLuint fBasePathID; |
| 43 size_t fNumDefinedPaths; | 57 mutable size_t fGpuMemorySize; |
| 44 | 58 |
| 45 typedef GrPathRange INHERITED; | 59 typedef GrPathRange INHERITED; |
| 46 }; | 60 }; |
| 47 | 61 |
| 48 #endif | 62 #endif |
| OLD | NEW |