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

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 6769 matching lines...) Expand 10 before | Expand all | Expand 10 after
6780 EXPECT_FALSE(query->pending()); 6780 EXPECT_FALSE(query->pending());
6781 6781
6782 // Test end succeeds 6782 // Test end succeeds
6783 EndQueryEXT end_cmd; 6783 EndQueryEXT end_cmd;
6784 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); 6784 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1);
6785 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 6785 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
6786 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6786 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6787 EXPECT_FALSE(query->pending()); 6787 EXPECT_FALSE(query->pending());
6788 } 6788 }
6789 6789
6790 TEST_F(GLES2DecoderTest, GenMailboxCHROMIUM) {
6791 const uint32 kBucketId = 123;
6792
6793 GenMailboxCHROMIUM gen_mailbox_cmd;
6794 gen_mailbox_cmd.Init(kBucketId);
6795 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_mailbox_cmd));
6796
6797 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
6798 ASSERT_TRUE(bucket != NULL);
6799 ASSERT_EQ(kMailboxSize, bucket->size());
6800
6801 static const char zero[kMailboxSize] = {
6802 0
6803 };
6804 EXPECT_NE(0, memcmp(zero,
6805 bucket->GetData(0, kMailboxSize),
6806 sizeof(kMailboxSize)));
6807 }
6808
6809 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) {
6810 static const char mailbox[kMailboxSize] = {
6811 1, 2, 3
6812 };
6813
6814 memcpy(shared_memory_address_, mailbox, sizeof(mailbox));
6815
6816 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6817 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6818 0, 0);
6819 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6820 0, 0);
6821 TextureManager::TextureInfo* info =
6822 group().texture_manager()->GetTextureInfo(client_texture_id_);
6823 EXPECT_EQ(kServiceTextureId, info->service_id());
6824
6825 // Assigns and binds new service side texture ID and applies the texture
6826 // objects' state to it.
6827 EXPECT_CALL(*gl_, GenTextures(1, _))
6828 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
6829 .RetiresOnSaturation();
6830 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kNewServiceId))
6831 .Times(1)
6832 .RetiresOnSaturation();
6833 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6834 GL_TEXTURE_MIN_FILTER,
6835 GL_NEAREST_MIPMAP_LINEAR));
6836 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6837 GL_TEXTURE_MAG_FILTER,
6838 GL_LINEAR));
6839 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6840 GL_TEXTURE_WRAP_S,
6841 GL_REPEAT));
6842 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6843 GL_TEXTURE_WRAP_T,
6844 GL_REPEAT));
6845
6846 ProduceTextureCHROMIUM produce_cmd;
6847 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset);
6848 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd));
6849
6850 // Texture is zero-by-zero.
6851 GLsizei width;
6852 GLsizei height;
6853 GLenum type;
6854 GLenum internal_format;
6855
6856 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
6857 EXPECT_EQ(0, width);
6858 EXPECT_EQ(0, height);
6859 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
6860 EXPECT_EQ(GL_RGBA, internal_format);
6861 EXPECT_EQ(GL_UNSIGNED_BYTE, type);
6862
6863 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
6864 EXPECT_EQ(0, width);
6865 EXPECT_EQ(0, height);
6866 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format));
6867 EXPECT_EQ(GL_RGBA, internal_format);
6868 EXPECT_EQ(GL_UNSIGNED_BYTE, type);
6869
6870 // Service ID has changed.
6871 EXPECT_EQ(kNewServiceId, info->service_id());
6872
6873 // Assigns and binds original service side texture ID and applies the texture
6874 // objects' state to it.
6875 EXPECT_CALL(*gl_, DeleteTextures(1, _))
6876 .Times(1)
6877 .RetiresOnSaturation();
6878 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
6879 .Times(1)
6880 .RetiresOnSaturation();
6881 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6882 GL_TEXTURE_MIN_FILTER,
6883 GL_NEAREST_MIPMAP_LINEAR));
6884 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6885 GL_TEXTURE_MAG_FILTER,
6886 GL_LINEAR));
6887 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6888 GL_TEXTURE_WRAP_S,
6889 GL_REPEAT));
6890 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D,
6891 GL_TEXTURE_WRAP_T,
6892 GL_REPEAT));
6893
6894 ConsumeTextureCHROMIUM consume_cmd;
6895 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset);
6896 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd));
6897
6898 // Texture is redefined.
6899 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
6900 EXPECT_EQ(3, width);
6901 EXPECT_EQ(1, height);
6902 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
6903 EXPECT_EQ(GL_RGBA, internal_format);
6904 EXPECT_EQ(GL_UNSIGNED_BYTE, type);
6905
6906 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
6907 EXPECT_EQ(2, width);
6908 EXPECT_EQ(4, height);
6909 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format));
6910 EXPECT_EQ(GL_RGBA, internal_format);
6911 EXPECT_EQ(GL_UNSIGNED_BYTE, type);
6912
6913 // Service ID is restored.
6914 EXPECT_EQ(kServiceTextureId, info->service_id());
6915 }
6790 6916
6791 // TODO(gman): Complete this test. 6917 // TODO(gman): Complete this test.
6792 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { 6918 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) {
6793 // } 6919 // }
6794 6920
6795 // TODO(gman): BufferData 6921 // TODO(gman): BufferData
6796 6922
6797 // TODO(gman): BufferDataImmediate 6923 // TODO(gman): BufferDataImmediate
6798 6924
6799 // TODO(gman): BufferSubData 6925 // TODO(gman): BufferSubData
(...skipping 17 matching lines...) Expand all
6817 // TODO(gman): TexImage2DImmediate 6943 // TODO(gman): TexImage2DImmediate
6818 6944
6819 // TODO(gman): TexSubImage2DImmediate 6945 // TODO(gman): TexSubImage2DImmediate
6820 6946
6821 // TODO(gman): UseProgram 6947 // TODO(gman): UseProgram
6822 6948
6823 // TODO(gman): SwapBuffers 6949 // TODO(gman): SwapBuffers
6824 6950
6825 } // namespace gles2 6951 } // namespace gles2
6826 } // namespace gpu 6952 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698