content/canvas/src/WebGLVertexAttribData.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef WEBGLVERTEXATTRIBDATA_H_
     7 #define WEBGLVERTEXATTRIBDATA_H_
     9 namespace mozilla {
    11 class WebGLBuffer;
    13 struct WebGLVertexAttribData {
    14     // note that these initial values are what GL initializes vertex attribs to
    15     WebGLVertexAttribData()
    16         : buf(0)
    17         , stride(0)
    18         , size(4)
    19         , divisor(0) // OpenGL ES 3.0 specs paragraphe 6.2 p240
    20         , byteOffset(0)
    21         , type(LOCAL_GL_FLOAT)
    22         , enabled(false)
    23         , normalized(false)
    24     { }
    26     WebGLRefPtr<WebGLBuffer> buf;
    27     GLuint stride;
    28     GLuint size;
    29     GLuint divisor;
    30     GLuint byteOffset;
    31     GLenum type;
    32     bool enabled;
    33     bool normalized;
    35     GLuint componentSize() const {
    36         switch(type) {
    37             case LOCAL_GL_BYTE:
    38                 return sizeof(GLbyte);
    39                 break;
    40             case LOCAL_GL_UNSIGNED_BYTE:
    41                 return sizeof(GLubyte);
    42                 break;
    43             case LOCAL_GL_SHORT:
    44                 return sizeof(GLshort);
    45                 break;
    46             case LOCAL_GL_UNSIGNED_SHORT:
    47                 return sizeof(GLushort);
    48                 break;
    49             // XXX case LOCAL_GL_FIXED:
    50             case LOCAL_GL_FLOAT:
    51                 return sizeof(GLfloat);
    52                 break;
    53             default:
    54                 NS_ERROR("Should never get here!");
    55                 return 0;
    56         }
    57     }
    59     GLuint actualStride() const {
    60         if (stride) return stride;
    61         return size * componentSize();
    62     }
    63 };
    65 } // namespace mozilla
    67 inline void ImplCycleCollectionUnlink(mozilla::WebGLVertexAttribData& aField)
    68 {
    69   aField.buf = nullptr;
    70 }
    72 inline void
    73 ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
    74                             mozilla::WebGLVertexAttribData& aField,
    75                             const char* aName,
    76                             uint32_t aFlags = 0)
    77 {
    78   CycleCollectionNoteChild(aCallback, aField.buf.get(), aName, aFlags);
    79 }
    81 #endif

mercurial