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

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

Issue 10543125: gpu: Add support for GLX_EXT_texture_from_pixmap extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move CreateGLImage below virtual methods. Created 8 years, 2 months 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 | Annotate | Revision Log
OLDNEW
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 7683 matching lines...) Expand 10 before | Expand all | Expand 10 after
7709 } 7710 }
7710 7711
7711 TEST_F(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgsNewId) { 7712 TEST_F(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgsNewId) {
7712 SpecializedSetup<BindVertexArrayOES, 0>(true); 7713 SpecializedSetup<BindVertexArrayOES, 0>(true);
7713 BindVertexArrayOES cmd; 7714 BindVertexArrayOES cmd;
7714 cmd.Init(kNewClientId); 7715 cmd.Init(kNewClientId);
7715 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 7716 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7716 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 7717 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7717 } 7718 }
7718 7719
7720 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUM) {
7721 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
7722 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7723 0, 0);
7724 TextureManager::TextureInfo* info =
7725 group().texture_manager()->GetTextureInfo(client_texture_id_);
7726 EXPECT_EQ(kServiceTextureId, info->service_id());
7727
7728 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0), 1);
7729 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL);
7730
7731 GLsizei width;
7732 GLsizei height;
7733 GLenum type;
7734 GLenum internal_format;
7735
7736 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7737 EXPECT_EQ(3, width);
7738 EXPECT_EQ(1, height);
7739 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
7740 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
7741 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
7742 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
7743
7744 // Bind image to texture.
7745 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd;
7746 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1);
7747 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd));
7748 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7749 // Image should now be set.
7750 EXPECT_FALSE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
7751
7752 // Define new texture image.
7753 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7754 0, 0);
7755 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7756 // Image should no longer be set.
7757 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
7758 }
7759
7760 TEST_F(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
7761 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
7762 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7763 0, 0);
7764 TextureManager::TextureInfo* info =
7765 group().texture_manager()->GetTextureInfo(client_texture_id_);
7766 EXPECT_EQ(kServiceTextureId, info->service_id());
7767
7768 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0), 1);
7769 EXPECT_FALSE(group().image_manager()->LookupImage(1) == NULL);
7770
7771 GLsizei width;
7772 GLsizei height;
7773 GLenum type;
7774 GLenum internal_format;
7775
7776 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7777 EXPECT_EQ(3, width);
7778 EXPECT_EQ(1, height);
7779 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
7780 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
7781 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
7782 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
7783
7784 // Bind image to texture.
7785 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd;
7786 bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1);
7787 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd));
7788 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7789 // Image should now be set.
7790 EXPECT_FALSE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
7791
7792 // Release image from texture.
7793 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd;
7794 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1);
7795 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd));
7796 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7797 // Image should no longer be set.
7798 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
7799 }
7800
7719 // TODO(gman): Complete this test. 7801 // TODO(gman): Complete this test.
7720 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { 7802 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) {
7721 // } 7803 // }
7722 7804
7723 // TODO(gman): BufferData 7805 // TODO(gman): BufferData
7724 7806
7725 // TODO(gman): BufferDataImmediate 7807 // TODO(gman): BufferDataImmediate
7726 7808
7727 // TODO(gman): BufferSubData 7809 // TODO(gman): BufferSubData
7728 7810
(...skipping 16 matching lines...) Expand all
7745 // TODO(gman): TexImage2DImmediate 7827 // TODO(gman): TexImage2DImmediate
7746 7828
7747 // TODO(gman): TexSubImage2DImmediate 7829 // TODO(gman): TexSubImage2DImmediate
7748 7830
7749 // TODO(gman): UseProgram 7831 // TODO(gman): UseProgram
7750 7832
7751 // TODO(gman): SwapBuffers 7833 // TODO(gman): SwapBuffers
7752 7834
7753 } // namespace gles2 7835 } // namespace gles2
7754 } // namespace gpu 7836 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698