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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_context_state.cc

Issue 1494553002: Revert of Upgrade PixelStorei to ES3/WebGL2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
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
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
79 using namespace cmds; 51 using namespace cmds;
80 52
81 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest { 53 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest {
82 public: 54 public:
83 GLES2DecoderRestoreStateTest() {} 55 GLES2DecoderRestoreStateTest() {}
84 56
85 protected: 57 protected:
86 void AddExpectationsForActiveTexture(GLenum unit); 58 void AddExpectationsForActiveTexture(GLenum unit);
87 void AddExpectationsForBindTexture(GLenum target, GLuint id); 59 void AddExpectationsForBindTexture(GLenum target, GLuint id);
88 void InitializeContextState(ContextState* state, 60 void InitializeContextState(ContextState* state,
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 389
418 // Test new and cached state changes. 390 // Test new and cached state changes.
419 for (int n = 0; n < 3; n++) { 391 for (int n = 0; n < 3; n++) {
420 enable_state = !enable_state; 392 enable_state = !enable_state;
421 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); 393 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
422 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); 394 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
423 } 395 }
424 } 396 }
425 } 397 }
426 398
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
463 // TODO(vmiura): Tests for VAO restore. 399 // TODO(vmiura): Tests for VAO restore.
464 400
465 // TODO(vmiura): Tests for ContextState::RestoreAttribute(). 401 // TODO(vmiura): Tests for ContextState::RestoreAttribute().
466 402
467 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings(). 403 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings().
468 404
469 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 405 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
470 406
471 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings(). 407 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings().
472 408
473 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 409 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
474 410
475 // TODO(vmiura): Tests for ContextState::RestoreGlobalState(). 411 // TODO(vmiura): Tests for ContextState::RestoreGlobalState().
476 412
477 } // namespace gles2 413 } // namespace gles2
478 } // namespace gpu 414 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698