Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: cc/layers/texture_layer_unittest.cc

Issue 295193002: Get rid of graphics layer anchor points, and replace with transform origin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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()); 697 root_->SetTransformOrigin(gfx::Point3F());
698 root_->SetBounds(bounds); 698 root_->SetBounds(bounds);
699 699
700 layer_ = TextureLayer::CreateForMailbox(NULL); 700 layer_ = TextureLayer::CreateForMailbox(NULL);
701 layer_->SetIsDrawable(true); 701 layer_->SetIsDrawable(true);
702 layer_->SetAnchorPoint(gfx::PointF()); 702 layer_->SetTransformOrigin(gfx::Point3F());
703 layer_->SetBounds(bounds); 703 layer_->SetBounds(bounds);
704 704
705 root_->AddChild(layer_); 705 root_->AddChild(layer_);
706 layer_tree_host()->SetRootLayer(root_); 706 layer_tree_host()->SetRootLayer(root_);
707 layer_tree_host()->SetViewportSize(bounds); 707 layer_tree_host()->SetViewportSize(bounds);
708 SetMailbox('1'); 708 SetMailbox('1');
709 EXPECT_EQ(0, callback_count_); 709 EXPECT_EQ(0, callback_count_);
710 710
711 // Case #1: change mailbox before the commit. The old mailbox should be 711 // Case #1: change mailbox before the commit. The old mailbox should be
712 // released immediately. 712 // released immediately.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 base::Bind( 812 base::Bind(
813 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); 813 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback));
814 layer_->SetTextureMailbox( 814 layer_->SetTextureMailbox(
815 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), 815 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0),
816 callback.Pass()); 816 callback.Pass());
817 } 817 }
818 818
819 virtual void BeginTest() OVERRIDE { 819 virtual void BeginTest() OVERRIDE {
820 gfx::Size bounds(100, 100); 820 gfx::Size bounds(100, 100);
821 root_ = Layer::Create(); 821 root_ = Layer::Create();
822 root_->SetAnchorPoint(gfx::PointF()); 822 root_->SetTransformOrigin(gfx::Point3F());
823 root_->SetBounds(bounds); 823 root_->SetBounds(bounds);
824 824
825 layer_ = TextureLayer::CreateForMailbox(NULL); 825 layer_ = TextureLayer::CreateForMailbox(NULL);
826 layer_->SetIsDrawable(true); 826 layer_->SetIsDrawable(true);
827 layer_->SetAnchorPoint(gfx::PointF()); 827 layer_->SetTransformOrigin(gfx::Point3F());
828 layer_->SetBounds(bounds); 828 layer_->SetBounds(bounds);
829 829
830 root_->AddChild(layer_); 830 root_->AddChild(layer_);
831 layer_tree_host()->SetRootLayer(root_); 831 layer_tree_host()->SetRootLayer(root_);
832 layer_tree_host()->SetViewportSize(bounds); 832 layer_tree_host()->SetViewportSize(bounds);
833 SetMailbox('1'); 833 SetMailbox('1');
834 834
835 PostSetNeedsCommitToMainThread(); 835 PostSetNeedsCommitToMainThread();
836 } 836 }
837 837
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 void MailboxReleased(uint32 sync_point, bool lost_resource) { 1122 void MailboxReleased(uint32 sync_point, bool lost_resource) {
1123 // Source frame number during callback is the same as the source frame 1123 // Source frame number during callback is the same as the source frame
1124 // on which it was released. 1124 // on which it was released.
1125 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); 1125 EXPECT_EQ(1, layer_tree_host()->source_frame_number());
1126 EndTest(); 1126 EndTest();
1127 } 1127 }
1128 1128
1129 virtual void SetupTree() OVERRIDE { 1129 virtual void SetupTree() OVERRIDE {
1130 scoped_refptr<Layer> root = Layer::Create(); 1130 scoped_refptr<Layer> root = Layer::Create();
1131 root->SetBounds(gfx::Size(10, 10)); 1131 root->SetBounds(gfx::Size(10, 10));
1132 root->SetAnchorPoint(gfx::PointF()); 1132 root->SetTransformOrigin(gfx::Point3F());
1133 root->SetIsDrawable(true); 1133 root->SetIsDrawable(true);
1134 1134
1135 texture_layer_ = TextureLayer::CreateForMailbox(this); 1135 texture_layer_ = TextureLayer::CreateForMailbox(this);
1136 texture_layer_->SetBounds(gfx::Size(10, 10)); 1136 texture_layer_->SetBounds(gfx::Size(10, 10));
1137 texture_layer_->SetAnchorPoint(gfx::PointF()); 1137 texture_layer_->SetTransformOrigin(gfx::Point3F());
1138 texture_layer_->SetIsDrawable(true); 1138 texture_layer_->SetIsDrawable(true);
1139 root->AddChild(texture_layer_); 1139 root->AddChild(texture_layer_);
1140 1140
1141 layer_tree_host()->SetRootLayer(root); 1141 layer_tree_host()->SetRootLayer(root);
1142 LayerTreeTest::SetupTree(); 1142 LayerTreeTest::SetupTree();
1143 } 1143 }
1144 1144
1145 virtual void BeginTest() OVERRIDE { 1145 virtual void BeginTest() OVERRIDE {
1146 PostSetNeedsCommitToMainThread(); 1146 PostSetNeedsCommitToMainThread();
1147 } 1147 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); 1222 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0);
1223 } 1223 }
1224 1224
1225 void MailboxReleased(uint32 sync_point, bool lost_resource) { 1225 void MailboxReleased(uint32 sync_point, bool lost_resource) {
1226 ++mailbox_returned_; 1226 ++mailbox_returned_;
1227 } 1227 }
1228 1228
1229 virtual void SetupTree() OVERRIDE { 1229 virtual void SetupTree() OVERRIDE {
1230 scoped_refptr<Layer> root = Layer::Create(); 1230 scoped_refptr<Layer> root = Layer::Create();
1231 root->SetBounds(gfx::Size(10, 10)); 1231 root->SetBounds(gfx::Size(10, 10));
1232 root->SetAnchorPoint(gfx::PointF()); 1232 root->SetTransformOrigin(gfx::Point3F());
1233 root->SetIsDrawable(true); 1233 root->SetIsDrawable(true);
1234 1234
1235 solid_layer_ = SolidColorLayer::Create(); 1235 solid_layer_ = SolidColorLayer::Create();
1236 solid_layer_->SetBounds(gfx::Size(10, 10)); 1236 solid_layer_->SetBounds(gfx::Size(10, 10));
1237 solid_layer_->SetIsDrawable(true); 1237 solid_layer_->SetIsDrawable(true);
1238 solid_layer_->SetBackgroundColor(SK_ColorWHITE); 1238 solid_layer_->SetBackgroundColor(SK_ColorWHITE);
1239 root->AddChild(solid_layer_); 1239 root->AddChild(solid_layer_);
1240 1240
1241 parent_layer_ = Layer::Create(); 1241 parent_layer_ = Layer::Create();
1242 parent_layer_->SetBounds(gfx::Size(10, 10)); 1242 parent_layer_->SetBounds(gfx::Size(10, 10));
1243 parent_layer_->SetIsDrawable(true); 1243 parent_layer_->SetIsDrawable(true);
1244 root->AddChild(parent_layer_); 1244 root->AddChild(parent_layer_);
1245 1245
1246 texture_layer_ = TextureLayer::CreateForMailbox(this); 1246 texture_layer_ = TextureLayer::CreateForMailbox(this);
1247 texture_layer_->SetBounds(gfx::Size(10, 10)); 1247 texture_layer_->SetBounds(gfx::Size(10, 10));
1248 texture_layer_->SetAnchorPoint(gfx::PointF()); 1248 texture_layer_->SetTransformOrigin(gfx::Point3F());
1249 texture_layer_->SetIsDrawable(true); 1249 texture_layer_->SetIsDrawable(true);
1250 parent_layer_->AddChild(texture_layer_); 1250 parent_layer_->AddChild(texture_layer_);
1251 1251
1252 layer_tree_host()->SetRootLayer(root); 1252 layer_tree_host()->SetRootLayer(root);
1253 LayerTreeTest::SetupTree(); 1253 LayerTreeTest::SetupTree();
1254 } 1254 }
1255 1255
1256 virtual void BeginTest() OVERRIDE { 1256 virtual void BeginTest() OVERRIDE {
1257 PostSetNeedsCommitToMainThread(); 1257 PostSetNeedsCommitToMainThread();
1258 } 1258 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 void MailboxReleased(unsigned sync_point, bool lost_resource) { 1357 void MailboxReleased(unsigned sync_point, bool lost_resource) {
1358 mailbox_released_ = true; 1358 mailbox_released_ = true;
1359 } 1359 }
1360 1360
1361 virtual void SetupTree() OVERRIDE { 1361 virtual void SetupTree() OVERRIDE {
1362 LayerTreeTest::SetupTree(); 1362 LayerTreeTest::SetupTree();
1363 1363
1364 scoped_refptr<TextureLayer> texture_layer = 1364 scoped_refptr<TextureLayer> texture_layer =
1365 TextureLayer::CreateForMailbox(this); 1365 TextureLayer::CreateForMailbox(this);
1366 texture_layer->SetBounds(gfx::Size(10, 10)); 1366 texture_layer->SetBounds(gfx::Size(10, 10));
1367 texture_layer->SetAnchorPoint(gfx::PointF()); 1367 texture_layer->SetTransformOrigin(gfx::Point3F());
1368 texture_layer->SetIsDrawable(true); 1368 texture_layer->SetIsDrawable(true);
1369 1369
1370 layer_tree_host()->root_layer()->AddChild(texture_layer); 1370 layer_tree_host()->root_layer()->AddChild(texture_layer);
1371 } 1371 }
1372 1372
1373 virtual void BeginTest() OVERRIDE { 1373 virtual void BeginTest() OVERRIDE {
1374 mailbox_released_ = false; 1374 mailbox_released_ = false;
1375 PostSetNeedsCommitToMainThread(); 1375 PostSetNeedsCommitToMainThread();
1376 } 1376 }
1377 1377
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, 1428 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback,
1429 base::Unretained(this))); 1429 base::Unretained(this)));
1430 layer_->SetTextureMailbox( 1430 layer_->SetTextureMailbox(
1431 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), 1431 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0),
1432 callback.Pass()); 1432 callback.Pass());
1433 } 1433 }
1434 1434
1435 virtual void SetupTree() OVERRIDE { 1435 virtual void SetupTree() OVERRIDE {
1436 gfx::Size bounds(100, 100); 1436 gfx::Size bounds(100, 100);
1437 root_ = Layer::Create(); 1437 root_ = Layer::Create();
1438 root_->SetAnchorPoint(gfx::PointF()); 1438 root_->SetTransformOrigin(gfx::Point3F());
1439 root_->SetBounds(bounds); 1439 root_->SetBounds(bounds);
1440 1440
1441 layer_ = TextureLayer::CreateForMailbox(NULL); 1441 layer_ = TextureLayer::CreateForMailbox(NULL);
1442 layer_->SetIsDrawable(true); 1442 layer_->SetIsDrawable(true);
1443 layer_->SetAnchorPoint(gfx::PointF()); 1443 layer_->SetTransformOrigin(gfx::Point3F());
1444 layer_->SetBounds(bounds); 1444 layer_->SetBounds(bounds);
1445 1445
1446 root_->AddChild(layer_); 1446 root_->AddChild(layer_);
1447 layer_tree_host()->SetRootLayer(root_); 1447 layer_tree_host()->SetRootLayer(root_);
1448 layer_tree_host()->SetViewportSize(bounds); 1448 layer_tree_host()->SetViewportSize(bounds);
1449 } 1449 }
1450 1450
1451 virtual void BeginTest() OVERRIDE { 1451 virtual void BeginTest() OVERRIDE {
1452 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1452 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1453 1453
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, 1501 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback,
1502 base::Unretained(this))); 1502 base::Unretained(this)));
1503 layer_->SetTextureMailbox( 1503 layer_->SetTextureMailbox(
1504 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), 1504 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0),
1505 callback.Pass()); 1505 callback.Pass());
1506 } 1506 }
1507 1507
1508 virtual void SetupTree() OVERRIDE { 1508 virtual void SetupTree() OVERRIDE {
1509 gfx::Size bounds(100, 100); 1509 gfx::Size bounds(100, 100);
1510 root_ = Layer::Create(); 1510 root_ = Layer::Create();
1511 root_->SetAnchorPoint(gfx::PointF()); 1511 root_->SetTransformOrigin(gfx::Point3F());
1512 root_->SetBounds(bounds); 1512 root_->SetBounds(bounds);
1513 1513
1514 layer_ = TextureLayer::CreateForMailbox(NULL); 1514 layer_ = TextureLayer::CreateForMailbox(NULL);
1515 layer_->SetIsDrawable(true); 1515 layer_->SetIsDrawable(true);
1516 layer_->SetAnchorPoint(gfx::PointF()); 1516 layer_->SetTransformOrigin(gfx::Point3F());
1517 layer_->SetBounds(bounds); 1517 layer_->SetBounds(bounds);
1518 1518
1519 root_->AddChild(layer_); 1519 root_->AddChild(layer_);
1520 layer_tree_host()->SetRootLayer(root_); 1520 layer_tree_host()->SetRootLayer(root_);
1521 layer_tree_host()->SetViewportSize(bounds); 1521 layer_tree_host()->SetViewportSize(bounds);
1522 } 1522 }
1523 1523
1524 virtual void BeginTest() OVERRIDE { 1524 virtual void BeginTest() OVERRIDE {
1525 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 1525 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
1526 1526
(...skipping 29 matching lines...) Expand all
1556 int callback_count_; 1556 int callback_count_;
1557 scoped_refptr<Layer> root_; 1557 scoped_refptr<Layer> root_;
1558 scoped_refptr<TextureLayer> layer_; 1558 scoped_refptr<TextureLayer> layer_;
1559 }; 1559 };
1560 1560
1561 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1561 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1562 TextureLayerWithMailboxImplThreadDeleted); 1562 TextureLayerWithMailboxImplThreadDeleted);
1563 1563
1564 } // namespace 1564 } // namespace
1565 } // namespace cc 1565 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698