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

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

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