1#include "precompiled.h"
2//
3// Copyright (c) 2010-2013 The ANGLE Project Authors. All rights reserved.
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#include "libGLESv2/Uniform.h"
9
10#include "libGLESv2/utilities.h"
11
12namespace gl
13{
14
15Uniform::Uniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize)
16    : type(type), precision(precision), name(name), arraySize(arraySize)
17{
18    int bytes = gl::UniformInternalSize(type) * elementCount();
19    data = new unsigned char[bytes];
20    memset(data, 0, bytes);
21    dirty = true;
22
23    psRegisterIndex = -1;
24    vsRegisterIndex = -1;
25    registerCount = VariableRowCount(type) * elementCount();
26}
27
28Uniform::~Uniform()
29{
30    delete[] data;
31}
32
33bool Uniform::isArray() const
34{
35    return arraySize > 0;
36}
37
38unsigned int Uniform::elementCount() const
39{
40    return arraySize > 0 ? arraySize : 1;
41}
42
43}
44