Commit a43994c9 by Lingfeng Yang Committed by Commit Bot

GLES1: glColor4(f|ub|x)

BUG=angleproject:2306 Change-Id: I4a57732d4c470c821a3847a7ee012cf3ccbba197 Reviewed-on: https://chromium-review.googlesource.com/986454 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 489243fb
...@@ -6397,6 +6397,10 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -6397,6 +6397,10 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_INT; *type = GL_INT;
*numParams = 1; *numParams = 1;
return true; return true;
case GL_CURRENT_COLOR:
*type = GL_FLOAT;
*numParams = 4;
return true;
} }
} }
......
...@@ -51,17 +51,20 @@ void Context::clipPlanex(GLenum plane, const GLfixed *equation) ...@@ -51,17 +51,20 @@ void Context::clipPlanex(GLenum plane, const GLfixed *equation)
void Context::color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) void Context::color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
{ {
UNIMPLEMENTED(); mGLState.gles1().setCurrentColor({red, green, blue, alpha});
} }
void Context::color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) void Context::color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
{ {
UNIMPLEMENTED(); mGLState.gles1().setCurrentColor(
{normalizedToFloat<uint8_t>(red), normalizedToFloat<uint8_t>(green),
normalizedToFloat<uint8_t>(blue), normalizedToFloat<uint8_t>(alpha)});
} }
void Context::color4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) void Context::color4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
{ {
UNIMPLEMENTED(); mGLState.gles1().setCurrentColor(
{FixedToFloat(red), FixedToFloat(green), FixedToFloat(blue), FixedToFloat(alpha)});
} }
void Context::colorPointer(GLint size, GLenum type, GLsizei stride, const void *ptr) void Context::colorPointer(GLint size, GLenum type, GLsizei stride, const void *ptr)
......
...@@ -159,4 +159,14 @@ unsigned int GLES1State::getClientTextureUnit() const ...@@ -159,4 +159,14 @@ unsigned int GLES1State::getClientTextureUnit() const
return mClientActiveTexture; return mClientActiveTexture;
} }
void GLES1State::setCurrentColor(ColorF color)
{
mCurrentColor = color;
}
const ColorF &GLES1State::getCurrentColor() const
{
return mCurrentColor;
}
} // namespace gl } // namespace gl
...@@ -121,6 +121,8 @@ class GLES1State final : angle::NonCopyable ...@@ -121,6 +121,8 @@ class GLES1State final : angle::NonCopyable
void setAlphaFunc(AlphaTestFunc func, GLfloat ref); void setAlphaFunc(AlphaTestFunc func, GLfloat ref);
void setClientTextureUnit(unsigned int unit); void setClientTextureUnit(unsigned int unit);
unsigned int getClientTextureUnit() const; unsigned int getClientTextureUnit() const;
void setCurrentColor(ColorF color);
const ColorF &getCurrentColor() const;
private: private:
friend class State; friend class State;
......
...@@ -1930,6 +1930,15 @@ void State::getFloatv(GLenum pname, GLfloat *params) ...@@ -1930,6 +1930,15 @@ void State::getFloatv(GLenum pname, GLfloat *params)
case GL_ALPHA_TEST_REF: case GL_ALPHA_TEST_REF:
*params = mGLES1State.mAlphaTestRef; *params = mGLES1State.mAlphaTestRef;
break; break;
case GL_CURRENT_COLOR:
{
const auto &color = mGLES1State.mCurrentColor;
params[0] = color.red;
params[1] = color.green;
params[2] = color.blue;
params[3] = color.alpha;
break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;
......
...@@ -97,19 +97,19 @@ bool ValidateClipPlanex(Context *context, GLenum plane, const GLfixed *equation) ...@@ -97,19 +97,19 @@ bool ValidateClipPlanex(Context *context, GLenum plane, const GLfixed *equation)
bool ValidateColor4f(Context *context, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) bool ValidateColor4f(Context *context, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
{ {
UNIMPLEMENTED(); ANGLE_VALIDATE_IS_GLES1(context);
return true; return true;
} }
bool ValidateColor4ub(Context *context, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) bool ValidateColor4ub(Context *context, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
{ {
UNIMPLEMENTED(); ANGLE_VALIDATE_IS_GLES1(context);
return true; return true;
} }
bool ValidateColor4x(Context *context, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) bool ValidateColor4x(Context *context, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
{ {
UNIMPLEMENTED(); ANGLE_VALIDATE_IS_GLES1(context);
return true; return true;
} }
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
'<(angle_path)/src/tests/gl_tests/GeometryShaderTest.cpp', '<(angle_path)/src/tests/gl_tests/GeometryShaderTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/AlphaFuncTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/AlphaFuncTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/ClientActiveTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/ClientActiveTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/CurrentColorTest.cpp',
'<(angle_path)/src/tests/gl_tests/GLSLTest.cpp', '<(angle_path)/src/tests/gl_tests/GLSLTest.cpp',
'<(angle_path)/src/tests/gl_tests/ImageTest.cpp', '<(angle_path)/src/tests/gl_tests/ImageTest.cpp',
'<(angle_path)/src/tests/gl_tests/IncompleteTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/IncompleteTextureTest.cpp',
......
//
// Copyright 2018 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.
//
// CurrentColorTest.cpp: Tests basic usage of glClientActiveTexture.
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
#include "random_utils.h"
#include <stdint.h>
using namespace angle;
class CurrentColorTest : public ANGLETest
{
protected:
CurrentColorTest()
{
setWindowWidth(32);
setWindowHeight(32);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
}
};
// State query: Checks the initial state is correct.
TEST_P(CurrentColorTest, InitialState)
{
const GLColor32F kFloatWhite(1.0f, 1.0f, 1.0f, 1.0f);
GLColor32F actualColor;
glGetFloatv(GL_CURRENT_COLOR, &actualColor.R);
EXPECT_GL_NO_ERROR();
EXPECT_EQ(kFloatWhite, actualColor);
}
// Set test: Checks that the current color is properly set and retrieved.
TEST_P(CurrentColorTest, Set)
{
float epsilon = 0.00001f;
glColor4f(0.1f, 0.2f, 0.3f, 0.4f);
EXPECT_GL_NO_ERROR();
GLColor32F floatColor;
glGetFloatv(GL_CURRENT_COLOR, &floatColor.R);
EXPECT_GL_NO_ERROR();
EXPECT_EQ(GLColor32F(0.1f, 0.2f, 0.3f, 0.4f), floatColor);
glColor4ub(0xff, 0x0, 0x55, 0x33);
glGetFloatv(GL_CURRENT_COLOR, &floatColor.R);
EXPECT_GL_NO_ERROR();
EXPECT_NEAR(1.0f, floatColor.R, epsilon);
EXPECT_NEAR(0.0f, floatColor.G, epsilon);
EXPECT_NEAR(1.0f / 3.0f, floatColor.B, epsilon);
EXPECT_NEAR(0.2f, floatColor.A, epsilon);
glColor4x(0x10000, 0x0, 0x3333, 0x5555);
glGetFloatv(GL_CURRENT_COLOR, &floatColor.R);
EXPECT_GL_NO_ERROR();
EXPECT_NEAR(1.0f, floatColor.R, epsilon);
EXPECT_NEAR(0.0f, floatColor.G, epsilon);
EXPECT_NEAR(0.2f, floatColor.B, epsilon);
EXPECT_NEAR(1.0f / 3.0f, floatColor.A, epsilon);
}
ANGLE_INSTANTIATE_TEST(CurrentColorTest, ES1_D3D11(), ES1_OPENGL(), ES1_OPENGLES());
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