| 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 5698 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5709       "GL_CHROMIUM_stream_texture",  // extensions |  5709       "GL_CHROMIUM_stream_texture",  // extensions | 
|  5710       false,   // has alpha |  5710       false,   // has alpha | 
|  5711       false,   // has depth |  5711       false,   // has depth | 
|  5712       false,   // has stencil |  5712       false,   // has stencil | 
|  5713       false,   // request alpha |  5713       false,   // request alpha | 
|  5714       false,   // request depth |  5714       false,   // request depth | 
|  5715       false,   // request stencil |  5715       false,   // request stencil | 
|  5716       true);   // bind generates resource |  5716       true);   // bind generates resource | 
|  5717  |  5717  | 
|  5718   Texture* texture = GetTexture(client_texture_id_); |  5718   Texture* texture = GetTexture(client_texture_id_); | 
|  5719   texture->SetStreamTexture(true); |  5719   group().texture_manager()->SetStreamTexture(texture, true); | 
|  5720  |  5720  | 
|  5721   CreateStreamTextureCHROMIUM cmd; |  5721   CreateStreamTextureCHROMIUM cmd; | 
|  5722   cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); |  5722   cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); | 
|  5723   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |  5723   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 
|  5724   EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |  5724   EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 
|  5725 } |  5725 } | 
|  5726  |  5726  | 
|  5727 TEST_F(GLES2DecoderManualInitTest, BindStreamTextureCHROMIUM) { |  5727 TEST_F(GLES2DecoderManualInitTest, BindStreamTextureCHROMIUM) { | 
|  5728   InitDecoder( |  5728   InitDecoder( | 
|  5729       "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external",  // extensions |  5729       "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external",  // extensions | 
|  5730       false,   // has alpha |  5730       false,   // has alpha | 
|  5731       false,   // has depth |  5731       false,   // has depth | 
|  5732       false,   // has stencil |  5732       false,   // has stencil | 
|  5733       false,   // request alpha |  5733       false,   // request alpha | 
|  5734       false,   // request depth |  5734       false,   // request depth | 
|  5735       false,   // request stencil |  5735       false,   // request stencil | 
|  5736       true);   // bind generates resource |  5736       true);   // bind generates resource | 
|  5737  |  5737  | 
|  5738   StrictMock<MockStreamTextureManager> manager; |  5738   StrictMock<MockStreamTextureManager> manager; | 
|  5739   StrictMock<MockStreamTexture> stream_texture; |  5739   StrictMock<MockStreamTexture> stream_texture; | 
|  5740   decoder_->SetStreamTextureManager(&manager); |  5740   decoder_->SetStreamTextureManager(&manager); | 
|  5741  |  5741  | 
|  5742   Texture* texture = GetTexture(client_texture_id_); |  5742   Texture* texture = GetTexture(client_texture_id_); | 
|  5743   texture->SetStreamTexture(true); |  5743   group().texture_manager()->SetStreamTexture(texture, true); | 
|  5744  |  5744  | 
|  5745   EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) |  5745   EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) | 
|  5746       .Times(1) |  5746       .Times(1) | 
|  5747       .RetiresOnSaturation(); |  5747       .RetiresOnSaturation(); | 
|  5748   EXPECT_CALL(manager, LookupStreamTexture(kServiceTextureId)) |  5748   EXPECT_CALL(manager, LookupStreamTexture(kServiceTextureId)) | 
|  5749       .WillOnce(Return(&stream_texture)) |  5749       .WillOnce(Return(&stream_texture)) | 
|  5750       .RetiresOnSaturation(); |  5750       .RetiresOnSaturation(); | 
|  5751   EXPECT_CALL(stream_texture, Update()) |  5751   EXPECT_CALL(stream_texture, Update()) | 
|  5752       .Times(1) |  5752       .Times(1) | 
|  5753       .RetiresOnSaturation(); |  5753       .RetiresOnSaturation(); | 
|  5754  |  5754  | 
|  5755   BindTexture cmd; |  5755   BindTexture cmd; | 
|  5756   cmd.Init(GL_TEXTURE_EXTERNAL_OES, client_texture_id_); |  5756   cmd.Init(GL_TEXTURE_EXTERNAL_OES, client_texture_id_); | 
|  5757   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |  5757   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 
|  5758   EXPECT_EQ(GL_NO_ERROR, GetGLError()); |  5758   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
|  5759 } |  5759 } | 
|  5760  |  5760  | 
|  5761 TEST_F(GLES2DecoderManualInitTest, BindStreamTextureCHROMIUMInvalid) { |  5761 TEST_F(GLES2DecoderManualInitTest, BindStreamTextureCHROMIUMInvalid) { | 
|  5762   InitDecoder( |  5762   InitDecoder( | 
|  5763       "GL_CHROMIUM_stream_texture",  // extensions |  5763       "GL_CHROMIUM_stream_texture",  // extensions | 
|  5764       false,   // has alpha |  5764       false,   // has alpha | 
|  5765       false,   // has depth |  5765       false,   // has depth | 
|  5766       false,   // has stencil |  5766       false,   // has stencil | 
|  5767       false,   // request alpha |  5767       false,   // request alpha | 
|  5768       false,   // request depth |  5768       false,   // request depth | 
|  5769       false,   // request stencil |  5769       false,   // request stencil | 
|  5770       true);   // bind generates resource |  5770       true);   // bind generates resource | 
|  5771  |  5771  | 
|  5772   Texture* texture = GetTexture(client_texture_id_); |  5772   Texture* texture = GetTexture(client_texture_id_); | 
|  5773   texture->SetStreamTexture(true); |  5773   group().texture_manager()->SetStreamTexture(texture, true); | 
|  5774  |  5774  | 
|  5775   BindTexture cmd; |  5775   BindTexture cmd; | 
|  5776   cmd.Init(GL_TEXTURE_2D, client_texture_id_); |  5776   cmd.Init(GL_TEXTURE_2D, client_texture_id_); | 
|  5777   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |  5777   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 
|  5778   EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |  5778   EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 
|  5779  |  5779  | 
|  5780   BindTexture cmd2; |  5780   BindTexture cmd2; | 
|  5781   cmd2.Init(GL_TEXTURE_CUBE_MAP, client_texture_id_); |  5781   cmd2.Init(GL_TEXTURE_CUBE_MAP, client_texture_id_); | 
|  5782   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |  5782   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 
|  5783   EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |  5783   EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 
|  5784 } |  5784 } | 
|  5785  |  5785  | 
|  5786 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUM) { |  5786 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUM) { | 
|  5787   InitDecoder( |  5787   InitDecoder( | 
|  5788       "GL_CHROMIUM_stream_texture",  // extensions |  5788       "GL_CHROMIUM_stream_texture",  // extensions | 
|  5789       false,   // has alpha |  5789       false,   // has alpha | 
|  5790       false,   // has depth |  5790       false,   // has depth | 
|  5791       false,   // has stencil |  5791       false,   // has stencil | 
|  5792       false,   // request alpha |  5792       false,   // request alpha | 
|  5793       false,   // request depth |  5793       false,   // request depth | 
|  5794       false,   // request stencil |  5794       false,   // request stencil | 
|  5795       true);   // bind generates resource |  5795       true);   // bind generates resource | 
|  5796  |  5796  | 
|  5797   StrictMock<MockStreamTextureManager> manager; |  5797   StrictMock<MockStreamTextureManager> manager; | 
|  5798   decoder_->SetStreamTextureManager(&manager); |  5798   decoder_->SetStreamTextureManager(&manager); | 
|  5799  |  5799  | 
|  5800   Texture* texture = GetTexture(client_texture_id_); |  5800   Texture* texture = GetTexture(client_texture_id_); | 
|  5801   texture->SetStreamTexture(true); |  5801   group().texture_manager()->SetStreamTexture(texture, true); | 
|  5802  |  5802  | 
|  5803   EXPECT_CALL(manager, DestroyStreamTexture(kServiceTextureId)) |  5803   EXPECT_CALL(manager, DestroyStreamTexture(kServiceTextureId)) | 
|  5804       .Times(1) |  5804       .Times(1) | 
|  5805       .RetiresOnSaturation(); |  5805       .RetiresOnSaturation(); | 
|  5806  |  5806  | 
|  5807   DestroyStreamTextureCHROMIUM cmd; |  5807   DestroyStreamTextureCHROMIUM cmd; | 
|  5808   cmd.Init(client_texture_id_); |  5808   cmd.Init(client_texture_id_); | 
|  5809   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |  5809   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 
|  5810   EXPECT_EQ(GL_NO_ERROR, GetGLError()); |  5810   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
|  5811   EXPECT_FALSE(texture->IsStreamTexture()); |  5811   EXPECT_FALSE(texture->IsStreamTexture()); | 
|  5812   EXPECT_EQ(0U, texture->target()); |  5812   EXPECT_EQ(0U, texture->target()); | 
|  5813 } |  5813 } | 
|  5814  |  5814  | 
|  5815 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUMInvalid) { |  5815 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUMInvalid) { | 
|  5816   InitDecoder( |  5816   InitDecoder( | 
|  5817       "GL_CHROMIUM_stream_texture",  // extensions |  5817       "GL_CHROMIUM_stream_texture",  // extensions | 
|  5818       false,   // has alpha |  5818       false,   // has alpha | 
|  5819       false,   // has depth |  5819       false,   // has depth | 
|  5820       false,   // has stencil |  5820       false,   // has stencil | 
|  5821       false,   // request alpha |  5821       false,   // request alpha | 
|  5822       false,   // request depth |  5822       false,   // request depth | 
|  5823       false,   // request stencil |  5823       false,   // request stencil | 
|  5824       true);   // bind generates resource |  5824       true);   // bind generates resource | 
|  5825  |  5825  | 
|  5826   Texture* texture = GetTexture(client_texture_id_); |  5826   Texture* texture = GetTexture(client_texture_id_); | 
|  5827   texture->SetStreamTexture(false); |  5827   group().texture_manager()->SetStreamTexture(texture, false); | 
|  5828  |  5828  | 
|  5829   DestroyStreamTextureCHROMIUM cmd; |  5829   DestroyStreamTextureCHROMIUM cmd; | 
|  5830   cmd.Init(client_texture_id_); |  5830   cmd.Init(client_texture_id_); | 
|  5831   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |  5831   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 
|  5832   EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |  5832   EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 
|  5833 } |  5833 } | 
|  5834  |  5834  | 
|  5835 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUMBadId) { |  5835 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUMBadId) { | 
|  5836   InitDecoder( |  5836   InitDecoder( | 
|  5837       "GL_CHROMIUM_stream_texture",  // extensions |  5837       "GL_CHROMIUM_stream_texture",  // extensions | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  5859       false,   // request depth |  5859       false,   // request depth | 
|  5860       false,   // request stencil |  5860       false,   // request stencil | 
|  5861       true);   // bind generates resource |  5861       true);   // bind generates resource | 
|  5862  |  5862  | 
|  5863   CreateStreamTextureCHROMIUM cmd; |  5863   CreateStreamTextureCHROMIUM cmd; | 
|  5864   cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); |  5864   cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); | 
|  5865   EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); |  5865   EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); | 
|  5866   GetGLError(); // ignore internal error |  5866   GetGLError(); // ignore internal error | 
|  5867  |  5867  | 
|  5868   Texture* texture = GetTexture(client_texture_id_); |  5868   Texture* texture = GetTexture(client_texture_id_); | 
|  5869   texture->SetStreamTexture(true); |  5869   group().texture_manager()->SetStreamTexture(texture, true); | 
|  5870  |  5870  | 
|  5871   DestroyStreamTextureCHROMIUM cmd2; |  5871   DestroyStreamTextureCHROMIUM cmd2; | 
|  5872   cmd2.Init(client_texture_id_); |  5872   cmd2.Init(client_texture_id_); | 
|  5873   EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd2)); |  5873   EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd2)); | 
|  5874   GetGLError(); // ignore internal error |  5874   GetGLError(); // ignore internal error | 
|  5875 } |  5875 } | 
|  5876  |  5876  | 
|  5877 TEST_F(GLES2DecoderManualInitTest, ReCreateStreamTextureCHROMIUM) { |  5877 TEST_F(GLES2DecoderManualInitTest, ReCreateStreamTextureCHROMIUM) { | 
|  5878   const GLuint kObjectId = 123; |  5878   const GLuint kObjectId = 123; | 
|  5879   InitDecoder( |  5879   InitDecoder( | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  5898       .RetiresOnSaturation(); |  5898       .RetiresOnSaturation(); | 
|  5899   EXPECT_CALL(manager, DestroyStreamTexture(kServiceTextureId)) |  5899   EXPECT_CALL(manager, DestroyStreamTexture(kServiceTextureId)) | 
|  5900       .Times(1) |  5900       .Times(1) | 
|  5901       .RetiresOnSaturation(); |  5901       .RetiresOnSaturation(); | 
|  5902   EXPECT_CALL(manager, CreateStreamTexture(kServiceTextureId, |  5902   EXPECT_CALL(manager, CreateStreamTexture(kServiceTextureId, | 
|  5903                                            client_texture_id_)) |  5903                                            client_texture_id_)) | 
|  5904       .WillOnce(Return(kObjectId)) |  5904       .WillOnce(Return(kObjectId)) | 
|  5905       .RetiresOnSaturation(); |  5905       .RetiresOnSaturation(); | 
|  5906  |  5906  | 
|  5907   Texture* texture = GetTexture(client_texture_id_); |  5907   Texture* texture = GetTexture(client_texture_id_); | 
|  5908   texture->SetStreamTexture(true); |  5908   group().texture_manager()->SetStreamTexture(texture, true); | 
|  5909  |  5909  | 
|  5910   DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |  5910   DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | 
|  5911   EXPECT_EQ(GL_NO_ERROR, GetGLError()); |  5911   EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 
|  5912  |  5912  | 
|  5913   DestroyStreamTextureCHROMIUM cmd; |  5913   DestroyStreamTextureCHROMIUM cmd; | 
|  5914   cmd.Init(client_texture_id_); |  5914   cmd.Init(client_texture_id_); | 
|  5915   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |  5915   EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 
|  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  | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  5932       false,   // request alpha |  5932       false,   // request alpha | 
|  5933       false,   // request depth |  5933       false,   // request depth | 
|  5934       false,   // request stencil |  5934       false,   // request stencil | 
|  5935       true);   // bind generates resource |  5935       true);   // bind generates resource | 
|  5936  |  5936  | 
|  5937   StrictMock<MockStreamTextureManager> manager; |  5937   StrictMock<MockStreamTextureManager> manager; | 
|  5938   StrictMock<MockStreamTexture> stream_texture; |  5938   StrictMock<MockStreamTexture> stream_texture; | 
|  5939   decoder_->SetStreamTextureManager(&manager); |  5939   decoder_->SetStreamTextureManager(&manager); | 
|  5940  |  5940  | 
|  5941   Texture* texture = GetTexture(client_texture_id_); |  5941   Texture* texture = GetTexture(client_texture_id_); | 
|  5942   texture->SetStreamTexture(true); |  5942   group().texture_manager()->SetStreamTexture(texture, true); | 
|  5943  |  5943  | 
|  5944   EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) |  5944   EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) | 
|  5945       .Times(1) |  5945       .Times(1) | 
|  5946       .RetiresOnSaturation(); |  5946       .RetiresOnSaturation(); | 
|  5947   EXPECT_CALL(manager, LookupStreamTexture(kServiceTextureId)) |  5947   EXPECT_CALL(manager, LookupStreamTexture(kServiceTextureId)) | 
|  5948       .WillOnce(Return(&stream_texture)) |  5948       .WillOnce(Return(&stream_texture)) | 
|  5949       .RetiresOnSaturation(); |  5949       .RetiresOnSaturation(); | 
|  5950   EXPECT_CALL(stream_texture, Update()) |  5950   EXPECT_CALL(stream_texture, Update()) | 
|  5951       .Times(1) |  5951       .Times(1) | 
|  5952       .RetiresOnSaturation(); |  5952       .RetiresOnSaturation(); | 
| (...skipping 2668 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  8621 // TODO(gman): TexImage2DImmediate |  8621 // TODO(gman): TexImage2DImmediate | 
|  8622  |  8622  | 
|  8623 // TODO(gman): TexSubImage2DImmediate |  8623 // TODO(gman): TexSubImage2DImmediate | 
|  8624  |  8624  | 
|  8625 // TODO(gman): UseProgram |  8625 // TODO(gman): UseProgram | 
|  8626  |  8626  | 
|  8627 // TODO(gman): SwapBuffers |  8627 // TODO(gman): SwapBuffers | 
|  8628  |  8628  | 
|  8629 }  // namespace gles2 |  8629 }  // namespace gles2 | 
|  8630 }  // namespace gpu |  8630 }  // namespace gpu | 
| OLD | NEW |