| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 10 #include "gpu/command_buffer/common/id_allocator.h" | 10 #include "gpu/command_buffer/common/id_allocator.h" |
| (...skipping 7940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7951 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUM) { | 7951 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUM) { |
| 7952 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 7952 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 7953 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 7953 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 7954 0, 0); | 7954 0, 0); |
| 7955 TextureRef* texture_ref = group().texture_manager()->GetTexture( | 7955 TextureRef* texture_ref = group().texture_manager()->GetTexture( |
| 7956 client_texture_id_); | 7956 client_texture_id_); |
| 7957 ASSERT_TRUE(texture_ref != NULL); | 7957 ASSERT_TRUE(texture_ref != NULL); |
| 7958 Texture* texture = texture_ref->texture(); | 7958 Texture* texture = texture_ref->texture(); |
| 7959 EXPECT_EQ(kServiceTextureId, texture->service_id()); | 7959 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 7960 | 7960 |
| 7961 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); | 7961 EXPECT_FALSE(GetImage(kImageId) == NULL); |
| 7962 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL); | 7962 EXPECT_TRUE(GetImage(kInvalidImageId) == NULL); |
| 7963 | 7963 |
| 7964 GLsizei width; | 7964 GLsizei width; |
| 7965 GLsizei height; | 7965 GLsizei height; |
| 7966 GLenum type; | 7966 GLenum type; |
| 7967 GLenum internal_format; | 7967 GLenum internal_format; |
| 7968 | 7968 |
| 7969 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 7969 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7970 EXPECT_EQ(3, width); | 7970 EXPECT_EQ(3, width); |
| 7971 EXPECT_EQ(1, height); | 7971 EXPECT_EQ(1, height); |
| 7972 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | 7972 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 7973 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | 7973 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 7974 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | 7974 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 7975 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | 7975 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7976 | 7976 |
| 7977 // Bind image to texture. | 7977 // Bind image to texture. |
| 7978 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 7978 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 7979 EXPECT_CALL(*gl_, GetError()) | 7979 EXPECT_CALL(*gl_, GetError()) |
| 7980 .WillOnce(Return(GL_NO_ERROR)) | 7980 .WillOnce(Return(GL_NO_ERROR)) |
| 7981 .WillOnce(Return(GL_NO_ERROR)) | 7981 .WillOnce(Return(GL_NO_ERROR)) |
| 7982 .RetiresOnSaturation(); | 7982 .RetiresOnSaturation(); |
| 7983 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | 7983 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 7984 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | 7984 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); |
| 7985 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | 7985 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 7986 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 7986 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7987 // Image should now be set. | 7987 // Image should now be set. |
| 7988 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | 7988 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7989 | 7989 |
| 7990 // Define new texture image. | 7990 // Define new texture image. |
| 7991 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 7991 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 7992 0, 0); | 7992 0, 0); |
| 7993 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 7993 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7994 // Image should no longer be set. | 7994 // Image should no longer be set. |
| 7995 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | 7995 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7996 } | 7996 } |
| 7997 | 7997 |
| 7998 TEST_F(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { | 7998 TEST_F(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { |
| 7999 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 7999 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 8000 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 8000 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 8001 0, 0); | 8001 0, 0); |
| 8002 TextureRef* texture_ref = group().texture_manager()->GetTexture( | 8002 TextureRef* texture_ref = group().texture_manager()->GetTexture( |
| 8003 client_texture_id_); | 8003 client_texture_id_); |
| 8004 ASSERT_TRUE(texture_ref != NULL); | 8004 ASSERT_TRUE(texture_ref != NULL); |
| 8005 Texture* texture = texture_ref->texture(); | 8005 Texture* texture = texture_ref->texture(); |
| 8006 EXPECT_EQ(kServiceTextureId, texture->service_id()); | 8006 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 8007 | 8007 |
| 8008 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); | 8008 EXPECT_FALSE(GetImage(kImageId) == NULL); |
| 8009 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL); | |
| 8010 | 8009 |
| 8011 GLsizei width; | 8010 GLsizei width; |
| 8012 GLsizei height; | 8011 GLsizei height; |
| 8013 GLenum type; | 8012 GLenum type; |
| 8014 GLenum internal_format; | 8013 GLenum internal_format; |
| 8015 | 8014 |
| 8016 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 8015 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 8017 EXPECT_EQ(3, width); | 8016 EXPECT_EQ(3, width); |
| 8018 EXPECT_EQ(1, height); | 8017 EXPECT_EQ(1, height); |
| 8019 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | 8018 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 8020 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | 8019 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 8021 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | 8020 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 8022 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | 8021 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 8023 | 8022 |
| 8024 // Bind image to texture. | 8023 // Bind image to texture. |
| 8025 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 8024 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 8026 EXPECT_CALL(*gl_, GetError()) | 8025 EXPECT_CALL(*gl_, GetError()) |
| 8027 .WillOnce(Return(GL_NO_ERROR)) | 8026 .WillOnce(Return(GL_NO_ERROR)) |
| 8028 .WillOnce(Return(GL_NO_ERROR)) | 8027 .WillOnce(Return(GL_NO_ERROR)) |
| 8029 .RetiresOnSaturation(); | 8028 .RetiresOnSaturation(); |
| 8030 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; | 8029 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 8031 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | 8030 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); |
| 8032 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); | 8031 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 8033 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 8032 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 8034 // Image should now be set. | 8033 // Image should now be set. |
| 8035 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | 8034 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 8036 | 8035 |
| 8037 // Release image from texture. | 8036 // Release image from texture. |
| 8038 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 8037 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
| 8039 EXPECT_CALL(*gl_, GetError()) | 8038 EXPECT_CALL(*gl_, GetError()) |
| 8040 .WillOnce(Return(GL_NO_ERROR)) | 8039 .WillOnce(Return(GL_NO_ERROR)) |
| 8041 .WillOnce(Return(GL_NO_ERROR)) | 8040 .WillOnce(Return(GL_NO_ERROR)) |
| 8042 .RetiresOnSaturation(); | 8041 .RetiresOnSaturation(); |
| 8043 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; | 8042 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; |
| 8044 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); | 8043 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); |
| 8045 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); | 8044 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); |
| 8046 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 8045 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 8047 // Image should no longer be set. | 8046 // Image should no longer be set. |
| 8048 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); | 8047 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 8049 } | 8048 } |
| 8050 | 8049 |
| 8051 TEST_F(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) { | 8050 TEST_F(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) { |
| 8052 InitDecoder( | 8051 InitDecoder( |
| 8053 "GL_ARB_texture_rectangle", // extensions | 8052 "GL_ARB_texture_rectangle", // extensions |
| 8054 false, // has alpha | 8053 false, // has alpha |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8661 // TODO(gman): TexImage2DImmediate | 8660 // TODO(gman): TexImage2DImmediate |
| 8662 | 8661 |
| 8663 // TODO(gman): TexSubImage2DImmediate | 8662 // TODO(gman): TexSubImage2DImmediate |
| 8664 | 8663 |
| 8665 // TODO(gman): UseProgram | 8664 // TODO(gman): UseProgram |
| 8666 | 8665 |
| 8667 // TODO(gman): SwapBuffers | 8666 // TODO(gman): SwapBuffers |
| 8668 | 8667 |
| 8669 } // namespace gles2 | 8668 } // namespace gles2 |
| 8670 } // namespace gpu | 8669 } // namespace gpu |
| OLD | NEW |