Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc

Issue 262793002: Revert of Optimize GLES2DecoderImpl::ApplyDirtyState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index 0b829f3fcd752b214d4e8db2a00ebe964be1a108..b1ed1dfaf390f28b4d09e67ff880e4acf41d2ffa 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -53,15 +53,7 @@
client_vertex_shader_id_(121),
client_fragment_shader_id_(122),
client_query_id_(123),
- client_vertexarray_id_(124),
- ignore_cached_state_for_test_(GetParam()),
- cached_color_mask_red_(true),
- cached_color_mask_green_(true),
- cached_color_mask_blue_(true),
- cached_color_mask_alpha_(true),
- cached_depth_mask_(true),
- cached_stencil_front_mask_(0xFFFFFFFFU),
- cached_stencil_back_mask_(0xFFFFFFFFU) {
+ client_vertexarray_id_(124) {
memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_));
}
@@ -94,8 +86,7 @@
request_depth(false),
request_stencil(false),
bind_generates_resource(false),
- lose_context_when_out_of_memory(false) {
-}
+ lose_context_when_out_of_memory(false) {}
void GLES2DecoderTestBase::InitDecoder(const InitState& init) {
InitDecoderWithCommandLine(init, NULL);
@@ -316,7 +307,6 @@
std::vector<int32> attribs(attributes, attributes + arraysize(attributes));
decoder_.reset(GLES2Decoder::Create(group_.get()));
- decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_);
decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
decoder_->Initialize(surface_,
context_,
@@ -565,7 +555,9 @@
EXPECT_CALL(*gl_, ClearColor(0.0f, 0.0f, 0.0f, 0.0f))
.Times(1)
.RetiresOnSaturation();
- SetupExpectationsForColorMask(true, true, true, true);
+ EXPECT_CALL(*gl_, ColorMask(true, true, true, true))
+ .Times(1)
+ .RetiresOnSaturation();
}
if ((clear_bits & GL_STENCIL_BUFFER_BIT) != 0) {
EXPECT_CALL(*gl_, ClearStencil(0))
@@ -579,9 +571,13 @@
EXPECT_CALL(*gl_, ClearDepth(1.0f))
.Times(1)
.RetiresOnSaturation();
- SetupExpectationsForDepthMask(true);
- }
- SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, false);
+ EXPECT_CALL(*gl_, DepthMask(1))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
+ EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST))
+ .Times(1)
+ .RetiresOnSaturation();
EXPECT_CALL(*gl_, Clear(clear_bits))
.Times(1)
.RetiresOnSaturation();
@@ -651,98 +647,6 @@
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
}
-void GLES2DecoderTestBase::SetupExpectationsForColorMask(bool red,
- bool green,
- bool blue,
- bool alpha) {
- if (ignore_cached_state_for_test_ || cached_color_mask_red_ != red ||
- cached_color_mask_green_ != green || cached_color_mask_blue_ != blue ||
- cached_color_mask_alpha_ != alpha) {
- cached_color_mask_red_ = red;
- cached_color_mask_green_ = green;
- cached_color_mask_blue_ = blue;
- cached_color_mask_alpha_ = alpha;
- EXPECT_CALL(*gl_, ColorMask(red, green, blue, alpha))
- .Times(1)
- .RetiresOnSaturation();
- }
-}
-
-void GLES2DecoderTestBase::SetupExpectationsForDepthMask(bool mask) {
- if (ignore_cached_state_for_test_ || cached_depth_mask_ != mask) {
- cached_depth_mask_ = mask;
- EXPECT_CALL(*gl_, DepthMask(mask)).Times(1).RetiresOnSaturation();
- }
-}
-
-void GLES2DecoderTestBase::SetupExpectationsForEnableDisable(GLenum cap,
- bool enable) {
- switch (cap) {
- case GL_BLEND:
- if (enable_flags_.cached_blend == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_blend = enable;
- break;
- case GL_CULL_FACE:
- if (enable_flags_.cached_cull_face == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_cull_face = enable;
- break;
- case GL_DEPTH_TEST:
- if (enable_flags_.cached_depth_test == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_depth_test = enable;
- break;
- case GL_DITHER:
- if (enable_flags_.cached_dither == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_dither = enable;
- break;
- case GL_POLYGON_OFFSET_FILL:
- if (enable_flags_.cached_polygon_offset_fill == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_polygon_offset_fill = enable;
- break;
- case GL_SAMPLE_ALPHA_TO_COVERAGE:
- if (enable_flags_.cached_sample_alpha_to_coverage == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_sample_alpha_to_coverage = enable;
- break;
- case GL_SAMPLE_COVERAGE:
- if (enable_flags_.cached_sample_coverage == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_sample_coverage = enable;
- break;
- case GL_SCISSOR_TEST:
- if (enable_flags_.cached_scissor_test == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_scissor_test = enable;
- break;
- case GL_STENCIL_TEST:
- if (enable_flags_.cached_stencil_test == enable &&
- !ignore_cached_state_for_test_)
- return;
- enable_flags_.cached_stencil_test = enable;
- break;
- default:
- NOTREACHED();
- return;
- }
- if (enable) {
- EXPECT_CALL(*gl_, Enable(cap)).Times(1).RetiresOnSaturation();
- } else {
- EXPECT_CALL(*gl_, Disable(cap)).Times(1).RetiresOnSaturation();
- }
-}
-
void GLES2DecoderTestBase::SetupExpectationsForApplyingDirtyState(
bool framebuffer_is_rgb,
bool framebuffer_has_depth,
@@ -752,60 +656,87 @@
bool depth_enabled,
GLuint front_stencil_mask,
GLuint back_stencil_mask,
- bool stencil_enabled) {
- bool color_mask_red = (color_bits & 0x1000) != 0;
- bool color_mask_green = (color_bits & 0x0100) != 0;
- bool color_mask_blue = (color_bits & 0x0010) != 0;
- bool color_mask_alpha = (color_bits & 0x0001) && !framebuffer_is_rgb;
-
- SetupExpectationsForColorMask(
- color_mask_red, color_mask_green, color_mask_blue, color_mask_alpha);
- SetupExpectationsForDepthMask(depth_mask);
-
- if (ignore_cached_state_for_test_ ||
- cached_stencil_front_mask_ != front_stencil_mask) {
- cached_stencil_front_mask_ = front_stencil_mask;
- EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, front_stencil_mask))
- .Times(1)
- .RetiresOnSaturation();
- }
-
- if (ignore_cached_state_for_test_ ||
- cached_stencil_back_mask_ != back_stencil_mask) {
- cached_stencil_back_mask_ = back_stencil_mask;
- EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, back_stencil_mask))
- .Times(1)
- .RetiresOnSaturation();
- }
-
- SetupExpectationsForEnableDisable(GL_DEPTH_TEST,
- framebuffer_has_depth && depth_enabled);
- SetupExpectationsForEnableDisable(GL_STENCIL_TEST,
- framebuffer_has_stencil && stencil_enabled);
+ bool stencil_enabled,
+ bool cull_face_enabled,
+ bool scissor_test_enabled,
+ bool blend_enabled) {
+ EXPECT_CALL(*gl_, ColorMask(
+ (color_bits & 0x1000) != 0,
+ (color_bits & 0x0100) != 0,
+ (color_bits & 0x0010) != 0,
+ (color_bits & 0x0001) && !framebuffer_is_rgb))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, DepthMask(depth_mask))
+ .Times(1)
+ .RetiresOnSaturation();
+ if (framebuffer_has_depth && depth_enabled) {
+ EXPECT_CALL(*gl_, Enable(GL_DEPTH_TEST))
+ .Times(1)
+ .RetiresOnSaturation();
+ } else {
+ EXPECT_CALL(*gl_, Disable(GL_DEPTH_TEST))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
+ EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, front_stencil_mask))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, back_stencil_mask))
+ .Times(1)
+ .RetiresOnSaturation();
+ if (framebuffer_has_stencil && stencil_enabled) {
+ EXPECT_CALL(*gl_, Enable(GL_STENCIL_TEST))
+ .Times(1)
+ .RetiresOnSaturation();
+ } else {
+ EXPECT_CALL(*gl_, Disable(GL_STENCIL_TEST))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
+ if (cull_face_enabled) {
+ EXPECT_CALL(*gl_, Enable(GL_CULL_FACE))
+ .Times(1)
+ .RetiresOnSaturation();
+ } else {
+ EXPECT_CALL(*gl_, Disable(GL_CULL_FACE))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
+ if (scissor_test_enabled) {
+ EXPECT_CALL(*gl_, Enable(GL_SCISSOR_TEST))
+ .Times(1)
+ .RetiresOnSaturation();
+ } else {
+ EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
+ if (blend_enabled) {
+ EXPECT_CALL(*gl_, Enable(GL_BLEND))
+ .Times(1)
+ .RetiresOnSaturation();
+ } else {
+ EXPECT_CALL(*gl_, Disable(GL_BLEND))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
}
void GLES2DecoderTestBase::SetupExpectationsForApplyingDefaultDirtyState() {
- SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
- false, // Framebuffer has depth
- false, // Framebuffer has stencil
- 0x1111, // color bits
- true, // depth mask
- false, // depth enabled
- 0, // front stencil mask
- 0, // back stencil mask
- false); // stencil enabled
-}
-
-GLES2DecoderTestBase::EnableFlags::EnableFlags()
- : cached_blend(false),
- cached_cull_face(false),
- cached_depth_test(false),
- cached_dither(true),
- cached_polygon_offset_fill(false),
- cached_sample_alpha_to_coverage(false),
- cached_sample_coverage(false),
- cached_scissor_test(false),
- cached_stencil_test(false) {
+ SetupExpectationsForApplyingDirtyState(
+ false, // Framebuffer is RGB
+ false, // Framebuffer has depth
+ false, // Framebuffer has stencil
+ 0x1111, // color bits
+ true, // depth mask
+ false, // depth enabled
+ 0, // front stencil mask
+ 0, // back stencil mask
+ false, // stencil enabled
+ false, // cull_face_enabled
+ false, // scissor_test_enabled
+ false); // blend_enabled
}
void GLES2DecoderTestBase::DoBindFramebuffer(
@@ -1377,19 +1308,6 @@
EXPECT_EQ(error::kNoError, ExecuteCmd(link_cmd));
}
-void GLES2DecoderTestBase::DoEnableDisable(GLenum cap, bool enable) {
- SetupExpectationsForEnableDisable(cap, enable);
- if (enable) {
- cmds::Enable cmd;
- cmd.Init(cap);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- } else {
- cmds::Disable cmd;
- cmd.Init(cap);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-}
-
void GLES2DecoderTestBase::DoEnableVertexAttribArray(GLint index) {
EXPECT_CALL(*gl_, EnableVertexAttribArray(index))
.Times(1)
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698