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 5953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5964 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5964 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
5965 | 5965 |
5966 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 5966 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
5967 group().mailbox_manager()->GenerateMailboxName( | 5967 group().mailbox_manager()->GenerateMailboxName( |
5968 reinterpret_cast<MailboxName*>(mailbox)); | 5968 reinterpret_cast<MailboxName*>(mailbox)); |
5969 | 5969 |
5970 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); | 5970 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); |
5971 | 5971 |
5972 EXPECT_EQ(kServiceTextureId, texture_ref->service_id()); | 5972 EXPECT_EQ(kServiceTextureId, texture_ref->service_id()); |
5973 | 5973 |
5974 // Assigns and binds new service side texture ID. | |
5975 EXPECT_CALL(*gl_, GenTextures(1, _)) | |
5976 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) | |
5977 .RetiresOnSaturation(); | |
5978 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId)) | |
5979 .Times(1) | |
5980 .RetiresOnSaturation(); | |
5981 | |
5982 ProduceTextureCHROMIUM produce_cmd; | 5974 ProduceTextureCHROMIUM produce_cmd; |
5983 produce_cmd.Init( | 5975 produce_cmd.Init( |
5984 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); | 5976 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); |
5985 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); | 5977 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); |
5986 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5978 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
5987 | 5979 |
| 5980 // Create new texture for consume. |
| 5981 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 5982 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 5983 .RetiresOnSaturation(); |
| 5984 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, kNewClientId, kNewServiceId); |
| 5985 |
5988 // Assigns and binds original service size texture ID. | 5986 // Assigns and binds original service size texture ID. |
5989 EXPECT_CALL(*gl_, DeleteTextures(1, _)) | 5987 EXPECT_CALL(*gl_, DeleteTextures(1, _)) |
5990 .Times(1) | 5988 .Times(1) |
5991 .RetiresOnSaturation(); | 5989 .RetiresOnSaturation(); |
5992 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) | 5990 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) |
5993 .Times(1) | 5991 .Times(1) |
5994 .RetiresOnSaturation(); | 5992 .RetiresOnSaturation(); |
5995 | 5993 |
5996 // TextureManager::Restore will set TexParameters. | |
5997 EXPECT_CALL(*gl_, TexParameteri( | |
5998 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR)) | |
5999 .Times(1) | |
6000 .RetiresOnSaturation(); | |
6001 EXPECT_CALL(*gl_, TexParameteri( | |
6002 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR)) | |
6003 .Times(1) | |
6004 .RetiresOnSaturation(); | |
6005 EXPECT_CALL(*gl_, TexParameteri( | |
6006 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)) | |
6007 .Times(1) | |
6008 .RetiresOnSaturation(); | |
6009 EXPECT_CALL(*gl_, TexParameteri( | |
6010 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)) | |
6011 .Times(1) | |
6012 .RetiresOnSaturation(); | |
6013 #if 0 | |
6014 EXPECT_CALL(*gl_, TexParameteri( | |
6015 GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_NONE)) | |
6016 .Times(1) | |
6017 .RetiresOnSaturation(); | |
6018 #endif | |
6019 | |
6020 // Shared mem got clobbered from GetError() above. | 5994 // Shared mem got clobbered from GetError() above. |
6021 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); | 5995 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); |
6022 ConsumeTextureCHROMIUM consume_cmd; | 5996 ConsumeTextureCHROMIUM consume_cmd; |
6023 consume_cmd.Init( | 5997 consume_cmd.Init( |
6024 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); | 5998 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); |
6025 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); | 5999 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); |
6026 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 6000 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
6027 | 6001 |
6028 // Service ID is restored. | 6002 // Service ID is restored. |
6029 EXPECT_EQ(kServiceTextureId, texture_ref->service_id()); | 6003 EXPECT_EQ(kServiceTextureId, texture_ref->service_id()); |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7398 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 7372 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
7399 0, 0); | 7373 0, 0); |
7400 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 7374 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
7401 0, 0); | 7375 0, 0); |
7402 TextureRef* texture_ref = group().texture_manager()->GetTexture( | 7376 TextureRef* texture_ref = group().texture_manager()->GetTexture( |
7403 client_texture_id_); | 7377 client_texture_id_); |
7404 ASSERT_TRUE(texture_ref != NULL); | 7378 ASSERT_TRUE(texture_ref != NULL); |
7405 Texture* texture = texture_ref->texture(); | 7379 Texture* texture = texture_ref->texture(); |
7406 EXPECT_EQ(kServiceTextureId, texture->service_id()); | 7380 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
7407 | 7381 |
7408 // Assigns and binds new service side texture ID. | |
7409 EXPECT_CALL(*gl_, GenTextures(1, _)) | |
7410 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) | |
7411 .RetiresOnSaturation(); | |
7412 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kNewServiceId)) | |
7413 .Times(1) | |
7414 .RetiresOnSaturation(); | |
7415 | |
7416 ProduceTextureCHROMIUM produce_cmd; | 7382 ProduceTextureCHROMIUM produce_cmd; |
7417 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); | 7383 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); |
7418 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); | 7384 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); |
| 7385 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
7419 | 7386 |
7420 // Texture is zero-by-zero. | 7387 // Texture didn't change. |
7421 GLsizei width; | 7388 GLsizei width; |
7422 GLsizei height; | 7389 GLsizei height; |
7423 GLenum type; | 7390 GLenum type; |
7424 GLenum internal_format; | 7391 GLenum internal_format; |
7425 | 7392 |
7426 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 7393 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
7427 EXPECT_EQ(0, width); | 7394 EXPECT_EQ(3, width); |
7428 EXPECT_EQ(0, height); | 7395 EXPECT_EQ(1, height); |
7429 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | 7396 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
7430 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | 7397 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
7431 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | 7398 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
7432 | 7399 |
7433 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); | 7400 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
7434 EXPECT_EQ(0, width); | 7401 EXPECT_EQ(2, width); |
7435 EXPECT_EQ(0, height); | 7402 EXPECT_EQ(4, height); |
7436 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); | 7403 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); |
7437 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | 7404 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
7438 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | 7405 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
7439 | 7406 |
7440 // Service ID has changed. | 7407 // Service ID has not changed. |
7441 EXPECT_EQ(kNewServiceId, texture->service_id()); | 7408 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
| 7409 |
| 7410 // Create new texture for consume. |
| 7411 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 7412 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 7413 .RetiresOnSaturation(); |
| 7414 DoBindTexture(GL_TEXTURE_2D, kNewClientId, kNewServiceId); |
7442 | 7415 |
7443 // Assigns and binds original service size texture ID. | 7416 // Assigns and binds original service size texture ID. |
7444 EXPECT_CALL(*gl_, DeleteTextures(1, _)) | 7417 EXPECT_CALL(*gl_, DeleteTextures(1, _)) |
7445 .Times(1) | 7418 .Times(1) |
7446 .RetiresOnSaturation(); | 7419 .RetiresOnSaturation(); |
7447 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | 7420 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
7448 .Times(1) | 7421 .Times(1) |
7449 .RetiresOnSaturation(); | 7422 .RetiresOnSaturation(); |
7450 | 7423 |
7451 // TextureManager::Restore will set TexParameters. | 7424 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); |
7452 EXPECT_CALL(*gl_, TexParameteri( | |
7453 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR)) | |
7454 .Times(1) | |
7455 .RetiresOnSaturation(); | |
7456 EXPECT_CALL(*gl_, TexParameteri( | |
7457 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)) | |
7458 .Times(1) | |
7459 .RetiresOnSaturation(); | |
7460 EXPECT_CALL(*gl_, TexParameteri( | |
7461 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)) | |
7462 .Times(1) | |
7463 .RetiresOnSaturation(); | |
7464 EXPECT_CALL(*gl_, TexParameteri( | |
7465 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)) | |
7466 .Times(1) | |
7467 .RetiresOnSaturation(); | |
7468 #if 0 | |
7469 EXPECT_CALL(*gl_, TexParameteri( | |
7470 GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_NONE)) | |
7471 .Times(1) | |
7472 .RetiresOnSaturation(); | |
7473 #endif | |
7474 | |
7475 ConsumeTextureCHROMIUM consume_cmd; | 7425 ConsumeTextureCHROMIUM consume_cmd; |
7476 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); | 7426 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); |
7477 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); | 7427 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); |
| 7428 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
7478 | 7429 |
7479 // Texture is redefined. | 7430 // Texture is redefined. |
7480 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); | 7431 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
7481 EXPECT_EQ(3, width); | 7432 EXPECT_EQ(3, width); |
7482 EXPECT_EQ(1, height); | 7433 EXPECT_EQ(1, height); |
7483 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); | 7434 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
7484 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); | 7435 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
7485 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); | 7436 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
7486 | 7437 |
7487 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); | 7438 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8641 // TODO(gman): TexImage2DImmediate | 8592 // TODO(gman): TexImage2DImmediate |
8642 | 8593 |
8643 // TODO(gman): TexSubImage2DImmediate | 8594 // TODO(gman): TexSubImage2DImmediate |
8644 | 8595 |
8645 // TODO(gman): UseProgram | 8596 // TODO(gman): UseProgram |
8646 | 8597 |
8647 // TODO(gman): SwapBuffers | 8598 // TODO(gman): SwapBuffers |
8648 | 8599 |
8649 } // namespace gles2 | 8600 } // namespace gles2 |
8650 } // namespace gpu | 8601 } // namespace gpu |
OLD | NEW |