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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 using ::testing::StrictMock; | 48 using ::testing::StrictMock; |
49 | 49 |
50 namespace gpu { | 50 namespace gpu { |
51 namespace gles2 { | 51 namespace gles2 { |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 void SetupUpdateES3UnpackParametersExpectations( | 55 void SetupUpdateES3UnpackParametersExpectations( |
56 ::gfx::MockGLInterface* gl, | 56 ::gfx::MockGLInterface* gl, |
57 GLint row_length, | 57 GLint row_length, |
58 GLint image_height, | 58 GLint image_height) { |
59 GLint skip_pixels, | |
60 GLint skip_rows, | |
61 GLint skip_images) { | |
62 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_ROW_LENGTH, row_length)) | 59 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_ROW_LENGTH, row_length)) |
63 .Times(1) | 60 .Times(1) |
64 .RetiresOnSaturation(); | 61 .RetiresOnSaturation(); |
65 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height)) | 62 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height)) |
66 .Times(1) | 63 .Times(1) |
67 .RetiresOnSaturation(); | 64 .RetiresOnSaturation(); |
68 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows)) | |
69 .Times(1) | |
70 .RetiresOnSaturation(); | |
71 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels)) | |
72 .Times(1) | |
73 .RetiresOnSaturation(); | |
74 EXPECT_CALL(*gl, PixelStorei(GL_UNPACK_SKIP_IMAGES, skip_images)) | |
75 .Times(1) | |
76 .RetiresOnSaturation(); | |
77 } | 65 } |
78 | 66 |
79 } // namespace anonymous | 67 } // namespace anonymous |
80 | 68 |
81 using namespace cmds; | 69 using namespace cmds; |
82 | 70 |
83 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest { | 71 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest { |
84 public: | 72 public: |
85 GLES2DecoderRestoreStateTest() {} | 73 GLES2DecoderRestoreStateTest() {} |
86 | 74 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); | 412 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); |
425 } | 413 } |
426 } | 414 } |
427 } | 415 } |
428 | 416 |
429 TEST_P(GLES3DecoderTest, ES3PixelStoreiWithPixelUnpackBuffer) { | 417 TEST_P(GLES3DecoderTest, ES3PixelStoreiWithPixelUnpackBuffer) { |
430 // Without PIXEL_UNPACK_BUFFER bound, PixelStorei with unpack parameters | 418 // Without PIXEL_UNPACK_BUFFER bound, PixelStorei with unpack parameters |
431 // is cached and not passed down to GL. | 419 // is cached and not passed down to GL. |
432 EXPECT_CALL(*gl_, PixelStorei(_, _)).Times(0); | 420 EXPECT_CALL(*gl_, PixelStorei(_, _)).Times(0); |
433 cmds::PixelStorei cmd; | 421 cmds::PixelStorei cmd; |
434 cmd.Init(GL_UNPACK_SKIP_ROWS, 2); | 422 cmd.Init(GL_UNPACK_ROW_LENGTH, 8); |
435 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 423 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
436 | 424 |
437 // When a PIXEL_UNPACK_BUFFER is bound, all cached unpack parameters are | 425 // When a PIXEL_UNPACK_BUFFER is bound, all cached unpack parameters are |
438 // applied to GL. | 426 // applied to GL. |
439 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 0, 0, 0, 2, 0); | 427 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 8, 0); |
440 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, client_buffer_id_, kServiceBufferId); | 428 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, client_buffer_id_, kServiceBufferId); |
441 | 429 |
442 // Now with a bound PIXEL_UNPACK_BUFFER, all PixelStorei calls with unpack | 430 // Now with a bound PIXEL_UNPACK_BUFFER, all PixelStorei calls with unpack |
443 // parameters are applied to GL. | 431 // parameters are applied to GL. |
444 EXPECT_CALL(*gl_, PixelStorei(GL_UNPACK_ROW_LENGTH, 16)) | 432 EXPECT_CALL(*gl_, PixelStorei(GL_UNPACK_ROW_LENGTH, 16)) |
445 .Times(1) | 433 .Times(1) |
446 .RetiresOnSaturation(); | 434 .RetiresOnSaturation(); |
447 cmd.Init(GL_UNPACK_ROW_LENGTH, 16); | 435 cmd.Init(GL_UNPACK_ROW_LENGTH, 16); |
448 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 436 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
449 | 437 |
450 // Now unbind PIXEL_UNPACK_BUFFER, all ES3 unpack parameters are set back to | 438 // Now unbind PIXEL_UNPACK_BUFFER, all ES3 unpack parameters are set back to |
451 // 0. | 439 // 0. |
452 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 0, 0, 0, 0, 0); | 440 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 0, 0); |
453 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0, 0); | 441 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0, 0); |
454 | 442 |
455 // Again, PixelStorei calls with unpack parameters are cached. | 443 // Again, PixelStorei calls with unpack parameters are cached. |
456 EXPECT_CALL(*gl_, PixelStorei(_, _)).Times(0); | 444 EXPECT_CALL(*gl_, PixelStorei(_, _)).Times(0); |
457 cmd.Init(GL_UNPACK_SKIP_ROWS, 3); | 445 cmd.Init(GL_UNPACK_ROW_LENGTH, 32); |
458 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 446 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
459 | 447 |
460 // Bind a PIXEL_UNPACK_BUFFER again. | 448 // Bind a PIXEL_UNPACK_BUFFER again. |
461 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 16, 0, 0, 3, 0); | 449 SetupUpdateES3UnpackParametersExpectations(gl_.get(), 32, 0); |
462 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, client_buffer_id_, kServiceBufferId); | 450 DoBindBuffer(GL_PIXEL_UNPACK_BUFFER, client_buffer_id_, kServiceBufferId); |
463 } | 451 } |
464 | 452 |
465 // TODO(vmiura): Tests for VAO restore. | 453 // TODO(vmiura): Tests for VAO restore. |
466 | 454 |
467 // TODO(vmiura): Tests for ContextState::RestoreAttribute(). | 455 // TODO(vmiura): Tests for ContextState::RestoreAttribute(). |
468 | 456 |
469 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings(). | 457 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings(). |
470 | 458 |
471 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). | 459 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). |
472 | 460 |
473 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings(). | 461 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings(). |
474 | 462 |
475 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). | 463 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). |
476 | 464 |
477 // TODO(vmiura): Tests for ContextState::RestoreGlobalState(). | 465 // TODO(vmiura): Tests for ContextState::RestoreGlobalState(). |
478 | 466 |
479 } // namespace gles2 | 467 } // namespace gles2 |
480 } // namespace gpu | 468 } // namespace gpu |
OLD | NEW |