OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 using ::testing::SaveArg; | 41 using ::testing::SaveArg; |
42 using ::testing::SetArrayArgument; | 42 using ::testing::SetArrayArgument; |
43 using ::testing::SetArgumentPointee; | 43 using ::testing::SetArgumentPointee; |
44 using ::testing::SetArgPointee; | 44 using ::testing::SetArgPointee; |
45 using ::testing::StrEq; | 45 using ::testing::StrEq; |
46 using ::testing::StrictMock; | 46 using ::testing::StrictMock; |
47 | 47 |
48 namespace gpu { | 48 namespace gpu { |
49 namespace gles2 { | 49 namespace gles2 { |
50 | 50 |
| 51 namespace { |
| 52 |
| 53 void SetupUpdateES3UnpackParametersExpectations( |
| 54 ::gfx::MockGLInterface* gl, |
| 55 GLint row_length, |
| 56 GLint image_height, |
| 57 GLint skip_pixels, |
| 58 GLint skip_rows, |
| 59 GLint skip_images) { |
| 60 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_ROW_LENGTH, row_length)) |
| 61 .Times(1) |
| 62 .RetiresOnSaturation(); |
| 63 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height)) |
| 64 .Times(1) |
| 65 .RetiresOnSaturation(); |
| 66 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows)) |
| 67 .Times(1) |
| 68 .RetiresOnSaturation(); |
| 69 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels)) |
| 70 .Times(1) |
| 71 .RetiresOnSaturation(); |
| 72 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_SKIP_IMAGES, skip_images)) |
| 73 .Times(1) |
| 74 .RetiresOnSaturation(); |
| 75 } |
| 76 |
| 77 } // namespace anonymous |
| 78 |
51 using namespace cmds; | 79 using namespace cmds; |
52 | 80 |
53 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest { | 81 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest { |
54 public: | 82 public: |
55 GLES2DecoderRestoreStateTest() {} | 83 GLES2DecoderRestoreStateTest() {} |
56 | 84 |
57 protected: | 85 protected: |
58 void AddExpectationsForActiveTexture(GLenum unit); | 86 void AddExpectationsForActiveTexture(GLenum unit); |
59 void AddExpectationsForBindTexture(GLenum target, GLuint id); | 87 void AddExpectationsForBindTexture(GLenum target, GLuint id); |
60 void InitializeContextState(ContextState* state, | 88 void InitializeContextState(ContextState* state, |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 417 |
390 // Test new and cached state changes. | 418 // Test new and cached state changes. |
391 for (int n = 0; n < 3; n++) { | 419 for (int n = 0; n < 3; n++) { |
392 enable_state = !enable_state; | 420 enable_state = !enable_state; |
393 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); | 421 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); |
394 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); | 422 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); |
395 } | 423 } |
396 } | 424 } |
397 } | 425 } |
398 | 426 |
| 427 TEST_P(GLES3DecoderTest, ES3PixelStoreiWithPixelUnpackBuffer) { |
| 428 // Without PIXEL_UNPACK_BUFFER bound, PixelStorei with unpack parameters |
| 429 // is cached and not passed down to GL. |
| 430 EXPECT_CALL(*gl_, PixelStorei(_, _)).Times(0); |
| 431 cmds::PixelStorei cmd; |
| 432 cmd.Init(GL_UNPACK_SKIP_ROWS, 2); |
| 433 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 434 |
| 435 // When a PIXEL_UNPACK_BUFFER is bound, all cached unpack parameters are |
| 436 // applied to GL. |
| 437 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 0, 0, 0, 2, 0); |
| 438 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, client_buffer_id_, kServiceBufferId); |
| 439 |
| 440 // Now with a bound PIXEL_UNPACK_BUFFER, all PixelStorei calls with unpack |
| 441 // parameters are applied to GL. |
| 442 EXPECT_CALL(*gl_, PixelStorei(GL_UNPACK_ROW_LENGTH, 16)) |
| 443 .Times(1) |
| 444 .RetiresOnSaturation(); |
| 445 cmd.Init(GL_UNPACK_ROW_LENGTH, 16); |
| 446 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 447 |
| 448 // Now unbind PIXEL_UNPACK_BUFFER, all ES3 unpack parameters are set back to |
| 449 // 0. |
| 450 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 0, 0, 0, 0, 0); |
| 451 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0, 0); |
| 452 |
| 453 // Again, PixelStorei calls with unpack parameters are cached. |
| 454 EXPECT_CALL(*gl_, PixelStorei(_, _)).Times(0); |
| 455 cmd.Init(GL_UNPACK_SKIP_ROWS, 3); |
| 456 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 457 |
| 458 // Bind a PIXEL_UNPACK_BUFFER again. |
| 459 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 16, 0, 0, 3, 0); |
| 460 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, client_buffer_id_, kServiceBufferId); |
| 461 } |
| 462 |
399 // TODO(vmiura): Tests for VAO restore. | 463 // TODO(vmiura): Tests for VAO restore. |
400 | 464 |
401 // TODO(vmiura): Tests for ContextState::RestoreAttribute(). | 465 // TODO(vmiura): Tests for ContextState::RestoreAttribute(). |
402 | 466 |
403 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings(). | 467 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings(). |
404 | 468 |
405 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). | 469 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). |
406 | 470 |
407 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings(). | 471 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings(). |
408 | 472 |
409 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). | 473 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). |
410 | 474 |
411 // TODO(vmiura): Tests for ContextState::RestoreGlobalState(). | 475 // TODO(vmiura): Tests for ContextState::RestoreGlobalState(). |
412 | 476 |
413 } // namespace gles2 | 477 } // namespace gles2 |
414 } // namespace gpu | 478 } // namespace gpu |
OLD | NEW |