| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 4313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4324 init.bind_generates_resource = true; | 4324 init.bind_generates_resource = true; |
| 4325 InitDecoder(init); | 4325 InitDecoder(init); |
| 4326 DoBindTexture(GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, | 4326 DoBindTexture(GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, |
| 4327 kServiceTextureId); | 4327 kServiceTextureId); |
| 4328 TexStorage2DEXT cmd; | 4328 TexStorage2DEXT cmd; |
| 4329 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, 2, GL_RGBA8, 4, 4); | 4329 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, 2, GL_RGBA8, 4, 4); |
| 4330 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4330 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4331 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 4331 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 4332 } | 4332 } |
| 4333 | 4333 |
| 4334 TEST_P(GLES2DecoderManualInitTest, TexStorageFormatAndTypeES2) { | 4334 class GLES2DecoderTexStorageFormatAndTypeTest |
| 4335 : public GLES2DecoderManualInitTest { |
| 4336 public: |
| 4337 GLES2DecoderTexStorageFormatAndTypeTest() {} |
| 4338 |
| 4339 void DoTexStorageFormatAndType(const InitState& init, |
| 4340 GLenum format, |
| 4341 GLenum adjusted_internal_format) { |
| 4342 InitDecoder(init); |
| 4343 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 4344 EXPECT_CALL(*gl_, TexStorage2DEXT(GL_TEXTURE_2D, 2, format, 2, 2)) |
| 4345 .Times(1) |
| 4346 .RetiresOnSaturation(); |
| 4347 TexStorage2DEXT cmd; |
| 4348 cmd.Init(GL_TEXTURE_2D, 2, format, 2, 2); |
| 4349 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4350 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4351 TextureRef* texture_ref = |
| 4352 group().texture_manager()->GetTexture(client_texture_id_); |
| 4353 Texture* texture = texture_ref->texture(); |
| 4354 GLenum type; |
| 4355 GLenum internal_format; |
| 4356 EXPECT_TRUE( |
| 4357 texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 4358 EXPECT_EQ(static_cast<GLenum>(adjusted_internal_format), internal_format); |
| 4359 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 4360 } |
| 4361 }; |
| 4362 |
| 4363 INSTANTIATE_TEST_CASE_P(Service, |
| 4364 GLES2DecoderTexStorageFormatAndTypeTest, |
| 4365 ::testing::Bool()); |
| 4366 |
| 4367 TEST_P(GLES2DecoderTexStorageFormatAndTypeTest, ES2) { |
| 4335 InitState init; | 4368 InitState init; |
| 4336 init.gl_version = "OpenGL ES 2.0"; | 4369 init.gl_version = "OpenGL ES 2.0"; |
| 4337 init.extensions = "GL_ARB_texture_storage"; | 4370 init.extensions = "GL_ARB_texture_storage"; |
| 4338 init.bind_generates_resource = true; | 4371 init.bind_generates_resource = true; |
| 4339 init.context_type = CONTEXT_TYPE_OPENGLES2; | 4372 init.context_type = CONTEXT_TYPE_OPENGLES2; |
| 4340 InitDecoder(init); | 4373 DoTexStorageFormatAndType(init, GL_RGBA8_OES, GL_RGBA); |
| 4341 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 4342 EXPECT_CALL(*gl_, TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGBA8_OES, 2, 2)) | |
| 4343 .Times(1) | |
| 4344 .RetiresOnSaturation(); | |
| 4345 TexStorage2DEXT cmd; | |
| 4346 cmd.Init(GL_TEXTURE_2D, 2, GL_RGBA8_OES, 2, 2); | |
| 4347 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 4348 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 4349 TextureRef* texture_ref = | |
| 4350 group().texture_manager()->GetTexture(client_texture_id_); | |
| 4351 Texture* texture = texture_ref->texture(); | |
| 4352 GLenum type; | |
| 4353 GLenum internal_format; | |
| 4354 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | |
| 4355 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | |
| 4356 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | |
| 4357 } | 4374 } |
| 4358 | 4375 |
| 4359 TEST_P(GLES2DecoderManualInitTest, TexStorageFormatAndTypeES3) { | 4376 TEST_P(GLES2DecoderTexStorageFormatAndTypeTest, WebGL1) { |
| 4377 InitState init; |
| 4378 init.gl_version = "OpenGL ES 2.0"; |
| 4379 init.extensions = "GL_ARB_texture_storage"; |
| 4380 init.bind_generates_resource = true; |
| 4381 init.context_type = CONTEXT_TYPE_WEBGL1; |
| 4382 DoTexStorageFormatAndType(init, GL_RGBA8_OES, GL_RGBA); |
| 4383 } |
| 4384 |
| 4385 TEST_P(GLES2DecoderTexStorageFormatAndTypeTest, ES3) { |
| 4360 InitState init; | 4386 InitState init; |
| 4361 init.gl_version = "OpenGL ES 3.0"; | 4387 init.gl_version = "OpenGL ES 3.0"; |
| 4362 init.bind_generates_resource = true; | 4388 init.bind_generates_resource = true; |
| 4363 init.context_type = CONTEXT_TYPE_OPENGLES3; | 4389 init.context_type = CONTEXT_TYPE_OPENGLES3; |
| 4364 InitDecoder(init); | 4390 DoTexStorageFormatAndType(init, GL_RGBA8, GL_RGBA8); |
| 4365 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 4391 } |
| 4366 EXPECT_CALL(*gl_, TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGBA8, 2, 2)) | 4392 |
| 4367 .Times(1) | 4393 TEST_P(GLES2DecoderTexStorageFormatAndTypeTest, WebGL2) { |
| 4368 .RetiresOnSaturation(); | 4394 InitState init; |
| 4369 TexStorage2DEXT cmd; | 4395 init.gl_version = "OpenGL ES 3.0"; |
| 4370 cmd.Init(GL_TEXTURE_2D, 2, GL_RGBA8, 2, 2); | 4396 init.bind_generates_resource = true; |
| 4371 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4397 init.context_type = CONTEXT_TYPE_WEBGL2; |
| 4372 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4398 DoTexStorageFormatAndType(init, GL_RGBA8, GL_RGBA8); |
| 4373 TextureRef* texture_ref = | |
| 4374 group().texture_manager()->GetTexture(client_texture_id_); | |
| 4375 Texture* texture = texture_ref->texture(); | |
| 4376 GLenum type; | |
| 4377 GLenum internal_format; | |
| 4378 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | |
| 4379 EXPECT_EQ(static_cast<GLenum>(GL_RGBA8), internal_format); | |
| 4380 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | |
| 4381 } | 4399 } |
| 4382 | 4400 |
| 4383 TEST_P(GLES3DecoderTest, TexStorage3DValidArgs) { | 4401 TEST_P(GLES3DecoderTest, TexStorage3DValidArgs) { |
| 4384 DoBindTexture(GL_TEXTURE_3D, client_texture_id_, kServiceTextureId); | 4402 DoBindTexture(GL_TEXTURE_3D, client_texture_id_, kServiceTextureId); |
| 4385 EXPECT_CALL(*gl_, TexStorage3D(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6)) | 4403 EXPECT_CALL(*gl_, TexStorage3D(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6)) |
| 4386 .Times(1) | 4404 .Times(1) |
| 4387 .RetiresOnSaturation(); | 4405 .RetiresOnSaturation(); |
| 4388 TexStorage3D cmd; | 4406 TexStorage3D cmd; |
| 4389 cmd.Init(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6); | 4407 cmd.Init(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6); |
| 4390 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4408 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4793 // TODO(gman): CompressedTexSubImage2DImmediate | 4811 // TODO(gman): CompressedTexSubImage2DImmediate |
| 4794 | 4812 |
| 4795 // TODO(gman): TexImage2D | 4813 // TODO(gman): TexImage2D |
| 4796 | 4814 |
| 4797 // TODO(gman): TexImage2DImmediate | 4815 // TODO(gman): TexImage2DImmediate |
| 4798 | 4816 |
| 4799 // TODO(gman): TexSubImage2DImmediate | 4817 // TODO(gman): TexSubImage2DImmediate |
| 4800 | 4818 |
| 4801 } // namespace gles2 | 4819 } // namespace gles2 |
| 4802 } // namespace gpu | 4820 } // namespace gpu |
| OLD | NEW |