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

Side by Side Diff: ui/gfx/compositor/layer_unittest.cc

Issue 8247009: Explicit animation support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated views desktop demo. Created 9 years, 2 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/canvas_skia.h" 9 #include "ui/gfx/canvas_skia.h"
10 #include "ui/gfx/compositor/compositor_observer.h" 10 #include "ui/gfx/compositor/compositor_observer.h"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 // Verifies that there is no hole present when one of the child layers has a 532 // Verifies that there is no hole present when one of the child layers has a
533 // transform. 533 // transform.
534 TEST_F(LayerWithNullDelegateTest, NoHoleWithTransform) { 534 TEST_F(LayerWithNullDelegateTest, NoHoleWithTransform) {
535 scoped_ptr<Layer> parent(CreateTextureLayer(gfx::Rect(0, 0, 400, 400))); 535 scoped_ptr<Layer> parent(CreateTextureLayer(gfx::Rect(0, 0, 400, 400)));
536 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100))); 536 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 100, 100)));
537 parent->Add(child.get()); 537 parent->Add(child.get());
538 538
539 EXPECT_TRUE(!parent->hole_rect().IsEmpty()); 539 EXPECT_TRUE(!parent->hole_rect().IsEmpty());
540 540
541 ui::Transform t; 541 ui::Transform t;
542 t.SetTranslate(-75, -75); 542 t.SetTranslate(-50, -50);
543 t.ConcatRotate(45.0f); 543 t.ConcatRotate(45.0f);
544 t.ConcatTranslate(75, 75); 544 t.ConcatTranslate(50, 50);
545 child->SetTransform(t); 545 child->SetTransform(t);
546 546
547 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), parent->hole_rect()); 547 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), parent->hole_rect());
548 } 548 }
549 549
550 // Verifies that if the child layer is rotated by a multiple of ninety degrees 550 // Verifies that if the child layer is rotated by a multiple of ninety degrees
551 // we punch a hole 551 // we punch a hole
552 TEST_F(LayerWithNullDelegateTest, HoleWithNinetyDegreeTransforms) { 552 TEST_F(LayerWithNullDelegateTest, HoleWithNinetyDegreeTransforms) {
553 scoped_ptr<Layer> parent(CreateTextureLayer(gfx::Rect(0, 0, 400, 400))); 553 scoped_ptr<Layer> parent(CreateTextureLayer(gfx::Rect(0, 0, 400, 400)));
554 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 50, 50))); 554 scoped_ptr<Layer> child(CreateTextureLayer(gfx::Rect(50, 50, 50, 50)));
555 parent->Add(child.get()); 555 parent->Add(child.get());
556 556
557 EXPECT_TRUE(!parent->hole_rect().IsEmpty()); 557 EXPECT_TRUE(!parent->hole_rect().IsEmpty());
558 558
559 for (int i = -4; i <= 4; ++i) { 559 for (int i = -4; i <= 4; ++i) {
560 ui::Transform t; 560 ui::Transform t;
561 t.SetTranslate(-75, -75); 561 // Need to rotate in local coordinates.
562 t.SetTranslate(-25, -25);
562 t.ConcatRotate(90.0f * i); 563 t.ConcatRotate(90.0f * i);
563 t.ConcatTranslate(75, 75); 564 t.ConcatTranslate(25, 25);
564 child->SetTransform(t); 565 child->SetTransform(t);
565 566
566 gfx::Rect target_rect = child->bounds(); 567 gfx::Rect target_rect(child->bounds().size());
567 child->transform().TransformRect(&target_rect); 568 t.ConcatTranslate(child->bounds().x(), child->bounds().y());
569 t.TransformRect(&target_rect);
570
568 EXPECT_EQ(target_rect, parent->hole_rect()); 571 EXPECT_EQ(target_rect, parent->hole_rect());
569 } 572 }
570 } 573 }
571 574
572 // Create this hierarchy: 575 // Create this hierarchy:
573 // L1 (no texture) 576 // L1 (no texture)
574 // +- L11 (texture) 577 // +- L11 (texture)
575 // +- L12 (no texture) (added after L1 is already set as root-layer) 578 // +- L12 (no texture) (added after L1 is already set as root-layer)
576 // +- L121 (texture) 579 // +- L121 (texture)
577 // +- L122 (texture) 580 // +- L122 (texture)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 EXPECT_FALSE(l2->IsDrawn()); 664 EXPECT_FALSE(l2->IsDrawn());
662 EXPECT_FALSE(l3->IsDrawn()); 665 EXPECT_FALSE(l3->IsDrawn());
663 666
664 l1->SetVisible(true); 667 l1->SetVisible(true);
665 EXPECT_TRUE(l1->IsDrawn()); 668 EXPECT_TRUE(l1->IsDrawn());
666 EXPECT_TRUE(l2->IsDrawn()); 669 EXPECT_TRUE(l2->IsDrawn());
667 EXPECT_FALSE(l3->IsDrawn()); 670 EXPECT_FALSE(l3->IsDrawn());
668 } 671 }
669 672
670 } // namespace ui 673 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698