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/gl_mock.h" | 8 #include "gpu/command_buffer/common/gl_mock.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" |
11 #include "gpu/command_buffer/common/id_allocator.h" | 11 #include "gpu/command_buffer/common/id_allocator.h" |
12 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 12 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
13 #include "gpu/command_buffer/service/context_group.h" | 13 #include "gpu/command_buffer/service/context_group.h" |
14 #include "gpu/command_buffer/service/gl_surface_mock.h" | 14 #include "gpu/command_buffer/service/gl_surface_mock.h" |
15 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 15 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
| 16 #include "gpu/command_buffer/service/image_manager.h" |
16 #include "gpu/command_buffer/service/mailbox_manager.h" | 17 #include "gpu/command_buffer/service/mailbox_manager.h" |
17 #include "gpu/command_buffer/service/program_manager.h" | 18 #include "gpu/command_buffer/service/program_manager.h" |
18 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" | 19 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" |
19 #include "gpu/command_buffer/service/stream_texture_mock.h" | 20 #include "gpu/command_buffer/service/stream_texture_mock.h" |
20 #include "gpu/command_buffer/service/test_helper.h" | 21 #include "gpu/command_buffer/service/test_helper.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "ui/gl/gl_implementation.h" | 23 #include "ui/gl/gl_implementation.h" |
23 #include "ui/gl/gl_surface_stub.h" | 24 #include "ui/gl/gl_surface_stub.h" |
24 | 25 |
25 | 26 |
(...skipping 7774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7800 } | 7801 } |
7801 | 7802 |
7802 TEST_F(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgsNewId) { | 7803 TEST_F(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgsNewId) { |
7803 BindVertexArrayOESValidArgsNewId(); | 7804 BindVertexArrayOESValidArgsNewId(); |
7804 } | 7805 } |
7805 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, | 7806 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, |
7806 BindVertexArrayOESValidArgsNewId) { | 7807 BindVertexArrayOESValidArgsNewId) { |
7807 BindVertexArrayOESValidArgsNewId(); | 7808 BindVertexArrayOESValidArgsNewId(); |
7808 } | 7809 } |
7809 | 7810 |
| 7811 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUM) { |
| 7812 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 7813 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 7814 0, 0); |
| 7815 TextureManager::TextureInfo* info = |
| 7816 group().texture_manager()->GetTextureInfo(client_texture_id_); |
| 7817 EXPECT_EQ(kServiceTextureId, info->service_id()); |
| 7818 |
| 7819 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0), 1); |
| 7820 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL); |
| 7821 |
| 7822 GLsizei width; |
| 7823 GLsizei height; |
| 7824 GLenum type; |
| 7825 GLenum internal_format; |
| 7826 |
| 7827 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7828 EXPECT_EQ(3, width); |
| 7829 EXPECT_EQ(1, height); |
| 7830 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 7831 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 7832 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 7833 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7834 |
| 7835 // Bind image to texture. |
| 7836 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 7837 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| 7838 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 7839 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7840 // Image should now be set. |
| 7841 EXPECT_FALSE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7842 |
| 7843 // Define new texture image. |
| 7844 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 7845 0, 0); |
| 7846 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7847 // Image should no longer be set. |
| 7848 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7849 } |
| 7850 |
| 7851 TEST_F(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { |
| 7852 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 7853 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 7854 0, 0); |
| 7855 TextureManager::TextureInfo* info = |
| 7856 group().texture_manager()->GetTextureInfo(client_texture_id_); |
| 7857 EXPECT_EQ(kServiceTextureId, info->service_id()); |
| 7858 |
| 7859 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0), 1); |
| 7860 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL); |
| 7861 |
| 7862 GLsizei width; |
| 7863 GLsizei height; |
| 7864 GLenum type; |
| 7865 GLenum internal_format; |
| 7866 |
| 7867 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7868 EXPECT_EQ(3, width); |
| 7869 EXPECT_EQ(1, height); |
| 7870 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 7871 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 7872 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 7873 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7874 |
| 7875 // Bind image to texture. |
| 7876 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| 7877 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| 7878 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| 7879 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7880 // Image should now be set. |
| 7881 EXPECT_FALSE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7882 |
| 7883 // Release image from texture. |
| 7884 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; |
| 7885 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| 7886 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); |
| 7887 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 7888 // Image should no longer be set. |
| 7889 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| 7890 } |
| 7891 |
7810 // TODO(gman): Complete this test. | 7892 // TODO(gman): Complete this test. |
7811 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { | 7893 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { |
7812 // } | 7894 // } |
7813 | 7895 |
7814 // TODO(gman): BufferData | 7896 // TODO(gman): BufferData |
7815 | 7897 |
7816 // TODO(gman): BufferDataImmediate | 7898 // TODO(gman): BufferDataImmediate |
7817 | 7899 |
7818 // TODO(gman): BufferSubData | 7900 // TODO(gman): BufferSubData |
7819 | 7901 |
(...skipping 16 matching lines...) Expand all Loading... |
7836 // TODO(gman): TexImage2DImmediate | 7918 // TODO(gman): TexImage2DImmediate |
7837 | 7919 |
7838 // TODO(gman): TexSubImage2DImmediate | 7920 // TODO(gman): TexSubImage2DImmediate |
7839 | 7921 |
7840 // TODO(gman): UseProgram | 7922 // TODO(gman): UseProgram |
7841 | 7923 |
7842 // TODO(gman): SwapBuffers | 7924 // TODO(gman): SwapBuffers |
7843 | 7925 |
7844 } // namespace gles2 | 7926 } // namespace gles2 |
7845 } // namespace gpu | 7927 } // namespace gpu |
OLD | NEW |