Commit 2a64ee44 by Geoff Lang Committed by Shannon Woods

Templated the Color structure so it can be used for the new integer and unsigned…

Templated the Color structure so it can be used for the new integer and unsigned integer color types. TRAC #23256 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang
parent 49a8887b
......@@ -22,8 +22,6 @@
namespace gl
{
struct Color;
int UniformComponentCount(GLenum type);
GLenum UniformComponentType(GLenum type);
size_t UniformComponentSize(GLenum type);
......
......@@ -148,7 +148,7 @@ class VertexAttribute
// Helper structure to store all raw state
struct State
{
Color colorClearValue;
ColorF colorClearValue;
GLclampf depthClearValue;
int stencilClearValue;
......@@ -157,7 +157,7 @@ struct State
Rectangle scissor;
BlendState blend;
Color blendColor;
ColorF blendColor;
bool sampleCoverage;
GLclampf sampleCoverageValue;
bool sampleCoverageInvert;
......
......@@ -29,14 +29,19 @@ enum SamplerType
SAMPLER_VERTEX
};
template <typename T>
struct Color
{
float red;
float green;
float blue;
float alpha;
T red;
T green;
T blue;
T alpha;
};
typedef Color<float> ColorF;
typedef Color<int> ColorI;
typedef Color<unsigned int> ColorUI;
struct Rectangle
{
int x;
......@@ -125,7 +130,7 @@ struct ClearParameters
{
GLbitfield mask;
Color colorClearValue;
ColorF colorClearValue;
bool colorMaskRed;
bool colorMaskGreen;
bool colorMaskBlue;
......
......@@ -118,7 +118,7 @@ class Renderer
virtual bool setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]) = 0;
virtual void setRasterizerState(const gl::RasterizerState &rasterState) = 0;
virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
virtual void setBlendState(const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask) = 0;
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW) = 0;
......
......@@ -700,12 +700,12 @@ void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState)
mForceSetRasterState = false;
}
void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask)
{
if (mForceSetBlendState ||
memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0 ||
memcmp(&blendColor, &mCurBlendColor, sizeof(gl::Color)) != 0 ||
memcmp(&blendColor, &mCurBlendColor, sizeof(gl::ColorF)) != 0 ||
sampleMask != mCurSampleMask)
{
ID3D11BlendState *dxBlendState = mStateCache.getBlendState(blendState);
......@@ -3500,7 +3500,7 @@ static inline unsigned int getFastPixelCopySize(DXGI_FORMAT sourceFormat, GLenum
}
static inline void readPixelColor(const unsigned char *data, DXGI_FORMAT format, unsigned int x,
unsigned int y, int inputPitch, gl::Color *outColor)
unsigned int y, int inputPitch, gl::ColorF *outColor)
{
switch (format)
{
......@@ -3616,7 +3616,7 @@ static inline void readPixelColor(const unsigned char *data, DXGI_FORMAT format,
}
}
static inline void writePixelColor(const gl::Color &color, GLenum format, GLenum type, unsigned int x,
static inline void writePixelColor(const gl::ColorF &color, GLenum format, GLenum type, unsigned int x,
unsigned int y, int outputPitch, void *outData)
{
unsigned char* byteData = reinterpret_cast<unsigned char*>(outData);
......@@ -3846,7 +3846,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
}
else
{
gl::Color pixelColor;
gl::ColorF pixelColor;
for (int j = 0; j < area.height; j++)
{
for (int i = 0; i < area.width; i++)
......
......@@ -60,7 +60,7 @@ class Renderer11 : public Renderer
virtual bool setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
virtual void setRasterizerState(const gl::RasterizerState &rasterState);
virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
virtual void setBlendState(const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask);
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW);
......@@ -291,7 +291,7 @@ class Renderer11 : public Renderer
// Currently applied blend state
bool mForceSetBlendState;
gl::BlendState mCurBlendState;
gl::Color mCurBlendColor;
gl::ColorF mCurBlendColor;
unsigned int mCurSampleMask;
// Currently applied rasterizer state
......
......@@ -7,6 +7,8 @@
// Renderer9.cpp: Implements a back-end specific class for the D3D9 renderer.
#include "common/utilities.h"
#include "libGLESv2/main.h"
#include "libGLESv2/Buffer.h"
#include "libGLESv2/Texture.h"
......@@ -815,10 +817,10 @@ void Renderer9::setRasterizerState(const gl::RasterizerState &rasterState)
mForceSetRasterState = false;
}
void Renderer9::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor, unsigned int sampleMask)
void Renderer9::setBlendState(const gl::BlendState &blendState, const gl::ColorF &blendColor, unsigned int sampleMask)
{
bool blendStateChanged = mForceSetBlendState || memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0;
bool blendColorChanged = mForceSetBlendState || memcmp(&blendColor, &mCurBlendColor, sizeof(gl::Color)) != 0;
bool blendColorChanged = mForceSetBlendState || memcmp(&blendColor, &mCurBlendColor, sizeof(gl::ColorF)) != 0;
bool sampleMaskChanged = mForceSetBlendState || sampleMask != mCurSampleMask;
if (blendStateChanged || blendColorChanged)
......
......@@ -74,7 +74,7 @@ class Renderer9 : public Renderer
virtual bool setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
virtual void setRasterizerState(const gl::RasterizerState &rasterState);
virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
virtual void setBlendState(const gl::BlendState &blendState, const gl::ColorF &blendColor,
unsigned int sampleMask);
virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
int stencilBackRef, bool frontFaceCCW);
......@@ -334,7 +334,7 @@ class Renderer9 : public Renderer
bool mForceSetBlendState;
gl::BlendState mCurBlendState;
gl::Color mCurBlendColor;
gl::ColorF mCurBlendColor;
GLuint mCurSampleMask;
// Currently applied sampler states
......
......@@ -236,7 +236,7 @@ void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, flo
}
void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z,
const gl::Color &color)
const gl::ColorF &color)
{
vertex->x = x;
vertex->y = y;
......
......@@ -61,7 +61,7 @@ struct PositionDepthColorVertex
float r, g, b, a;
};
void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z,
const gl::Color &color);
const gl::ColorF &color);
HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name);
......
......@@ -39,7 +39,7 @@ D3DCMPFUNC ConvertComparison(GLenum comparison)
return d3dComp;
}
D3DCOLOR ConvertColor(gl::Color color)
D3DCOLOR ConvertColor(gl::ColorF color)
{
return D3DCOLOR_RGBA(gl::unorm<8>(color.red),
gl::unorm<8>(color.green),
......
......@@ -10,7 +10,7 @@
#ifndef LIBGLESV2_RENDERER_RENDERER9_UTILS_H
#define LIBGLESV2_RENDERER_RENDERER9_UTILS_H
#include "common/utilities.h"
#include "libGLESv2/angletypes.h"
namespace rx
{
......@@ -19,7 +19,7 @@ namespace gl_d3d9
{
D3DCMPFUNC ConvertComparison(GLenum comparison);
D3DCOLOR ConvertColor(gl::Color color);
D3DCOLOR ConvertColor(gl::ColorF color);
D3DBLEND ConvertBlendFunc(GLenum blend);
D3DBLENDOP ConvertBlendOp(GLenum blendOp);
D3DSTENCILOP ConvertStencilOp(GLenum stencilOp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment