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 "GrStrokeInfo.h" 14 #include "gl/GrGLTypes.h" 15 16 class GrGLGpu; 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: 26 /** 27 * Initialize a GL path range from a PathGenerator. This class will allocate 28 * the GPU path objects and initialize them lazily. 29 */ 30 GrGLPathRange(GrGLGpu*, PathGenerator*, const GrStrokeInfo&); 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 */ 37 GrGLPathRange(GrGLGpu*, 38 GrGLuint basePathID, 39 int numPaths, 40 size_t gpuMemorySize, 41 const GrStrokeInfo&); 42 basePathID()43 GrGLuint basePathID() const { return fBasePathID; } 44 shouldStroke()45 bool shouldStroke() const { return fShouldStroke; } shouldFill()46 bool shouldFill() const { return fShouldFill; } 47 48 protected: 49 void onInitPath(int index, const SkPath&) const override; 50 51 void onRelease() override; 52 void onAbandon() override; 53 54 private: 55 void init(); onGpuMemorySize()56 size_t onGpuMemorySize() const override { return fGpuMemorySize; } 57 58 const GrStrokeInfo fStroke; 59 GrGLuint fBasePathID; 60 mutable size_t fGpuMemorySize; 61 bool fShouldStroke; 62 bool fShouldFill; 63 64 typedef GrPathRange INHERITED; 65 }; 66 67 #endif 68