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

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 608503005: Revert of cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 1657
1658 gfx::Rect full_rect(0, 0, 10, 10); 1658 gfx::Rect full_rect(0, 0, 10, 10);
1659 ResourceUpdate upload = ResourceUpdate::Create( 1659 ResourceUpdate upload = ResourceUpdate::Create(
1660 texture_.get(), &bitmap_, full_rect, full_rect, gfx::Vector2d()); 1660 texture_.get(), &bitmap_, full_rect, full_rect, gfx::Vector2d());
1661 queue->AppendFullUpload(upload); 1661 queue->AppendFullUpload(upload);
1662 return true; 1662 return true;
1663 } 1663 }
1664 1664
1665 scoped_ptr<LayerImpl> EvictionTestLayer::CreateLayerImpl( 1665 scoped_ptr<LayerImpl> EvictionTestLayer::CreateLayerImpl(
1666 LayerTreeImpl* tree_impl) { 1666 LayerTreeImpl* tree_impl) {
1667 return EvictionTestLayerImpl::Create(tree_impl, layer_id_); 1667 return EvictionTestLayerImpl::Create(tree_impl, layer_id_)
1668 .PassAs<LayerImpl>();
1668 } 1669 }
1669 1670
1670 void EvictionTestLayer::PushPropertiesTo(LayerImpl* layer_impl) { 1671 void EvictionTestLayer::PushPropertiesTo(LayerImpl* layer_impl) {
1671 Layer::PushPropertiesTo(layer_impl); 1672 Layer::PushPropertiesTo(layer_impl);
1672 1673
1673 EvictionTestLayerImpl* test_layer_impl = 1674 EvictionTestLayerImpl* test_layer_impl =
1674 static_cast<EvictionTestLayerImpl*>(layer_impl); 1675 static_cast<EvictionTestLayerImpl*>(layer_impl);
1675 test_layer_impl->SetHasTexture(texture_->have_backing_texture()); 1676 test_layer_impl->SetHasTexture(texture_->have_backing_texture());
1676 } 1677 }
1677 1678
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); 1896 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits);
1896 1897
1897 class LayerTreeHostWithProxy : public LayerTreeHost { 1898 class LayerTreeHostWithProxy : public LayerTreeHost {
1898 public: 1899 public:
1899 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, 1900 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client,
1900 const LayerTreeSettings& settings, 1901 const LayerTreeSettings& settings,
1901 scoped_ptr<FakeProxy> proxy) 1902 scoped_ptr<FakeProxy> proxy)
1902 : LayerTreeHost(client, NULL, settings) { 1903 : LayerTreeHost(client, NULL, settings) {
1903 proxy->SetLayerTreeHost(this); 1904 proxy->SetLayerTreeHost(this);
1904 client->SetLayerTreeHost(this); 1905 client->SetLayerTreeHost(this);
1905 InitializeForTesting(proxy.Pass()); 1906 InitializeForTesting(proxy.PassAs<Proxy>());
1906 } 1907 }
1907 }; 1908 };
1908 1909
1909 TEST(LayerTreeHostTest, LimitPartialUpdates) { 1910 TEST(LayerTreeHostTest, LimitPartialUpdates) {
1910 // When partial updates are not allowed, max updates should be 0. 1911 // When partial updates are not allowed, max updates should be 0.
1911 { 1912 {
1912 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 1913 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
1913 1914
1914 scoped_ptr<FakeProxy> proxy(new FakeProxy); 1915 scoped_ptr<FakeProxy> proxy(new FakeProxy);
1915 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; 1916 proxy->GetRendererCapabilities().allow_partial_texture_updates = false;
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 }; 2469 };
2469 2470
2470 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest { 2471 class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest {
2471 protected: 2472 protected:
2472 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) 2473 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
2473 OVERRIDE { 2474 OVERRIDE {
2474 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned( 2475 scoped_ptr<MockIOSurfaceWebGraphicsContext3D> mock_context_owned(
2475 new MockIOSurfaceWebGraphicsContext3D); 2476 new MockIOSurfaceWebGraphicsContext3D);
2476 mock_context_ = mock_context_owned.get(); 2477 mock_context_ = mock_context_owned.get();
2477 2478
2478 if (delegating_renderer()) 2479 if (delegating_renderer()) {
2479 return FakeOutputSurface::CreateDelegating3d(mock_context_owned.Pass()); 2480 return FakeOutputSurface::CreateDelegating3d(
2480 else 2481 mock_context_owned.PassAs<TestWebGraphicsContext3D>());
2481 return FakeOutputSurface::Create3d(mock_context_owned.Pass()); 2482 } else {
2483 return FakeOutputSurface::Create3d(
2484 mock_context_owned.PassAs<TestWebGraphicsContext3D>());
2485 }
2482 } 2486 }
2483 2487
2484 virtual void SetupTree() OVERRIDE { 2488 virtual void SetupTree() OVERRIDE {
2485 LayerTreeHostTest::SetupTree(); 2489 LayerTreeHostTest::SetupTree();
2486 2490
2487 layer_tree_host()->root_layer()->SetIsDrawable(false); 2491 layer_tree_host()->root_layer()->SetIsDrawable(false);
2488 2492
2489 io_surface_id_ = 9; 2493 io_surface_id_ = 9;
2490 io_surface_size_ = gfx::Size(6, 7); 2494 io_surface_size_ = gfx::Size(6, 7);
2491 2495
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 if (layer_tree_host()->settings().impl_side_painting) 2861 if (layer_tree_host()->settings().impl_side_painting)
2858 PerformTest(impl); 2862 PerformTest(impl);
2859 } 2863 }
2860 2864
2861 virtual void AfterTest() OVERRIDE {} 2865 virtual void AfterTest() OVERRIDE {}
2862 2866
2863 private: 2867 private:
2864 // Must clear all resources before exiting. 2868 // Must clear all resources before exiting.
2865 void ClearResources() { 2869 void ClearResources() {
2866 for (int i = 0; i < num_ui_resources_; i++) 2870 for (int i = 0; i < num_ui_resources_; i++)
2867 ui_resources_[i] = nullptr; 2871 ui_resources_[i].reset();
2868 } 2872 }
2869 2873
2870 void CreateResource() { 2874 void CreateResource() {
2871 ui_resources_[num_ui_resources_++] = 2875 ui_resources_[num_ui_resources_++] =
2872 FakeScopedUIResource::Create(layer_tree_host()); 2876 FakeScopedUIResource::Create(layer_tree_host());
2873 } 2877 }
2874 2878
2875 scoped_ptr<FakeScopedUIResource> ui_resources_[5]; 2879 scoped_ptr<FakeScopedUIResource> ui_resources_[5];
2876 int num_ui_resources_; 2880 int num_ui_resources_;
2877 }; 2881 };
(...skipping 12 matching lines...) Expand all
2890 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE { 2894 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE {
2891 LayerImpl::PushPropertiesTo(layer); 2895 LayerImpl::PushPropertiesTo(layer);
2892 push_properties_count_++; 2896 push_properties_count_++;
2893 // Push state to the active tree because we can only access it from there. 2897 // Push state to the active tree because we can only access it from there.
2894 static_cast<PushPropertiesCountingLayerImpl*>( 2898 static_cast<PushPropertiesCountingLayerImpl*>(
2895 layer)->push_properties_count_ = push_properties_count_; 2899 layer)->push_properties_count_ = push_properties_count_;
2896 } 2900 }
2897 2901
2898 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 2902 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
2899 OVERRIDE { 2903 OVERRIDE {
2900 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); 2904 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()).
2905 PassAs<LayerImpl>();
2901 } 2906 }
2902 2907
2903 size_t push_properties_count() const { return push_properties_count_; } 2908 size_t push_properties_count() const { return push_properties_count_; }
2904 void reset_push_properties_count() { push_properties_count_ = 0; } 2909 void reset_push_properties_count() { push_properties_count_ = 0; }
2905 2910
2906 private: 2911 private:
2907 size_t push_properties_count_; 2912 size_t push_properties_count_;
2908 2913
2909 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id) 2914 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id)
2910 : LayerImpl(tree_impl, id), 2915 : LayerImpl(tree_impl, id),
(...skipping 10 matching lines...) Expand all
2921 2926
2922 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE { 2927 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE {
2923 Layer::PushPropertiesTo(layer); 2928 Layer::PushPropertiesTo(layer);
2924 push_properties_count_++; 2929 push_properties_count_++;
2925 if (persist_needs_push_properties_) 2930 if (persist_needs_push_properties_)
2926 needs_push_properties_ = true; 2931 needs_push_properties_ = true;
2927 } 2932 }
2928 2933
2929 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 2934 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
2930 OVERRIDE { 2935 OVERRIDE {
2931 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); 2936 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()).
2937 PassAs<LayerImpl>();
2932 } 2938 }
2933 2939
2934 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); } 2940 void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); }
2935 2941
2936 size_t push_properties_count() const { return push_properties_count_; } 2942 size_t push_properties_count() const { return push_properties_count_; }
2937 void reset_push_properties_count() { push_properties_count_ = 0; } 2943 void reset_push_properties_count() { push_properties_count_ = 0; }
2938 2944
2939 void set_persist_needs_push_properties(bool persist) { 2945 void set_persist_needs_push_properties(bool persist) {
2940 persist_needs_push_properties_ = persist; 2946 persist_needs_push_properties_ = persist;
2941 } 2947 }
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
4721 EXPECT_TRUE(host_impl->active_tree()->RequiresHighResToDraw()); 4727 EXPECT_TRUE(host_impl->active_tree()->RequiresHighResToDraw());
4722 } 4728 }
4723 4729
4724 virtual void DidCommit() OVERRIDE { 4730 virtual void DidCommit() OVERRIDE {
4725 int frame = layer_tree_host()->source_frame_number(); 4731 int frame = layer_tree_host()->source_frame_number();
4726 switch (frame) { 4732 switch (frame) {
4727 case 1: 4733 case 1:
4728 PostSetNeedsCommitToMainThread(); 4734 PostSetNeedsCommitToMainThread();
4729 break; 4735 break;
4730 case 2: 4736 case 2:
4731 ui_resource_ = nullptr; 4737 ui_resource_.reset();
4732 EndTest(); 4738 EndTest();
4733 break; 4739 break;
4734 } 4740 }
4735 } 4741 }
4736 4742
4737 virtual void AfterTest() OVERRIDE {} 4743 virtual void AfterTest() OVERRIDE {}
4738 4744
4739 FakeContentLayerClient client_; 4745 FakeContentLayerClient client_;
4740 scoped_ptr<FakeScopedUIResource> ui_resource_; 4746 scoped_ptr<FakeScopedUIResource> ui_resource_;
4741 }; 4747 };
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
5100 int activation_count_; 5106 int activation_count_;
5101 5107
5102 FakeContentLayerClient client_; 5108 FakeContentLayerClient client_;
5103 scoped_refptr<FakePictureLayer> picture_layer_; 5109 scoped_refptr<FakePictureLayer> picture_layer_;
5104 }; 5110 };
5105 5111
5106 // TODO(vmpstr): Enable with single thread impl-side painting. 5112 // TODO(vmpstr): Enable with single thread impl-side painting.
5107 MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate); 5113 MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate);
5108 5114
5109 } // namespace cc 5115 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698