Home | History | Annotate | Download | only in gl
      1 /*
      2  * Copyright 2013 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 GrGLProgramDesc_DEFINED
      9 #define GrGLProgramDesc_DEFINED
     10 
     11 #include "GrColor.h"
     12 #include "GrProgramDesc.h"
     13 #include "GrGpu.h"
     14 #include "GrTypesPriv.h"
     15 
     16 class GrGLGpu;
     17 class GrGLProgramDescBuilder;
     18 
     19 class GrGLProgramDesc : public GrProgramDesc {
     20     friend class GrGLProgramDescBuilder;
     21 };
     22 
     23 /**
     24  * This class can be used to build a GrProgramDesc.  It also provides helpers for accessing
     25  * GL specific info in the header.
     26  */
     27 class GrGLProgramDescBuilder {
     28 public:
     29     typedef GrProgramDesc::KeyHeader KeyHeader;
     30     // The key, stored in fKey, is composed of five parts(first 2 are defined in the key itself):
     31     // 1. uint32_t for total key length.
     32     // 2. uint32_t for a checksum.
     33     // 3. Header struct defined above.
     34     // 4. Backend-specific information including per-processor keys and their key lengths.
     35     //    Each processor's key is a variable length array of uint32_t.
     36     enum {
     37         // Part 3.
     38         kHeaderOffset = GrGLProgramDesc::kHeaderOffset,
     39         kHeaderSize = SkAlign4(sizeof(KeyHeader)),
     40         // Part 4.
     41         // This is the offset into the backenend specific part of the key, which includes
     42         // per-processor keys.
     43         kProcessorKeysOffset = kHeaderOffset + kHeaderSize,
     44     };
     45 
     46     /**
     47      * Builds a GL specific program descriptor
     48      *
     49      * @param GrPrimitiveProcessor The geometry
     50      * @param GrPipeline  The optimized drawstate.  The descriptor will represent a program
     51      *                        which this optstate can use to draw with.  The optstate contains
     52      *                        general draw information, as well as the specific color, geometry,
     53      *                        and coverage stages which will be used to generate the GL Program for
     54      *                        this optstate.
     55      * @param GrGLSLCaps     Capabilities of the GLSL backend.
     56      * @param GrProgramDesc  The built and finalized descriptor
     57      **/
     58     static bool Build(GrProgramDesc*,
     59                       const GrPrimitiveProcessor&,
     60                       const GrPipeline&,
     61                       const GrGLSLCaps&);
     62 };
     63 
     64 #endif
     65