| 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/layers/texture_layer.h" | 5 #include "cc/layers/texture_layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); | 1191 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); |
| 1192 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1192 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 { | 1195 { |
| 1196 scoped_ptr<TextureLayerImpl> impl_layer = | 1196 scoped_ptr<TextureLayerImpl> impl_layer = |
| 1197 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1197 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 1198 impl_layer->SetDrawsContent(true); | 1198 impl_layer->SetDrawsContent(true); |
| 1199 ContextProvider* context_provider = | 1199 ContextProvider* context_provider = |
| 1200 host_impl_.output_surface()->context_provider(); | 1200 host_impl_.output_surface()->context_provider(); |
| 1201 unsigned texture = | 1201 GLuint texture = 0; |
| 1202 context_provider->Context3d()->createTexture(); | 1202 context_provider->ContextGL()->GenTextures(1, &texture); |
| 1203 impl_layer->set_texture_id(texture); | 1203 impl_layer->set_texture_id(texture); |
| 1204 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1204 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 { | 1207 { |
| 1208 scoped_ptr<TextureLayerImpl> impl_layer = | 1208 scoped_ptr<TextureLayerImpl> impl_layer = |
| 1209 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1209 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 1210 impl_layer->SetDrawsContent(true); | 1210 impl_layer->SetDrawsContent(true); |
| 1211 impl_layer->set_texture_id(0); | 1211 impl_layer->set_texture_id(0); |
| 1212 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 1212 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1242 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); | 1242 SingleReleaseCallback::Create(test_data_.release_mailbox3_)); |
| 1243 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1243 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 { | 1246 { |
| 1247 scoped_ptr<TextureLayerImpl> impl_layer = | 1247 scoped_ptr<TextureLayerImpl> impl_layer = |
| 1248 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1248 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 1249 impl_layer->SetDrawsContent(true); | 1249 impl_layer->SetDrawsContent(true); |
| 1250 ContextProvider* context_provider = | 1250 ContextProvider* context_provider = |
| 1251 host_impl_.output_surface()->context_provider(); | 1251 host_impl_.output_surface()->context_provider(); |
| 1252 unsigned texture = | 1252 GLuint texture = 0; |
| 1253 context_provider->Context3d()->createTexture(); | 1253 context_provider->ContextGL()->GenTextures(1, &texture); |
| 1254 impl_layer->set_texture_id(texture); | 1254 impl_layer->set_texture_id(texture); |
| 1255 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1255 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 { | 1258 { |
| 1259 scoped_ptr<TextureLayerImpl> impl_layer = | 1259 scoped_ptr<TextureLayerImpl> impl_layer = |
| 1260 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1260 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 1261 impl_layer->SetDrawsContent(true); | 1261 impl_layer->SetDrawsContent(true); |
| 1262 impl_layer->set_texture_id(0); | 1262 impl_layer->set_texture_id(0); |
| 1263 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 1263 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 // Resourceless software mode. | 1266 // Resourceless software mode. |
| 1267 { | 1267 { |
| 1268 scoped_ptr<TextureLayerImpl> impl_layer = | 1268 scoped_ptr<TextureLayerImpl> impl_layer = |
| 1269 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 1269 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
| 1270 impl_layer->SetDrawsContent(true); | 1270 impl_layer->SetDrawsContent(true); |
| 1271 impl_layer->SetTextureMailbox( | 1271 impl_layer->SetTextureMailbox( |
| 1272 test_data_.mailbox1_, | 1272 test_data_.mailbox1_, |
| 1273 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); | 1273 SingleReleaseCallback::Create(test_data_.release_mailbox1_)); |
| 1274 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 1274 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 { | 1277 { |
| 1278 scoped_ptr<TextureLayerImpl> impl_layer = | 1278 scoped_ptr<TextureLayerImpl> impl_layer = |
| 1279 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 1279 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 1280 impl_layer->SetDrawsContent(true); | 1280 impl_layer->SetDrawsContent(true); |
| 1281 ContextProvider* context_provider = | 1281 ContextProvider* context_provider = |
| 1282 host_impl_.output_surface()->context_provider(); | 1282 host_impl_.output_surface()->context_provider(); |
| 1283 unsigned texture = | 1283 GLuint texture = 0; |
| 1284 context_provider->Context3d()->createTexture(); | 1284 context_provider->ContextGL()->GenTextures(1, &texture); |
| 1285 impl_layer->set_texture_id(texture); | 1285 impl_layer->set_texture_id(texture); |
| 1286 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 1286 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
| 1287 } | 1287 } |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { | 1290 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { |
| 1291 host_impl_.CreatePendingTree(); | 1291 host_impl_.CreatePendingTree(); |
| 1292 scoped_ptr<TextureLayerImpl> pending_layer; | 1292 scoped_ptr<TextureLayerImpl> pending_layer; |
| 1293 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); | 1293 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); |
| 1294 ASSERT_TRUE(pending_layer); | 1294 ASSERT_TRUE(pending_layer); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 bool result) OVERRIDE { | 1484 bool result) OVERRIDE { |
| 1485 ASSERT_TRUE(result); | 1485 ASSERT_TRUE(result); |
| 1486 EXPECT_EQ(expected_used_textures_on_draw_, | 1486 EXPECT_EQ(expected_used_textures_on_draw_, |
| 1487 ContextForImplThread(host_impl)->NumUsedTextures()); | 1487 ContextForImplThread(host_impl)->NumUsedTextures()); |
| 1488 } | 1488 } |
| 1489 | 1489 |
| 1490 virtual void AfterTest() OVERRIDE {} | 1490 virtual void AfterTest() OVERRIDE {} |
| 1491 | 1491 |
| 1492 private: | 1492 private: |
| 1493 TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) { | 1493 TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) { |
| 1494 return static_cast<TestWebGraphicsContext3D*>( | 1494 return static_cast<TestContextProvider*>( |
| 1495 host_impl->output_surface()->context_provider()->Context3d()); | 1495 host_impl->output_surface()->context_provider().get())->TestContext3d(); |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 scoped_refptr<TextureLayer> texture_layer_; | 1498 scoped_refptr<TextureLayer> texture_layer_; |
| 1499 unsigned texture_; | 1499 unsigned texture_; |
| 1500 int commit_count_; | 1500 int commit_count_; |
| 1501 | 1501 |
| 1502 // Used only on thread. | 1502 // Used only on thread. |
| 1503 unsigned expected_used_textures_on_draw_; | 1503 unsigned expected_used_textures_on_draw_; |
| 1504 | 1504 |
| 1505 // Used on either thread, protected by lock_. | 1505 // Used on either thread, protected by lock_. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 break; | 1646 break; |
| 1647 default: | 1647 default: |
| 1648 break; | 1648 break; |
| 1649 } | 1649 } |
| 1650 } | 1650 } |
| 1651 | 1651 |
| 1652 virtual void AfterTest() OVERRIDE {} | 1652 virtual void AfterTest() OVERRIDE {} |
| 1653 | 1653 |
| 1654 private: | 1654 private: |
| 1655 TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) { | 1655 TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) { |
| 1656 return static_cast<TestWebGraphicsContext3D*>( | 1656 return static_cast<TestContextProvider*>( |
| 1657 host_impl->output_surface()->context_provider()->Context3d()); | 1657 host_impl->output_surface()->context_provider().get())->TestContext3d(); |
| 1658 } | 1658 } |
| 1659 | 1659 |
| 1660 scoped_refptr<SolidColorLayer> solid_layer_; | 1660 scoped_refptr<SolidColorLayer> solid_layer_; |
| 1661 scoped_refptr<Layer> parent_layer_; | 1661 scoped_refptr<Layer> parent_layer_; |
| 1662 scoped_refptr<TextureLayer> texture_layer_; | 1662 scoped_refptr<TextureLayer> texture_layer_; |
| 1663 | 1663 |
| 1664 // Used on the main thread, and on the impl thread while the main thread is | 1664 // Used on the main thread, and on the impl thread while the main thread is |
| 1665 // blocked. | 1665 // blocked. |
| 1666 unsigned texture_; | 1666 unsigned texture_; |
| 1667 | 1667 |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2155 int callback_count_; | 2155 int callback_count_; |
| 2156 scoped_refptr<Layer> root_; | 2156 scoped_refptr<Layer> root_; |
| 2157 scoped_refptr<TextureLayer> layer_; | 2157 scoped_refptr<TextureLayer> layer_; |
| 2158 }; | 2158 }; |
| 2159 | 2159 |
| 2160 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 2160 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 2161 TextureLayerWithMailboxImplThreadDeleted); | 2161 TextureLayerWithMailboxImplThreadDeleted); |
| 2162 | 2162 |
| 2163 } // namespace | 2163 } // namespace |
| 2164 } // namespace cc | 2164 } // namespace cc |
| OLD | NEW |