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