| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "cc/base/scoped_ptr_deque.h" | 9 #include "cc/base/scoped_ptr_deque.h" |
| 10 #include "cc/base/scoped_ptr_hash_map.h" | 10 #include "cc/base/scoped_ptr_hash_map.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox) OVERRIDE { | 226 virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox) OVERRIDE { |
| 227 return shared_data_->GenMailbox(mailbox); | 227 return shared_data_->GenMailbox(mailbox); |
| 228 } | 228 } |
| 229 | 229 |
| 230 virtual void produceTextureCHROMIUM(WGC3Denum target, | 230 virtual void produceTextureCHROMIUM(WGC3Denum target, |
| 231 const WGC3Dbyte* mailbox) OVERRIDE { | 231 const WGC3Dbyte* mailbox) OVERRIDE { |
| 232 ASSERT_TRUE(current_texture_); | 232 ASSERT_TRUE(current_texture_); |
| 233 ASSERT_EQ(target, GL_TEXTURE_2D); | 233 ASSERT_EQ(target, GL_TEXTURE_2D); |
| 234 | 234 |
| 235 // Delay moving the texture into the mailbox until the next | 235 // Delay moving the texture into the mailbox until the next |
| 236 // insertSyncPoint, so that it is not visible to other contexts that | 236 // InsertSyncPoint, so that it is not visible to other contexts that |
| 237 // haven't waited on that sync point. | 237 // haven't waited on that sync point. |
| 238 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture); | 238 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture); |
| 239 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox)); | 239 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox)); |
| 240 pending->texture = textures_.take(current_texture_); | 240 pending->texture = textures_.take(current_texture_); |
| 241 textures_.set(current_texture_, scoped_ptr<Texture>()); | 241 textures_.set(current_texture_, scoped_ptr<Texture>()); |
| 242 pending_produce_textures_.push_back(pending.Pass()); | 242 pending_produce_textures_.push_back(pending.Pass()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 virtual void consumeTextureCHROMIUM(WGC3Denum target, | 245 virtual void consumeTextureCHROMIUM(WGC3Denum target, |
| 246 const WGC3Dbyte* mailbox) OVERRIDE { | 246 const WGC3Dbyte* mailbox) OVERRIDE { |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); | 1035 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); |
| 1036 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); | 1036 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); |
| 1037 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); | 1037 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); |
| 1038 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); | 1038 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); |
| 1039 id = resource_provider->CreateResource( | 1039 id = resource_provider->CreateResource( |
| 1040 size, format, ResourceProvider::TextureUsageAny); | 1040 size, format, ResourceProvider::TextureUsageAny); |
| 1041 resource_provider->SetPixels(id, pixels, rect, rect, offset); | 1041 resource_provider->SetPixels(id, pixels, rect, rect, offset); |
| 1042 resource_provider->DeleteResource(id); | 1042 resource_provider->DeleteResource(id); |
| 1043 Mock::VerifyAndClearExpectations(context); | 1043 Mock::VerifyAndClearExpectations(context); |
| 1044 | 1044 |
| 1045 // Same for setPixelsFromBuffer | 1045 // Same for SetPixelsFromBuffer |
| 1046 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1046 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
| 1047 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); | 1047 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); |
| 1048 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); | 1048 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); |
| 1049 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); | 1049 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); |
| 1050 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); | 1050 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); |
| 1051 id = resource_provider->CreateResource( | 1051 id = resource_provider->CreateResource( |
| 1052 size, format, ResourceProvider::TextureUsageAny); | 1052 size, format, ResourceProvider::TextureUsageAny); |
| 1053 resource_provider->AcquirePixelBuffer(id); | 1053 resource_provider->AcquirePixelBuffer(id); |
| 1054 resource_provider->SetPixelsFromBuffer(id); | 1054 resource_provider->SetPixelsFromBuffer(id); |
| 1055 resource_provider->ReleasePixelBuffer(id); | 1055 resource_provider->ReleasePixelBuffer(id); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 Mock::VerifyAndClearExpectations(context); | 1143 Mock::VerifyAndClearExpectations(context); |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 INSTANTIATE_TEST_CASE_P( | 1146 INSTANTIATE_TEST_CASE_P( |
| 1147 ResourceProviderTests, | 1147 ResourceProviderTests, |
| 1148 ResourceProviderTest, | 1148 ResourceProviderTest, |
| 1149 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); | 1149 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); |
| 1150 | 1150 |
| 1151 } // namespace | 1151 } // namespace |
| 1152 } // namespace cc | 1152 } // namespace cc |
| OLD | NEW |