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 5905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5916 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5916 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
5917 EXPECT_FALSE(texture->IsStreamTexture()); | 5917 EXPECT_FALSE(texture->IsStreamTexture()); |
5918 | 5918 |
5919 CreateStreamTextureCHROMIUM cmd2; | 5919 CreateStreamTextureCHROMIUM cmd2; |
5920 cmd2.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); | 5920 cmd2.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); |
5921 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 5921 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
5922 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5922 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
5923 EXPECT_TRUE(texture->IsStreamTexture()); | 5923 EXPECT_TRUE(texture->IsStreamTexture()); |
5924 } | 5924 } |
5925 | 5925 |
| 5926 TEST_F(GLES2DecoderManualInitTest, ProduceAndConsumeStreamTextureCHROMIUM) { |
| 5927 InitDecoder( |
| 5928 "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions |
| 5929 false, // has alpha |
| 5930 false, // has depth |
| 5931 false, // has stencil |
| 5932 false, // request alpha |
| 5933 false, // request depth |
| 5934 false, // request stencil |
| 5935 true); // bind generates resource |
| 5936 |
| 5937 StrictMock<MockStreamTextureManager> manager; |
| 5938 StrictMock<MockStreamTexture> stream_texture; |
| 5939 decoder_->SetStreamTextureManager(&manager); |
| 5940 |
| 5941 Texture* texture = GetTexture(client_texture_id_); |
| 5942 texture->SetStreamTexture(true); |
| 5943 |
| 5944 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) |
| 5945 .Times(1) |
| 5946 .RetiresOnSaturation(); |
| 5947 EXPECT_CALL(manager, LookupStreamTexture(kServiceTextureId)) |
| 5948 .WillOnce(Return(&stream_texture)) |
| 5949 .RetiresOnSaturation(); |
| 5950 EXPECT_CALL(stream_texture, Update()) |
| 5951 .Times(1) |
| 5952 .RetiresOnSaturation(); |
| 5953 |
| 5954 BindTexture cmd; |
| 5955 cmd.Init(GL_TEXTURE_EXTERNAL_OES, client_texture_id_); |
| 5956 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5957 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5958 |
| 5959 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
| 5960 group().mailbox_manager()->GenerateMailboxName( |
| 5961 reinterpret_cast<MailboxName*>(mailbox)); |
| 5962 |
| 5963 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); |
| 5964 |
| 5965 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 5966 |
| 5967 // Assigns and binds new service side texture ID. |
| 5968 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 5969 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 5970 .RetiresOnSaturation(); |
| 5971 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId)) |
| 5972 .Times(1) |
| 5973 .RetiresOnSaturation(); |
| 5974 |
| 5975 ProduceTextureCHROMIUM produce_cmd; |
| 5976 produce_cmd.Init( |
| 5977 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); |
| 5978 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); |
| 5979 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5980 |
| 5981 // Assigns and binds original service size texture ID. |
| 5982 EXPECT_CALL(*gl_, DeleteTextures(1, _)) |
| 5983 .Times(1) |
| 5984 .RetiresOnSaturation(); |
| 5985 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) |
| 5986 .Times(1) |
| 5987 .RetiresOnSaturation(); |
| 5988 |
| 5989 // TextureManager::Restore will set TexParameters. |
| 5990 EXPECT_CALL(*gl_, TexParameteri( |
| 5991 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR)) |
| 5992 .Times(1) |
| 5993 .RetiresOnSaturation(); |
| 5994 EXPECT_CALL(*gl_, TexParameteri( |
| 5995 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR)) |
| 5996 .Times(1) |
| 5997 .RetiresOnSaturation(); |
| 5998 EXPECT_CALL(*gl_, TexParameteri( |
| 5999 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)) |
| 6000 .Times(1) |
| 6001 .RetiresOnSaturation(); |
| 6002 EXPECT_CALL(*gl_, TexParameteri( |
| 6003 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)) |
| 6004 .Times(1) |
| 6005 .RetiresOnSaturation(); |
| 6006 #if 0 |
| 6007 EXPECT_CALL(*gl_, TexParameteri( |
| 6008 GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_NONE)) |
| 6009 .Times(1) |
| 6010 .RetiresOnSaturation(); |
| 6011 #endif |
| 6012 |
| 6013 // Shared mem got clobbered from GetError() above. |
| 6014 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); |
| 6015 ConsumeTextureCHROMIUM consume_cmd; |
| 6016 consume_cmd.Init( |
| 6017 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); |
| 6018 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); |
| 6019 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 6020 |
| 6021 // Service ID is restored. |
| 6022 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 6023 } |
| 6024 |
5926 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { | 6025 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { |
5927 InitDecoder( | 6026 InitDecoder( |
5928 "GL_ARB_texture_rectangle", // extensions | 6027 "GL_ARB_texture_rectangle", // extensions |
5929 false, // has alpha | 6028 false, // has alpha |
5930 false, // has depth | 6029 false, // has depth |
5931 false, // has stencil | 6030 false, // has stencil |
5932 false, // request alpha | 6031 false, // request alpha |
5933 false, // request depth | 6032 false, // request depth |
5934 false, // request stencil | 6033 false, // request stencil |
5935 true); // bind generates resource | 6034 true); // bind generates resource |
(...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8528 // TODO(gman): TexImage2DImmediate | 8627 // TODO(gman): TexImage2DImmediate |
8529 | 8628 |
8530 // TODO(gman): TexSubImage2DImmediate | 8629 // TODO(gman): TexSubImage2DImmediate |
8531 | 8630 |
8532 // TODO(gman): UseProgram | 8631 // TODO(gman): UseProgram |
8533 | 8632 |
8534 // TODO(gman): SwapBuffers | 8633 // TODO(gman): SwapBuffers |
8535 | 8634 |
8536 } // namespace gles2 | 8635 } // namespace gles2 |
8537 } // namespace gpu | 8636 } // namespace gpu |
OLD | NEW |