LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/gpu/gl - GrGLVertexArray.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 21 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 GrGLVertexArray_DEFINED
       9             : #define GrGLVertexArray_DEFINED
      10             : 
      11             : #include "GrGpuResource.h"
      12             : #include "GrTypesPriv.h"
      13             : #include "gl/GrGLDefines.h"
      14             : #include "gl/GrGLTypes.h"
      15             : #include "SkTArray.h"
      16             : 
      17             : class GrBuffer;
      18             : class GrGLGpu;
      19             : 
      20             : /**
      21             :  * This sets and tracks the vertex attribute array state. It is used internally by GrGLVertexArray
      22             :  * (below) but is separate because it is also used to track the state of vertex array object 0.
      23             :  */
      24           0 : class GrGLAttribArrayState {
      25             : public:
      26           0 :     explicit GrGLAttribArrayState(int arrayCount = 0) {
      27           0 :         this->resize(arrayCount);
      28           0 :     }
      29             : 
      30           0 :     void resize(int newCount) {
      31           0 :         fAttribArrayStates.resize_back(newCount);
      32           0 :         for (int i = 0; i < newCount; ++i) {
      33           0 :             fAttribArrayStates[i].invalidate();
      34             :         }
      35           0 :     }
      36             : 
      37             :     /**
      38             :      * This function enables and sets vertex attrib state for the specified attrib index. It is
      39             :      * assumed that the GrGLAttribArrayState is tracking the state of the currently bound vertex
      40             :      * array object.
      41             :      */
      42             :     void set(GrGLGpu*,
      43             :              int attribIndex,
      44             :              const GrBuffer* vertexBuffer,
      45             :              GrVertexAttribType type,
      46             :              GrGLsizei stride,
      47             :              GrGLvoid* offset);
      48             : 
      49             :     /**
      50             :      * This function disables vertex attribs not present in the mask. It is assumed that the
      51             :      * GrGLAttribArrayState is tracking the state of the currently bound vertex array object.
      52             :      */
      53             :     void disableUnusedArrays(const GrGLGpu*, uint64_t usedAttribArrayMask);
      54             : 
      55           0 :     void invalidate() {
      56           0 :         int count = fAttribArrayStates.count();
      57           0 :         for (int i = 0; i < count; ++i) {
      58           0 :             fAttribArrayStates[i].invalidate();
      59             :         }
      60           0 :     }
      61             : 
      62             :     /**
      63             :      * The number of attrib arrays that this object is configured to track.
      64             :      */
      65           0 :     int count() const { return fAttribArrayStates.count(); }
      66             : 
      67             : private:
      68             :     /**
      69             :      * Tracks the state of glVertexAttribArray for an attribute index.
      70             :      */
      71           0 :     struct AttribArrayState {
      72           0 :         void invalidate() {
      73           0 :             fEnableIsValid = false;
      74           0 :             fVertexBufferUniqueID.makeInvalid();
      75           0 :         }
      76             : 
      77             :         bool                            fEnableIsValid;
      78             :         bool                            fEnabled;
      79             :         GrGpuResource::UniqueID         fVertexBufferUniqueID;
      80             :         GrVertexAttribType              fType;
      81             :         GrGLsizei                       fStride;
      82             :         GrGLvoid*                       fOffset;
      83             :     };
      84             : 
      85             :     SkSTArray<16, AttribArrayState, true> fAttribArrayStates;
      86             : };
      87             : 
      88             : /**
      89             :  * This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array
      90             :  * and is used to track the state of the vertex array to avoid redundant GL calls.
      91             :  */
      92           0 : class GrGLVertexArray {
      93             : public:
      94             :     GrGLVertexArray(GrGLint id, int attribCount);
      95             : 
      96             :     /**
      97             :      * Binds this vertex array. If the ID has been deleted or abandoned then nullptr is returned.
      98             :      * Otherwise, the GrGLAttribArrayState that is tracking this vertex array's attrib bindings is
      99             :      * returned.
     100             :      */
     101             :     GrGLAttribArrayState* bind(GrGLGpu*);
     102             : 
     103             :     /**
     104             :      * This is a version of the above function that also binds an index buffer to the vertex
     105             :      * array object.
     106             :      */
     107             :     GrGLAttribArrayState* bindWithIndexBuffer(GrGLGpu* gpu, const GrBuffer* indexBuffer);
     108             : 
     109             :     GrGLuint arrayID() const { return fID; }
     110             : 
     111             :     void invalidateCachedState();
     112             : 
     113             : private:
     114             :     GrGLuint                  fID;
     115             :     GrGLAttribArrayState      fAttribArrays;
     116             :     GrGpuResource::UniqueID   fIndexBufferUniqueID;
     117             : };
     118             : 
     119             : #endif

Generated by: LCOV version 1.13