| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 110 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 111 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 111 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 TEST_P(GLES2DecoderTest, FramebufferTexture2DWithNoBoundTarget) { | 114 TEST_P(GLES2DecoderTest, FramebufferTexture2DWithNoBoundTarget) { |
| 115 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); | 115 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 116 FramebufferTexture2D cmd; | 116 FramebufferTexture2D cmd; |
| 117 cmd.Init(GL_FRAMEBUFFER, | 117 cmd.Init(GL_FRAMEBUFFER, |
| 118 GL_COLOR_ATTACHMENT0, | 118 GL_COLOR_ATTACHMENT0, |
| 119 GL_TEXTURE_2D, | 119 GL_TEXTURE_2D, |
| 120 client_texture_id_); | 120 client_texture_id_, |
| 121 0); |
| 121 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 122 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 122 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 123 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 123 } | 124 } |
| 124 | 125 |
| 126 TEST_P(GLES3DecoderTest, FramebufferTexture2DWithNoBoundTarget) { |
| 127 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 128 FramebufferTexture2D cmd; |
| 129 cmd.Init(GL_FRAMEBUFFER, |
| 130 GL_COLOR_ATTACHMENT0, |
| 131 GL_TEXTURE_2D, |
| 132 client_texture_id_, |
| 133 1); |
| 134 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 135 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 136 } |
| 137 |
| 138 TEST_P(GLES3DecoderTest, FramebufferTexture2DValidArgs) { |
| 139 EXPECT_CALL(*gl_, |
| 140 FramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 141 GL_TEXTURE_2D, kServiceTextureId, 1)); |
| 142 DoBindFramebuffer( |
| 143 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 144 EXPECT_CALL(*gl_, GetError()) |
| 145 .WillOnce(Return(GL_NO_ERROR)) |
| 146 .WillOnce(Return(GL_NO_ERROR)) |
| 147 .RetiresOnSaturation(); |
| 148 cmds::FramebufferTexture2D cmd; |
| 149 cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 150 client_texture_id_, 1); |
| 151 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 152 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 153 } |
| 154 |
| 155 TEST_P(GLES3DecoderTest, FramebufferTexture2DInvalidArgs0_0) { |
| 156 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 157 DoBindFramebuffer( |
| 158 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 159 cmds::FramebufferTexture2D cmd; |
| 160 cmd.Init(GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 161 client_texture_id_, 1); |
| 162 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 163 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 164 } |
| 165 |
| 166 TEST_P(GLES3DecoderTest, FramebufferTexture2DInvalidArgs2_0) { |
| 167 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); |
| 168 DoBindFramebuffer( |
| 169 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
| 170 cmds::FramebufferTexture2D cmd; |
| 171 cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_PROXY_TEXTURE_CUBE_MAP, |
| 172 client_texture_id_, 1); |
| 173 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 174 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 175 } |
| 176 |
| 125 TEST_P(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { | 177 TEST_P(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { |
| 126 EXPECT_CALL(*gl_, GetError()) | 178 EXPECT_CALL(*gl_, GetError()) |
| 127 .WillOnce(Return(GL_NO_ERROR)) | 179 .WillOnce(Return(GL_NO_ERROR)) |
| 128 .WillOnce(Return(GL_NO_ERROR)) | 180 .WillOnce(Return(GL_NO_ERROR)) |
| 129 .RetiresOnSaturation(); | 181 .RetiresOnSaturation(); |
| 130 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) | 182 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) |
| 131 .Times(0); | 183 .Times(0); |
| 132 GetFramebufferAttachmentParameteriv cmd; | 184 GetFramebufferAttachmentParameteriv cmd; |
| 133 cmd.Init(GL_FRAMEBUFFER, | 185 cmd.Init(GL_FRAMEBUFFER, |
| 134 GL_COLOR_ATTACHMENT0, | 186 GL_COLOR_ATTACHMENT0, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 GetFramebufferAttachmentParameteriv::Result* result = | 241 GetFramebufferAttachmentParameteriv::Result* result = |
| 190 static_cast<GetFramebufferAttachmentParameteriv::Result*>( | 242 static_cast<GetFramebufferAttachmentParameteriv::Result*>( |
| 191 shared_memory_address_); | 243 shared_memory_address_); |
| 192 result->SetNumResults(0); | 244 result->SetNumResults(0); |
| 193 const GLint* result_value = result->GetData(); | 245 const GLint* result_value = result->GetData(); |
| 194 FramebufferTexture2D fbtex_cmd; | 246 FramebufferTexture2D fbtex_cmd; |
| 195 GetFramebufferAttachmentParameteriv cmd; | 247 GetFramebufferAttachmentParameteriv cmd; |
| 196 fbtex_cmd.Init(GL_FRAMEBUFFER, | 248 fbtex_cmd.Init(GL_FRAMEBUFFER, |
| 197 GL_COLOR_ATTACHMENT0, | 249 GL_COLOR_ATTACHMENT0, |
| 198 GL_TEXTURE_2D, | 250 GL_TEXTURE_2D, |
| 199 client_texture_id_); | 251 client_texture_id_, |
| 252 0); |
| 200 cmd.Init(GL_FRAMEBUFFER, | 253 cmd.Init(GL_FRAMEBUFFER, |
| 201 GL_COLOR_ATTACHMENT0, | 254 GL_COLOR_ATTACHMENT0, |
| 202 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, | 255 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, |
| 203 shared_memory_id_, | 256 shared_memory_id_, |
| 204 shared_memory_offset_); | 257 shared_memory_offset_); |
| 205 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); | 258 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); |
| 206 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 259 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 207 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 260 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 208 EXPECT_EQ(client_texture_id_, static_cast<GLuint>(*result_value)); | 261 EXPECT_EQ(client_texture_id_, static_cast<GLuint>(*result_value)); |
| 209 } | 262 } |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 GL_COLOR_ATTACHMENT0, | 1382 GL_COLOR_ATTACHMENT0, |
| 1330 GL_TEXTURE_2D, | 1383 GL_TEXTURE_2D, |
| 1331 kServiceTextureId, | 1384 kServiceTextureId, |
| 1332 0)) | 1385 0)) |
| 1333 .Times(1) | 1386 .Times(1) |
| 1334 .RetiresOnSaturation(); | 1387 .RetiresOnSaturation(); |
| 1335 FramebufferTexture2D fbtex_cmd; | 1388 FramebufferTexture2D fbtex_cmd; |
| 1336 fbtex_cmd.Init(GL_FRAMEBUFFER, | 1389 fbtex_cmd.Init(GL_FRAMEBUFFER, |
| 1337 GL_COLOR_ATTACHMENT0, | 1390 GL_COLOR_ATTACHMENT0, |
| 1338 GL_TEXTURE_2D, | 1391 GL_TEXTURE_2D, |
| 1339 client_texture_id_); | 1392 client_texture_id_, |
| 1393 0); |
| 1340 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); | 1394 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); |
| 1341 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1395 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
| 1342 } | 1396 } |
| 1343 | 1397 |
| 1344 TEST_P(GLES2DecoderTest, RenderbufferStorageGLError) { | 1398 TEST_P(GLES2DecoderTest, RenderbufferStorageGLError) { |
| 1345 DoBindRenderbuffer( | 1399 DoBindRenderbuffer( |
| 1346 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); | 1400 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); |
| 1347 EnsureRenderbufferBound(false); | 1401 EnsureRenderbufferBound(false); |
| 1348 EXPECT_CALL(*gl_, GetError()) | 1402 EXPECT_CALL(*gl_, GetError()) |
| 1349 .WillOnce(Return(GL_NO_ERROR)) | 1403 .WillOnce(Return(GL_NO_ERROR)) |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 EXPECT_EQ(1, result->GetNumResults()); | 2790 EXPECT_EQ(1, result->GetNumResults()); |
| 2737 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2791 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 2738 } | 2792 } |
| 2739 | 2793 |
| 2740 // TODO(gman): PixelStorei | 2794 // TODO(gman): PixelStorei |
| 2741 | 2795 |
| 2742 // TODO(gman): SwapBuffers | 2796 // TODO(gman): SwapBuffers |
| 2743 | 2797 |
| 2744 } // namespace gles2 | 2798 } // namespace gles2 |
| 2745 } // namespace gpu | 2799 } // namespace gpu |
| OLD | NEW |