| 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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 layer_->SetTextureMailbox( | 687 layer_->SetTextureMailbox( |
| 688 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 688 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
| 689 callback.Pass()); | 689 callback.Pass()); |
| 690 } | 690 } |
| 691 | 691 |
| 692 virtual void BeginTest() OVERRIDE { | 692 virtual void BeginTest() OVERRIDE { |
| 693 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 693 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 694 | 694 |
| 695 gfx::Size bounds(100, 100); | 695 gfx::Size bounds(100, 100); |
| 696 root_ = Layer::Create(); | 696 root_ = Layer::Create(); |
| 697 root_->SetAnchorPoint(gfx::PointF()); | |
| 698 root_->SetBounds(bounds); | 697 root_->SetBounds(bounds); |
| 699 | 698 |
| 700 layer_ = TextureLayer::CreateForMailbox(NULL); | 699 layer_ = TextureLayer::CreateForMailbox(NULL); |
| 701 layer_->SetIsDrawable(true); | 700 layer_->SetIsDrawable(true); |
| 702 layer_->SetAnchorPoint(gfx::PointF()); | |
| 703 layer_->SetBounds(bounds); | 701 layer_->SetBounds(bounds); |
| 704 | 702 |
| 705 root_->AddChild(layer_); | 703 root_->AddChild(layer_); |
| 706 layer_tree_host()->SetRootLayer(root_); | 704 layer_tree_host()->SetRootLayer(root_); |
| 707 layer_tree_host()->SetViewportSize(bounds); | 705 layer_tree_host()->SetViewportSize(bounds); |
| 708 SetMailbox('1'); | 706 SetMailbox('1'); |
| 709 EXPECT_EQ(0, callback_count_); | 707 EXPECT_EQ(0, callback_count_); |
| 710 | 708 |
| 711 // Case #1: change mailbox before the commit. The old mailbox should be | 709 // Case #1: change mailbox before the commit. The old mailbox should be |
| 712 // released immediately. | 710 // released immediately. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 base::Bind( | 810 base::Bind( |
| 813 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 811 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
| 814 layer_->SetTextureMailbox( | 812 layer_->SetTextureMailbox( |
| 815 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 813 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
| 816 callback.Pass()); | 814 callback.Pass()); |
| 817 } | 815 } |
| 818 | 816 |
| 819 virtual void BeginTest() OVERRIDE { | 817 virtual void BeginTest() OVERRIDE { |
| 820 gfx::Size bounds(100, 100); | 818 gfx::Size bounds(100, 100); |
| 821 root_ = Layer::Create(); | 819 root_ = Layer::Create(); |
| 822 root_->SetAnchorPoint(gfx::PointF()); | |
| 823 root_->SetBounds(bounds); | 820 root_->SetBounds(bounds); |
| 824 | 821 |
| 825 layer_ = TextureLayer::CreateForMailbox(NULL); | 822 layer_ = TextureLayer::CreateForMailbox(NULL); |
| 826 layer_->SetIsDrawable(true); | 823 layer_->SetIsDrawable(true); |
| 827 layer_->SetAnchorPoint(gfx::PointF()); | |
| 828 layer_->SetBounds(bounds); | 824 layer_->SetBounds(bounds); |
| 829 | 825 |
| 830 root_->AddChild(layer_); | 826 root_->AddChild(layer_); |
| 831 layer_tree_host()->SetRootLayer(root_); | 827 layer_tree_host()->SetRootLayer(root_); |
| 832 layer_tree_host()->SetViewportSize(bounds); | 828 layer_tree_host()->SetViewportSize(bounds); |
| 833 SetMailbox('1'); | 829 SetMailbox('1'); |
| 834 | 830 |
| 835 PostSetNeedsCommitToMainThread(); | 831 PostSetNeedsCommitToMainThread(); |
| 836 } | 832 } |
| 837 | 833 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 void MailboxReleased(uint32 sync_point, bool lost_resource) { | 1118 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
| 1123 // Source frame number during callback is the same as the source frame | 1119 // Source frame number during callback is the same as the source frame |
| 1124 // on which it was released. | 1120 // on which it was released. |
| 1125 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); | 1121 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); |
| 1126 EndTest(); | 1122 EndTest(); |
| 1127 } | 1123 } |
| 1128 | 1124 |
| 1129 virtual void SetupTree() OVERRIDE { | 1125 virtual void SetupTree() OVERRIDE { |
| 1130 scoped_refptr<Layer> root = Layer::Create(); | 1126 scoped_refptr<Layer> root = Layer::Create(); |
| 1131 root->SetBounds(gfx::Size(10, 10)); | 1127 root->SetBounds(gfx::Size(10, 10)); |
| 1132 root->SetAnchorPoint(gfx::PointF()); | |
| 1133 root->SetIsDrawable(true); | 1128 root->SetIsDrawable(true); |
| 1134 | 1129 |
| 1135 texture_layer_ = TextureLayer::CreateForMailbox(this); | 1130 texture_layer_ = TextureLayer::CreateForMailbox(this); |
| 1136 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1131 texture_layer_->SetBounds(gfx::Size(10, 10)); |
| 1137 texture_layer_->SetAnchorPoint(gfx::PointF()); | |
| 1138 texture_layer_->SetIsDrawable(true); | 1132 texture_layer_->SetIsDrawable(true); |
| 1139 root->AddChild(texture_layer_); | 1133 root->AddChild(texture_layer_); |
| 1140 | 1134 |
| 1141 layer_tree_host()->SetRootLayer(root); | 1135 layer_tree_host()->SetRootLayer(root); |
| 1142 LayerTreeTest::SetupTree(); | 1136 LayerTreeTest::SetupTree(); |
| 1143 } | 1137 } |
| 1144 | 1138 |
| 1145 virtual void BeginTest() OVERRIDE { | 1139 virtual void BeginTest() OVERRIDE { |
| 1146 PostSetNeedsCommitToMainThread(); | 1140 PostSetNeedsCommitToMainThread(); |
| 1147 } | 1141 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); | 1216 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); |
| 1223 } | 1217 } |
| 1224 | 1218 |
| 1225 void MailboxReleased(uint32 sync_point, bool lost_resource) { | 1219 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
| 1226 ++mailbox_returned_; | 1220 ++mailbox_returned_; |
| 1227 } | 1221 } |
| 1228 | 1222 |
| 1229 virtual void SetupTree() OVERRIDE { | 1223 virtual void SetupTree() OVERRIDE { |
| 1230 scoped_refptr<Layer> root = Layer::Create(); | 1224 scoped_refptr<Layer> root = Layer::Create(); |
| 1231 root->SetBounds(gfx::Size(10, 10)); | 1225 root->SetBounds(gfx::Size(10, 10)); |
| 1232 root->SetAnchorPoint(gfx::PointF()); | |
| 1233 root->SetIsDrawable(true); | 1226 root->SetIsDrawable(true); |
| 1234 | 1227 |
| 1235 solid_layer_ = SolidColorLayer::Create(); | 1228 solid_layer_ = SolidColorLayer::Create(); |
| 1236 solid_layer_->SetBounds(gfx::Size(10, 10)); | 1229 solid_layer_->SetBounds(gfx::Size(10, 10)); |
| 1237 solid_layer_->SetIsDrawable(true); | 1230 solid_layer_->SetIsDrawable(true); |
| 1238 solid_layer_->SetBackgroundColor(SK_ColorWHITE); | 1231 solid_layer_->SetBackgroundColor(SK_ColorWHITE); |
| 1239 root->AddChild(solid_layer_); | 1232 root->AddChild(solid_layer_); |
| 1240 | 1233 |
| 1241 parent_layer_ = Layer::Create(); | 1234 parent_layer_ = Layer::Create(); |
| 1242 parent_layer_->SetBounds(gfx::Size(10, 10)); | 1235 parent_layer_->SetBounds(gfx::Size(10, 10)); |
| 1243 parent_layer_->SetIsDrawable(true); | 1236 parent_layer_->SetIsDrawable(true); |
| 1244 root->AddChild(parent_layer_); | 1237 root->AddChild(parent_layer_); |
| 1245 | 1238 |
| 1246 texture_layer_ = TextureLayer::CreateForMailbox(this); | 1239 texture_layer_ = TextureLayer::CreateForMailbox(this); |
| 1247 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1240 texture_layer_->SetBounds(gfx::Size(10, 10)); |
| 1248 texture_layer_->SetAnchorPoint(gfx::PointF()); | |
| 1249 texture_layer_->SetIsDrawable(true); | 1241 texture_layer_->SetIsDrawable(true); |
| 1250 parent_layer_->AddChild(texture_layer_); | 1242 parent_layer_->AddChild(texture_layer_); |
| 1251 | 1243 |
| 1252 layer_tree_host()->SetRootLayer(root); | 1244 layer_tree_host()->SetRootLayer(root); |
| 1253 LayerTreeTest::SetupTree(); | 1245 LayerTreeTest::SetupTree(); |
| 1254 } | 1246 } |
| 1255 | 1247 |
| 1256 virtual void BeginTest() OVERRIDE { | 1248 virtual void BeginTest() OVERRIDE { |
| 1257 PostSetNeedsCommitToMainThread(); | 1249 PostSetNeedsCommitToMainThread(); |
| 1258 } | 1250 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1349 void MailboxReleased(unsigned sync_point, bool lost_resource) { |
| 1358 mailbox_released_ = true; | 1350 mailbox_released_ = true; |
| 1359 } | 1351 } |
| 1360 | 1352 |
| 1361 virtual void SetupTree() OVERRIDE { | 1353 virtual void SetupTree() OVERRIDE { |
| 1362 LayerTreeTest::SetupTree(); | 1354 LayerTreeTest::SetupTree(); |
| 1363 | 1355 |
| 1364 scoped_refptr<TextureLayer> texture_layer = | 1356 scoped_refptr<TextureLayer> texture_layer = |
| 1365 TextureLayer::CreateForMailbox(this); | 1357 TextureLayer::CreateForMailbox(this); |
| 1366 texture_layer->SetBounds(gfx::Size(10, 10)); | 1358 texture_layer->SetBounds(gfx::Size(10, 10)); |
| 1367 texture_layer->SetAnchorPoint(gfx::PointF()); | |
| 1368 texture_layer->SetIsDrawable(true); | 1359 texture_layer->SetIsDrawable(true); |
| 1369 | 1360 |
| 1370 layer_tree_host()->root_layer()->AddChild(texture_layer); | 1361 layer_tree_host()->root_layer()->AddChild(texture_layer); |
| 1371 } | 1362 } |
| 1372 | 1363 |
| 1373 virtual void BeginTest() OVERRIDE { | 1364 virtual void BeginTest() OVERRIDE { |
| 1374 mailbox_released_ = false; | 1365 mailbox_released_ = false; |
| 1375 PostSetNeedsCommitToMainThread(); | 1366 PostSetNeedsCommitToMainThread(); |
| 1376 } | 1367 } |
| 1377 | 1368 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 1419 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
| 1429 base::Unretained(this))); | 1420 base::Unretained(this))); |
| 1430 layer_->SetTextureMailbox( | 1421 layer_->SetTextureMailbox( |
| 1431 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1422 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
| 1432 callback.Pass()); | 1423 callback.Pass()); |
| 1433 } | 1424 } |
| 1434 | 1425 |
| 1435 virtual void SetupTree() OVERRIDE { | 1426 virtual void SetupTree() OVERRIDE { |
| 1436 gfx::Size bounds(100, 100); | 1427 gfx::Size bounds(100, 100); |
| 1437 root_ = Layer::Create(); | 1428 root_ = Layer::Create(); |
| 1438 root_->SetAnchorPoint(gfx::PointF()); | |
| 1439 root_->SetBounds(bounds); | 1429 root_->SetBounds(bounds); |
| 1440 | 1430 |
| 1441 layer_ = TextureLayer::CreateForMailbox(NULL); | 1431 layer_ = TextureLayer::CreateForMailbox(NULL); |
| 1442 layer_->SetIsDrawable(true); | 1432 layer_->SetIsDrawable(true); |
| 1443 layer_->SetAnchorPoint(gfx::PointF()); | |
| 1444 layer_->SetBounds(bounds); | 1433 layer_->SetBounds(bounds); |
| 1445 | 1434 |
| 1446 root_->AddChild(layer_); | 1435 root_->AddChild(layer_); |
| 1447 layer_tree_host()->SetRootLayer(root_); | 1436 layer_tree_host()->SetRootLayer(root_); |
| 1448 layer_tree_host()->SetViewportSize(bounds); | 1437 layer_tree_host()->SetViewportSize(bounds); |
| 1449 } | 1438 } |
| 1450 | 1439 |
| 1451 virtual void BeginTest() OVERRIDE { | 1440 virtual void BeginTest() OVERRIDE { |
| 1452 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1441 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 1453 | 1442 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 1490 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
| 1502 base::Unretained(this))); | 1491 base::Unretained(this))); |
| 1503 layer_->SetTextureMailbox( | 1492 layer_->SetTextureMailbox( |
| 1504 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1493 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
| 1505 callback.Pass()); | 1494 callback.Pass()); |
| 1506 } | 1495 } |
| 1507 | 1496 |
| 1508 virtual void SetupTree() OVERRIDE { | 1497 virtual void SetupTree() OVERRIDE { |
| 1509 gfx::Size bounds(100, 100); | 1498 gfx::Size bounds(100, 100); |
| 1510 root_ = Layer::Create(); | 1499 root_ = Layer::Create(); |
| 1511 root_->SetAnchorPoint(gfx::PointF()); | |
| 1512 root_->SetBounds(bounds); | 1500 root_->SetBounds(bounds); |
| 1513 | 1501 |
| 1514 layer_ = TextureLayer::CreateForMailbox(NULL); | 1502 layer_ = TextureLayer::CreateForMailbox(NULL); |
| 1515 layer_->SetIsDrawable(true); | 1503 layer_->SetIsDrawable(true); |
| 1516 layer_->SetAnchorPoint(gfx::PointF()); | |
| 1517 layer_->SetBounds(bounds); | 1504 layer_->SetBounds(bounds); |
| 1518 | 1505 |
| 1519 root_->AddChild(layer_); | 1506 root_->AddChild(layer_); |
| 1520 layer_tree_host()->SetRootLayer(root_); | 1507 layer_tree_host()->SetRootLayer(root_); |
| 1521 layer_tree_host()->SetViewportSize(bounds); | 1508 layer_tree_host()->SetViewportSize(bounds); |
| 1522 } | 1509 } |
| 1523 | 1510 |
| 1524 virtual void BeginTest() OVERRIDE { | 1511 virtual void BeginTest() OVERRIDE { |
| 1525 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1512 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
| 1526 | 1513 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1556 int callback_count_; | 1543 int callback_count_; |
| 1557 scoped_refptr<Layer> root_; | 1544 scoped_refptr<Layer> root_; |
| 1558 scoped_refptr<TextureLayer> layer_; | 1545 scoped_refptr<TextureLayer> layer_; |
| 1559 }; | 1546 }; |
| 1560 | 1547 |
| 1561 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1548 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1562 TextureLayerWithMailboxImplThreadDeleted); | 1549 TextureLayerWithMailboxImplThreadDeleted); |
| 1563 | 1550 |
| 1564 } // namespace | 1551 } // namespace |
| 1565 } // namespace cc | 1552 } // namespace cc |
| OLD | NEW |