Home | History | Annotate | Download | only in gl
      1 /*
      2  * Copyright 2014 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef GrGLPathRange_DEFINED
      9 #define GrGLPathRange_DEFINED
     10 
     11 #include "../GrPathRange.h"
     12 #include "GrStyle.h"
     13 #include "gl/GrGLTypes.h"
     14 
     15 class GrGLGpu;
     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:
     25     /**
     26      * Initialize a GL path range from a PathGenerator. This class will allocate
     27      * the GPU path objects and initialize them lazily.
     28      */
     29     GrGLPathRange(GrGLGpu*, PathGenerator*, const GrStyle&);
     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      */
     36     GrGLPathRange(GrGLGpu*,
     37                   GrGLuint basePathID,
     38                   int numPaths,
     39                   size_t gpuMemorySize,
     40                   const GrStyle&);
     41 
     42     GrGLuint basePathID() const { return fBasePathID; }
     43 
     44     bool shouldStroke() const { return fShouldStroke; }
     45     bool shouldFill() const { return fShouldFill; }
     46 
     47 protected:
     48     void onInitPath(int index, const SkPath&) const override;
     49 
     50     void onRelease() override;
     51     void onAbandon() override;
     52 
     53 private:
     54     void init();
     55     size_t onGpuMemorySize() const override { return fGpuMemorySize; }
     56 
     57     const GrStyle fStyle;
     58     GrGLuint fBasePathID;
     59     mutable size_t fGpuMemorySize;
     60     bool fShouldStroke;
     61     bool fShouldFill;
     62 
     63     typedef GrPathRange INHERITED;
     64 };
     65 
     66 #endif
     67