Hash :
a328d569
Author :
Date :
2014-07-01T13:52:40
Removed sampler state getters and setters from gl::Texture BUG=angle:688 Change-Id: I3f203e4d10059c12a0c00e967ad6c7d3b3a18074 Reviewed-on: https://chromium-review.googlesource.com/206335 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Brandon Jones <bajones@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
#include "precompiled.h"
//
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2
#include "libGLESv2/angletypes.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/VertexAttribute.h"
namespace gl
{
SamplerState::SamplerState()
: minFilter(GL_NEAREST_MIPMAP_LINEAR),
magFilter(GL_LINEAR),
wrapS(GL_REPEAT),
wrapT(GL_REPEAT),
wrapR(GL_REPEAT),
maxAnisotropy(1.0f),
baseLevel(0),
maxLevel(1000),
minLod(-1000.0f),
maxLod(1000.0f),
compareMode(GL_NONE),
compareFunc(GL_LEQUAL),
swizzleRed(GL_RED),
swizzleGreen(GL_GREEN),
swizzleBlue(GL_BLUE),
swizzleAlpha(GL_ALPHA)
{}
bool SamplerState::swizzleRequired() const
{
return swizzleRed != GL_RED || swizzleGreen != GL_GREEN ||
swizzleBlue != GL_BLUE || swizzleAlpha != GL_ALPHA;
}
static void MinMax(int a, int b, int *minimum, int *maximum)
{
if (a < b)
{
*minimum = a;
*maximum = b;
}
else
{
*minimum = b;
*maximum = a;
}
}
bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection)
{
int minSourceX, maxSourceX, minSourceY, maxSourceY;
MinMax(source.x, source.x + source.width, &minSourceX, &maxSourceX);
MinMax(source.y, source.y + source.height, &minSourceY, &maxSourceY);
int minClipX, maxClipX, minClipY, maxClipY;
MinMax(clip.x, clip.x + clip.width, &minClipX, &maxClipX);
MinMax(clip.y, clip.y + clip.height, &minClipY, &maxClipY);
if (minSourceX >= maxClipX || maxSourceX <= minClipX || minSourceY >= maxClipY || maxSourceY <= minClipY)
{
if (intersection)
{
intersection->x = minSourceX;
intersection->y = maxSourceY;
intersection->width = maxSourceX - minSourceX;
intersection->height = maxSourceY - minSourceY;
}
return false;
}
else
{
if (intersection)
{
intersection->x = std::max(minSourceX, minClipX);
intersection->y = std::max(minSourceY, minClipY);
intersection->width = std::min(maxSourceX, maxClipX) - std::max(minSourceX, minClipX);
intersection->height = std::min(maxSourceY, maxClipY) - std::max(minSourceY, minClipY);
}
return true;
}
}
VertexFormat::VertexFormat()
: mType(GL_NONE),
mNormalized(GL_FALSE),
mComponents(0),
mPureInteger(false)
{}
VertexFormat::VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger)
: mType(type),
mNormalized(normalized),
mComponents(components),
mPureInteger(pureInteger)
{
// Float data can not be normalized, so ignore the user setting
if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
{
mNormalized = GL_FALSE;
}
}
VertexFormat::VertexFormat(const VertexAttribute &attrib)
: mType(attrib.type),
mNormalized(attrib.normalized ? GL_TRUE : GL_FALSE),
mComponents(attrib.size),
mPureInteger(attrib.pureInteger)
{
// Ensure we aren't initializing a vertex format which should be using
// the current-value type
ASSERT(attrib.enabled);
// Float data can not be normalized, so ignore the user setting
if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
{
mNormalized = GL_FALSE;
}
}
VertexFormat::VertexFormat(const VertexAttribute &attrib, GLenum currentValueType)
: mType(attrib.type),
mNormalized(attrib.normalized ? GL_TRUE : GL_FALSE),
mComponents(attrib.size),
mPureInteger(attrib.pureInteger)
{
if (!attrib.enabled)
{
mType = currentValueType;
mNormalized = GL_FALSE;
mComponents = 4;
mPureInteger = (currentValueType != GL_FLOAT);
}
// Float data can not be normalized, so ignore the user setting
if (mType == GL_FLOAT || mType == GL_HALF_FLOAT || mType == GL_FIXED)
{
mNormalized = GL_FALSE;
}
}
void VertexFormat::GetInputLayout(VertexFormat *inputLayout,
ProgramBinary *programBinary,
const VertexAttribute *attributes,
const gl::VertexAttribCurrentValueData *currentValues)
{
for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{
int semanticIndex = programBinary->getSemanticIndex(attributeIndex);
if (semanticIndex != -1)
{
inputLayout[semanticIndex] = VertexFormat(attributes[attributeIndex], currentValues[attributeIndex].Type);
}
}
}
bool VertexFormat::operator==(const VertexFormat &other) const
{
return (mType == other.mType &&
mComponents == other.mComponents &&
mNormalized == other.mNormalized &&
mPureInteger == other.mPureInteger );
}
bool VertexFormat::operator!=(const VertexFormat &other) const
{
return !(*this == other);
}
bool VertexFormat::operator<(const VertexFormat& other) const
{
if (mType != other.mType)
{
return mType < other.mType;
}
if (mNormalized != other.mNormalized)
{
return mNormalized < other.mNormalized;
}
if (mComponents != other.mComponents)
{
return mComponents < other.mComponents;
}
return mPureInteger < other.mPureInteger;
}
}