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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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 <stdint.h>
8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 11 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 12 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
11 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 13 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
12 #include "gpu/command_buffer/service/context_group.h" 14 #include "gpu/command_buffer/service/context_group.h"
13 #include "gpu/command_buffer/service/context_state.h" 15 #include "gpu/command_buffer/service/context_state.h"
14 #include "gpu/command_buffer/service/gl_surface_mock.h" 16 #include "gpu/command_buffer/service/gl_surface_mock.h"
15 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" 17 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
16 18
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 using namespace cmds; 81 using namespace cmds;
80 82
81 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest { 83 class GLES2DecoderRestoreStateTest : public GLES2DecoderManualInitTest {
82 public: 84 public:
83 GLES2DecoderRestoreStateTest() {} 85 GLES2DecoderRestoreStateTest() {}
84 86
85 protected: 87 protected:
86 void AddExpectationsForActiveTexture(GLenum unit); 88 void AddExpectationsForActiveTexture(GLenum unit);
87 void AddExpectationsForBindTexture(GLenum target, GLuint id); 89 void AddExpectationsForBindTexture(GLenum target, GLuint id);
88 void InitializeContextState(ContextState* state, 90 void InitializeContextState(ContextState* state,
89 uint32 non_default_unit, 91 uint32_t non_default_unit,
90 uint32 active_unit); 92 uint32_t active_unit);
91 }; 93 };
92 94
93 INSTANTIATE_TEST_CASE_P(Service, 95 INSTANTIATE_TEST_CASE_P(Service,
94 GLES2DecoderRestoreStateTest, 96 GLES2DecoderRestoreStateTest,
95 ::testing::Bool()); 97 ::testing::Bool());
96 98
97 void GLES2DecoderRestoreStateTest::AddExpectationsForActiveTexture( 99 void GLES2DecoderRestoreStateTest::AddExpectationsForActiveTexture(
98 GLenum unit) { 100 GLenum unit) {
99 EXPECT_CALL(*gl_, ActiveTexture(unit)).Times(1).RetiresOnSaturation(); 101 EXPECT_CALL(*gl_, ActiveTexture(unit)).Times(1).RetiresOnSaturation();
100 } 102 }
101 103
102 void GLES2DecoderRestoreStateTest::AddExpectationsForBindTexture(GLenum target, 104 void GLES2DecoderRestoreStateTest::AddExpectationsForBindTexture(GLenum target,
103 GLuint id) { 105 GLuint id) {
104 EXPECT_CALL(*gl_, BindTexture(target, id)).Times(1).RetiresOnSaturation(); 106 EXPECT_CALL(*gl_, BindTexture(target, id)).Times(1).RetiresOnSaturation();
105 } 107 }
106 108
107 void GLES2DecoderRestoreStateTest::InitializeContextState( 109 void GLES2DecoderRestoreStateTest::InitializeContextState(
108 ContextState* state, 110 ContextState* state,
109 uint32 non_default_unit, 111 uint32_t non_default_unit,
110 uint32 active_unit) { 112 uint32_t active_unit) {
111 state->texture_units.resize(group().max_texture_units()); 113 state->texture_units.resize(group().max_texture_units());
112 for (uint32 tt = 0; tt < state->texture_units.size(); ++tt) { 114 for (uint32_t tt = 0; tt < state->texture_units.size(); ++tt) {
113 TextureRef* ref_cube_map = 115 TextureRef* ref_cube_map =
114 group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); 116 group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP);
115 state->texture_units[tt].bound_texture_cube_map = ref_cube_map; 117 state->texture_units[tt].bound_texture_cube_map = ref_cube_map;
116 TextureRef* ref_2d = 118 TextureRef* ref_2d =
117 (tt == non_default_unit) 119 (tt == non_default_unit)
118 ? group().texture_manager()->GetTexture(client_texture_id_) 120 ? group().texture_manager()->GetTexture(client_texture_id_)
119 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); 121 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D);
120 state->texture_units[tt].bound_texture_2d = ref_2d; 122 state->texture_units[tt].bound_texture_2d = ref_2d;
121 } 123 }
122 state->active_texture_unit = active_unit; 124 state->active_texture_unit = active_unit;
123 } 125 }
124 126
125 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) { 127 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) {
126 InitState init; 128 InitState init;
127 init.bind_generates_resource = true; 129 init.bind_generates_resource = true;
128 InitDecoder(init); 130 InitDecoder(init);
129 SetupTexture(); 131 SetupTexture();
130 132
131 InSequence sequence; 133 InSequence sequence;
132 // Expect to restore texture bindings for unit GL_TEXTURE0. 134 // Expect to restore texture bindings for unit GL_TEXTURE0.
133 AddExpectationsForActiveTexture(GL_TEXTURE0); 135 AddExpectationsForActiveTexture(GL_TEXTURE0);
134 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 136 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
135 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 137 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP,
136 TestHelper::kServiceDefaultTextureCubemapId); 138 TestHelper::kServiceDefaultTextureCubemapId);
137 139
138 // Expect to restore texture bindings for remaining units. 140 // Expect to restore texture bindings for remaining units.
139 for (uint32 i = 1; i < group().max_texture_units(); ++i) { 141 for (uint32_t i = 1; i < group().max_texture_units(); ++i) {
140 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); 142 AddExpectationsForActiveTexture(GL_TEXTURE0 + i);
141 AddExpectationsForBindTexture(GL_TEXTURE_2D, 143 AddExpectationsForBindTexture(GL_TEXTURE_2D,
142 TestHelper::kServiceDefaultTexture2dId); 144 TestHelper::kServiceDefaultTexture2dId);
143 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 145 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP,
144 TestHelper::kServiceDefaultTextureCubemapId); 146 TestHelper::kServiceDefaultTextureCubemapId);
145 } 147 }
146 148
147 // Expect to restore the active texture unit to GL_TEXTURE0. 149 // Expect to restore the active texture unit to GL_TEXTURE0.
148 AddExpectationsForActiveTexture(GL_TEXTURE0); 150 AddExpectationsForActiveTexture(GL_TEXTURE0);
149 151
150 GetDecoder()->RestoreAllTextureUnitBindings(NULL); 152 GetDecoder()->RestoreAllTextureUnitBindings(NULL);
151 } 153 }
152 154
153 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousState) { 155 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousState) {
154 InitState init; 156 InitState init;
155 InitDecoder(init); 157 InitDecoder(init);
156 SetupTexture(); 158 SetupTexture();
157 159
158 InSequence sequence; 160 InSequence sequence;
159 // Expect to restore texture bindings for unit GL_TEXTURE0. 161 // Expect to restore texture bindings for unit GL_TEXTURE0.
160 AddExpectationsForActiveTexture(GL_TEXTURE0); 162 AddExpectationsForActiveTexture(GL_TEXTURE0);
161 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 163 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
162 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); 164 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0);
163 165
164 // Expect to restore texture bindings for remaining units. 166 // Expect to restore texture bindings for remaining units.
165 for (uint32 i = 1; i < group().max_texture_units(); ++i) { 167 for (uint32_t i = 1; i < group().max_texture_units(); ++i) {
166 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); 168 AddExpectationsForActiveTexture(GL_TEXTURE0 + i);
167 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); 169 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0);
168 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); 170 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0);
169 } 171 }
170 172
171 // Expect to restore the active texture unit to GL_TEXTURE0. 173 // Expect to restore the active texture unit to GL_TEXTURE0.
172 AddExpectationsForActiveTexture(GL_TEXTURE0); 174 AddExpectationsForActiveTexture(GL_TEXTURE0);
173 175
174 GetDecoder()->RestoreAllTextureUnitBindings(NULL); 176 GetDecoder()->RestoreAllTextureUnitBindings(NULL);
175 } 177 }
176 178
177 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) { 179 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) {
178 InitState init; 180 InitState init;
179 init.bind_generates_resource = true; 181 init.bind_generates_resource = true;
180 InitDecoder(init); 182 InitDecoder(init);
181 SetupTexture(); 183 SetupTexture();
182 184
183 // Construct a previous ContextState with all texture bindings 185 // Construct a previous ContextState with all texture bindings
184 // set to default textures. 186 // set to default textures.
185 ContextState prev_state(NULL, NULL, NULL); 187 ContextState prev_state(NULL, NULL, NULL);
186 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 188 InitializeContextState(&prev_state, std::numeric_limits<uint32_t>::max(), 0);
187 189
188 InSequence sequence; 190 InSequence sequence;
189 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, 191 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit,
190 // since the rest of the bindings haven't changed between the current 192 // since the rest of the bindings haven't changed between the current
191 // state and the |prev_state|. 193 // state and the |prev_state|.
192 AddExpectationsForActiveTexture(GL_TEXTURE0); 194 AddExpectationsForActiveTexture(GL_TEXTURE0);
193 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 195 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
194 196
195 // Expect to restore active texture unit to GL_TEXTURE0. 197 // Expect to restore active texture unit to GL_TEXTURE0.
196 AddExpectationsForActiveTexture(GL_TEXTURE0); 198 AddExpectationsForActiveTexture(GL_TEXTURE0);
197 199
198 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 200 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
199 } 201 }
200 202
201 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousState) { 203 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousState) {
202 InitState init; 204 InitState init;
203 InitDecoder(init); 205 InitDecoder(init);
204 SetupTexture(); 206 SetupTexture();
205 207
206 // Construct a previous ContextState with all texture bindings 208 // Construct a previous ContextState with all texture bindings
207 // set to default textures. 209 // set to default textures.
208 ContextState prev_state(NULL, NULL, NULL); 210 ContextState prev_state(NULL, NULL, NULL);
209 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 211 InitializeContextState(&prev_state, std::numeric_limits<uint32_t>::max(), 0);
210 212
211 InSequence sequence; 213 InSequence sequence;
212 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, 214 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit,
213 // since the rest of the bindings haven't changed between the current 215 // since the rest of the bindings haven't changed between the current
214 // state and the |prev_state|. 216 // state and the |prev_state|.
215 AddExpectationsForActiveTexture(GL_TEXTURE0); 217 AddExpectationsForActiveTexture(GL_TEXTURE0);
216 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 218 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
217 219
218 // Expect to restore active texture unit to GL_TEXTURE0. 220 // Expect to restore active texture unit to GL_TEXTURE0.
219 AddExpectationsForActiveTexture(GL_TEXTURE0); 221 AddExpectationsForActiveTexture(GL_TEXTURE0);
220 222
221 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 223 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
222 } 224 }
223 225
224 TEST_P(GLES2DecoderRestoreStateTest, ActiveUnit1) { 226 TEST_P(GLES2DecoderRestoreStateTest, ActiveUnit1) {
225 InitState init; 227 InitState init;
226 InitDecoder(init); 228 InitDecoder(init);
227 229
228 // Bind a non-default texture to GL_TEXTURE1 unit. 230 // Bind a non-default texture to GL_TEXTURE1 unit.
229 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 231 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
230 ActiveTexture cmd; 232 ActiveTexture cmd;
231 cmd.Init(GL_TEXTURE1); 233 cmd.Init(GL_TEXTURE1);
232 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 234 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
233 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 235 EXPECT_EQ(GL_NO_ERROR, GetGLError());
234 SetupTexture(); 236 SetupTexture();
235 237
236 // Construct a previous ContextState with all texture bindings 238 // Construct a previous ContextState with all texture bindings
237 // set to default textures. 239 // set to default textures.
238 ContextState prev_state(NULL, NULL, NULL); 240 ContextState prev_state(NULL, NULL, NULL);
239 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 241 InitializeContextState(&prev_state, std::numeric_limits<uint32_t>::max(), 0);
240 242
241 InSequence sequence; 243 InSequence sequence;
242 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE1 unit, 244 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE1 unit,
243 // since the rest of the bindings haven't changed between the current 245 // since the rest of the bindings haven't changed between the current
244 // state and the |prev_state|. 246 // state and the |prev_state|.
245 AddExpectationsForActiveTexture(GL_TEXTURE1); 247 AddExpectationsForActiveTexture(GL_TEXTURE1);
246 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 248 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
247 249
248 // Expect to restore active texture unit to GL_TEXTURE1. 250 // Expect to restore active texture unit to GL_TEXTURE1.
249 AddExpectationsForActiveTexture(GL_TEXTURE1); 251 AddExpectationsForActiveTexture(GL_TEXTURE1);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 471 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
470 472
471 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings(). 473 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings().
472 474
473 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 475 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
474 476
475 // TODO(vmiura): Tests for ContextState::RestoreGlobalState(). 477 // TODO(vmiura): Tests for ContextState::RestoreGlobalState().
476 478
477 } // namespace gles2 479 } // namespace gles2
478 } // namespace gpu 480 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698