1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/src/WebGLUniformInfo.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef WEBGLUNIFORMINFO_H_ 1.10 +#define WEBGLUNIFORMINFO_H_ 1.11 + 1.12 +#include "angle/ShaderLang.h" 1.13 + 1.14 +namespace mozilla { 1.15 + 1.16 +struct WebGLUniformInfo { 1.17 + uint32_t arraySize; 1.18 + bool isArray; 1.19 + ShDataType type; 1.20 + 1.21 + WebGLUniformInfo(uint32_t s = 0, bool a = false, ShDataType t = SH_NONE) 1.22 + : arraySize(s), isArray(a), type(t) {} 1.23 + 1.24 + int ElementSize() const { 1.25 + switch (type) { 1.26 + case SH_INT: 1.27 + case SH_FLOAT: 1.28 + case SH_BOOL: 1.29 + case SH_SAMPLER_2D: 1.30 + case SH_SAMPLER_CUBE: 1.31 + return 1; 1.32 + case SH_INT_VEC2: 1.33 + case SH_FLOAT_VEC2: 1.34 + case SH_BOOL_VEC2: 1.35 + return 2; 1.36 + case SH_INT_VEC3: 1.37 + case SH_FLOAT_VEC3: 1.38 + case SH_BOOL_VEC3: 1.39 + return 3; 1.40 + case SH_INT_VEC4: 1.41 + case SH_FLOAT_VEC4: 1.42 + case SH_BOOL_VEC4: 1.43 + case SH_FLOAT_MAT2: 1.44 + return 4; 1.45 + case SH_FLOAT_MAT3: 1.46 + return 9; 1.47 + case SH_FLOAT_MAT4: 1.48 + return 16; 1.49 + default: 1.50 + MOZ_ASSERT(false); // should never get here 1.51 + return 0; 1.52 + } 1.53 + } 1.54 +}; 1.55 + 1.56 +} // namespace mozilla 1.57 + 1.58 +#endif