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

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

Issue 634113002: Use solid color layer for delegated surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 std::string roundtrip; 660 std::string roundtrip;
661 EXPECT_TRUE(dictionary->GetString("layer_name", &roundtrip)); 661 EXPECT_TRUE(dictionary->GetString("layer_name", &roundtrip));
662 EXPECT_EQ(name, roundtrip); 662 EXPECT_EQ(name, roundtrip);
663 } 663 }
664 664
665 void ReturnMailbox(bool* run, uint32 sync_point, bool is_lost) { 665 void ReturnMailbox(bool* run, uint32 sync_point, bool is_lost) {
666 *run = true; 666 *run = true;
667 } 667 }
668 668
669 TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) { 669 TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) {
670 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, 670 scoped_ptr<Layer> l1(CreateLayer(LAYER_SOLID_COLOR));
671 gfx::Rect(20, 20, 400, 400)));
672 l1->SetFillsBoundsOpaquely(true); 671 l1->SetFillsBoundsOpaquely(true);
673 l1->SetForceRenderSurface(true); 672 l1->SetForceRenderSurface(true);
674 l1->SetVisible(false); 673 l1->SetVisible(false);
675 674
676 EXPECT_EQ(gfx::Point3F(), l1->cc_layer()->transform_origin()); 675 EXPECT_EQ(gfx::Point3F(), l1->cc_layer()->transform_origin());
677 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); 676 EXPECT_TRUE(l1->cc_layer()->DrawsContent());
678 EXPECT_TRUE(l1->cc_layer()->contents_opaque()); 677 EXPECT_TRUE(l1->cc_layer()->contents_opaque());
679 EXPECT_TRUE(l1->cc_layer()->force_render_surface()); 678 EXPECT_TRUE(l1->cc_layer()->force_render_surface());
680 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); 679 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree());
681 680
(...skipping 17 matching lines...) Expand all
699 698
700 bool callback2_run = false; 699 bool callback2_run = false;
701 mailbox = cc::TextureMailbox(gpu::Mailbox::Generate(), 0, 0); 700 mailbox = cc::TextureMailbox(gpu::Mailbox::Generate(), 0, 0);
702 l1->SetTextureMailbox(mailbox, 701 l1->SetTextureMailbox(mailbox,
703 cc::SingleReleaseCallback::Create( 702 cc::SingleReleaseCallback::Create(
704 base::Bind(ReturnMailbox, &callback2_run)), 703 base::Bind(ReturnMailbox, &callback2_run)),
705 gfx::Size(1, 1)); 704 gfx::Size(1, 1));
706 EXPECT_TRUE(callback1_run); 705 EXPECT_TRUE(callback1_run);
707 EXPECT_FALSE(callback2_run); 706 EXPECT_FALSE(callback2_run);
708 707
709 l1->SetShowPaintedContent(); 708 l1->SetShowSolidColorContent();
710 EXPECT_EQ(gfx::Point3F(), l1->cc_layer()->transform_origin()); 709 EXPECT_EQ(gfx::Point3F(), l1->cc_layer()->transform_origin());
711 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); 710 EXPECT_TRUE(l1->cc_layer()->DrawsContent());
712 EXPECT_TRUE(l1->cc_layer()->contents_opaque()); 711 EXPECT_TRUE(l1->cc_layer()->contents_opaque());
713 EXPECT_TRUE(l1->cc_layer()->force_render_surface()); 712 EXPECT_TRUE(l1->cc_layer()->force_render_surface());
714 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); 713 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree());
715 EXPECT_TRUE(callback2_run); 714 EXPECT_TRUE(callback2_run);
716 } 715 }
717 716
718 // Various visibile/drawn assertions. 717 // Various visibile/drawn assertions.
719 TEST_F(LayerWithNullDelegateTest, Visibility) { 718 TEST_F(LayerWithNullDelegateTest, Visibility) {
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 // Low-DPI content on hi-DPI layer. 1483 // Low-DPI content on hi-DPI layer.
1485 frame_provider = new cc::DelegatedFrameProvider( 1484 frame_provider = new cc::DelegatedFrameProvider(
1486 resource_collection.get(), MakeFrameData(gfx::Size(10, 10))); 1485 resource_collection.get(), MakeFrameData(gfx::Size(10, 10)));
1487 child->SetShowDelegatedContent(frame_provider.get(), gfx::Size(10, 10)); 1486 child->SetShowDelegatedContent(frame_provider.get(), gfx::Size(10, 10));
1488 EXPECT_EQ(child->cc_layer()->bounds().ToString(), 1487 EXPECT_EQ(child->cc_layer()->bounds().ToString(),
1489 gfx::Size(10, 10).ToString()); 1488 gfx::Size(10, 10).ToString());
1490 } 1489 }
1491 1490
1492 TEST_F(LayerWithDelegateTest, ExternalContent) { 1491 TEST_F(LayerWithDelegateTest, ExternalContent) {
1493 scoped_ptr<Layer> root(CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000))); 1492 scoped_ptr<Layer> root(CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000)));
1494 scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED)); 1493 scoped_ptr<Layer> child(CreateLayer(LAYER_SOLID_COLOR));
1495 1494
1496 child->SetBounds(gfx::Rect(0, 0, 10, 10)); 1495 child->SetBounds(gfx::Rect(0, 0, 10, 10));
1497 child->SetVisible(true); 1496 child->SetVisible(true);
1498 root->Add(child.get()); 1497 root->Add(child.get());
1499 1498
1500 // The layer is already showing painted content, so the cc layer won't change. 1499 // The layer is already showing solid color content, so the cc layer won't
1500 // change.
1501 scoped_refptr<cc::Layer> before = child->cc_layer(); 1501 scoped_refptr<cc::Layer> before = child->cc_layer();
1502 child->SetShowPaintedContent(); 1502 child->SetShowSolidColorContent();
1503 EXPECT_TRUE(child->cc_layer()); 1503 EXPECT_TRUE(child->cc_layer());
1504 EXPECT_EQ(before.get(), child->cc_layer()); 1504 EXPECT_EQ(before.get(), child->cc_layer());
1505 1505
1506 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection = 1506 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection =
1507 new cc::DelegatedFrameResourceCollection; 1507 new cc::DelegatedFrameResourceCollection;
1508 scoped_refptr<cc::DelegatedFrameProvider> frame_provider = 1508 scoped_refptr<cc::DelegatedFrameProvider> frame_provider =
1509 new cc::DelegatedFrameProvider(resource_collection.get(), 1509 new cc::DelegatedFrameProvider(resource_collection.get(),
1510 MakeFrameData(gfx::Size(10, 10))); 1510 MakeFrameData(gfx::Size(10, 10)));
1511 1511
1512 // Showing delegated content changes the underlying cc layer. 1512 // Showing delegated content changes the underlying cc layer.
1513 before = child->cc_layer(); 1513 before = child->cc_layer();
1514 child->SetShowDelegatedContent(frame_provider.get(), gfx::Size(10, 10)); 1514 child->SetShowDelegatedContent(frame_provider.get(), gfx::Size(10, 10));
1515 EXPECT_TRUE(child->cc_layer()); 1515 EXPECT_TRUE(child->cc_layer());
1516 EXPECT_NE(before.get(), child->cc_layer()); 1516 EXPECT_NE(before.get(), child->cc_layer());
1517 1517
1518 // Changing to painted content should change the underlying cc layer. 1518 // Changing to painted content should change the underlying cc layer.
1519 before = child->cc_layer(); 1519 before = child->cc_layer();
1520 child->SetShowPaintedContent(); 1520 child->SetShowSolidColorContent();
1521 EXPECT_TRUE(child->cc_layer()); 1521 EXPECT_TRUE(child->cc_layer());
1522 EXPECT_NE(before.get(), child->cc_layer()); 1522 EXPECT_NE(before.get(), child->cc_layer());
1523 } 1523 }
1524 1524
1525 // Verifies that layer filters still attached after changing implementation 1525 // Verifies that layer filters still attached after changing implementation
1526 // layer. 1526 // layer.
1527 TEST_F(LayerWithDelegateTest, LayerFiltersSurvival) { 1527 TEST_F(LayerWithDelegateTest, LayerFiltersSurvival) {
1528 scoped_ptr<Layer> layer(CreateLayer(LAYER_TEXTURED)); 1528 scoped_ptr<Layer> layer(CreateLayer(LAYER_TEXTURED));
1529 layer->SetBounds(gfx::Rect(0, 0, 10, 10)); 1529 layer->SetBounds(gfx::Rect(0, 0, 10, 10));
1530 EXPECT_TRUE(layer->cc_layer()); 1530 EXPECT_TRUE(layer->cc_layer());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 MakeFrameData(gfx::Size(10, 10)))); 1744 MakeFrameData(gfx::Size(10, 10))));
1745 layer->SetShowDelegatedContent(frame_provider.get(), gfx::Size(10, 10)); 1745 layer->SetShowDelegatedContent(frame_provider.get(), gfx::Size(10, 10));
1746 1746
1747 EXPECT_FALSE(delegate.delegated_frame_damage_called()); 1747 EXPECT_FALSE(delegate.delegated_frame_damage_called());
1748 layer->OnDelegatedFrameDamage(damage_rect); 1748 layer->OnDelegatedFrameDamage(damage_rect);
1749 EXPECT_TRUE(delegate.delegated_frame_damage_called()); 1749 EXPECT_TRUE(delegate.delegated_frame_damage_called());
1750 EXPECT_EQ(damage_rect, delegate.delegated_frame_damage_rect()); 1750 EXPECT_EQ(damage_rect, delegate.delegated_frame_damage_rect());
1751 } 1751 }
1752 1752
1753 } // namespace ui 1753 } // namespace ui
OLDNEW
« ash/display/mirror_window_controller.cc ('K') | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698