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

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

Issue 10106015: Allow textures to be moved from one GL context group to another. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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/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/gl_mock.h" 10 #include "gpu/command_buffer/common/gl_mock.h"
(...skipping 6728 matching lines...) Expand 10 before | Expand all | Expand 10 after
6739 EXPECT_FALSE(query->pending()); 6739 EXPECT_FALSE(query->pending());
6740 6740
6741 // Test end succeeds 6741 // Test end succeeds
6742 EndQueryEXT end_cmd; 6742 EndQueryEXT end_cmd;
6743 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); 6743 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1);
6744 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 6744 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
6745 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6745 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6746 EXPECT_FALSE(query->pending()); 6746 EXPECT_FALSE(query->pending());
6747 } 6747 }
6748 6748
6749 TEST_F(GLES2DecoderTest, ProduceAndConsumeTexture) {
Ken Russell (switch to Gerrit) 2012/04/23 20:12:00 Need a test which verifies the functionality acros
6750 const static GLint mailbox[32] = {
6751 1, 2, 3
6752 };
6753 memcpy(shared_memory_address_, mailbox, sizeof(mailbox));
6754
6755 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6756 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6757 0, 0);
6758 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6759 0, 0);
6760 TextureManager::TextureInfo* info =
6761 group().texture_manager()->GetTextureInfo(client_texture_id_);
6762 EXPECT_EQ(kServiceTextureId, info->service_id());
6763
6764 // Assigns and binds new service side texture ID and applies the texture
6765 // objects' state to it.
6766 EXPECT_CALL(*gl_, GenTextures(1, _))
6767 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
6768 .RetiresOnSaturation();
6769 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kNewServiceId))
6770 .Times(1)
6771 .RetiresOnSaturation();
6772 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6773 GL_TEXTURE_MIN_FILTER,
6774 GL_NEAREST_MIPMAP_LINEAR));
6775 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6776 GL_TEXTURE_MAG_FILTER,
6777 GL_LINEAR));
6778 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6779 GL_TEXTURE_WRAP_S,
6780 GL_REPEAT));
6781 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6782 GL_TEXTURE_WRAP_T,
6783 GL_REPEAT));
6784
6785 ProduceTextureCHROMIUM produce_cmd;
6786 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset);
6787 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd));
6788
6789 // Texture is zero-by-zero.
6790 GLsizei width;
6791 GLsizei height;
6792 GLenum type;
6793 GLenum internal_format;
6794
6795 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
6796 EXPECT_EQ(0, width);
6797 EXPECT_EQ(0, height);
6798 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
6799 EXPECT_EQ(GL_RGBA, internal_format);
6800 EXPECT_EQ(GL_UNSIGNED_BYTE, type);
6801
6802 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
6803 EXPECT_EQ(0, width);
6804 EXPECT_EQ(0, height);
6805 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format));
6806 EXPECT_EQ(GL_RGBA, internal_format);
6807 EXPECT_EQ(GL_UNSIGNED_BYTE, type);
6808
6809 // Service ID has changed.
6810 EXPECT_EQ(kNewServiceId, info->service_id());
6811
6812 // Assigns and binds original service side texture ID and applies the texture
6813 // objects' state to it.
6814 EXPECT_CALL(*gl_, DeleteTextures(1, _))
6815 .Times(1)
6816 .RetiresOnSaturation();
6817 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
6818 .Times(1)
6819 .RetiresOnSaturation();
6820 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6821 GL_TEXTURE_MIN_FILTER,
6822 GL_NEAREST_MIPMAP_LINEAR));
6823 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6824 GL_TEXTURE_MAG_FILTER,
6825 GL_LINEAR));
6826 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6827 GL_TEXTURE_WRAP_S,
6828 GL_REPEAT));
6829 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6830 GL_TEXTURE_WRAP_T,
6831 GL_REPEAT));
6832
6833 ConsumeTextureCHROMIUM consume_cmd;
6834 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset);
6835 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd));
6836
6837 // Texture is redefined.
6838 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
6839 EXPECT_EQ(3, width);
6840 EXPECT_EQ(1, height);
6841 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
6842 EXPECT_EQ(GL_RGBA, internal_format);
6843 EXPECT_EQ(GL_UNSIGNED_BYTE, type);
6844
6845 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
6846 EXPECT_EQ(2, width);
6847 EXPECT_EQ(4, height);
6848 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format));
6849 EXPECT_EQ(GL_RGBA, internal_format);
6850 EXPECT_EQ(GL_UNSIGNED_BYTE, type);
6851
6852 // Service ID is restored.
6853 EXPECT_EQ(kServiceTextureId, info->service_id());
6854 }
6749 6855
6750 // TODO(gman): Complete this test. 6856 // TODO(gman): Complete this test.
6751 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { 6857 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) {
6752 // } 6858 // }
6753 6859
6754 // TODO(gman): BufferData 6860 // TODO(gman): BufferData
6755 6861
6756 // TODO(gman): BufferDataImmediate 6862 // TODO(gman): BufferDataImmediate
6757 6863
6758 // TODO(gman): BufferSubData 6864 // TODO(gman): BufferSubData
(...skipping 17 matching lines...) Expand all
6776 // TODO(gman): TexImage2DImmediate 6882 // TODO(gman): TexImage2DImmediate
6777 6883
6778 // TODO(gman): TexSubImage2DImmediate 6884 // TODO(gman): TexSubImage2DImmediate
6779 6885
6780 // TODO(gman): UseProgram 6886 // TODO(gman): UseProgram
6781 6887
6782 // TODO(gman): SwapBuffers 6888 // TODO(gman): SwapBuffers
6783 6889
6784 } // namespace gles2 6890 } // namespace gles2
6785 } // namespace gpu 6891 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698