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

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

Issue 1985973002: Defer compositor context creation to the thread. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 6746 matching lines...) Expand 10 before | Expand all | Expand 10 after
6757 } 6757 }
6758 protected: 6758 protected:
6759 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) 6759 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id)
6760 : LayerImpl(tree_impl, id) {} 6760 : LayerImpl(tree_impl, id) {}
6761 }; 6761 };
6762 6762
6763 // Only reshape when we know we are going to draw. Otherwise, the reshape 6763 // Only reshape when we know we are going to draw. Otherwise, the reshape
6764 // can leave the window at the wrong size if we never draw and the proper 6764 // can leave the window at the wrong size if we never draw and the proper
6765 // viewport size is never set. 6765 // viewport size is never set.
6766 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { 6766 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) {
6767 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 6767 TestContextProvider* provider = nullptr;
6768 std::unique_ptr<TestContextProvider::DeferredCreate> provider_create(
6769 new TestContextProvider::DeferredCreate);
6770 provider_create->created_context = &provider;
piman 2016/05/17 03:41:41 here it looks like you could create the TestWGC3D,
6768 std::unique_ptr<OutputSurface> output_surface( 6771 std::unique_ptr<OutputSurface> output_surface(
6769 FakeOutputSurface::Create3d(provider)); 6772 FakeOutputSurface::Create3d(std::move(provider_create)));
6770 CreateHostImpl(DefaultSettings(), std::move(output_surface)); 6773 CreateHostImpl(DefaultSettings(), std::move(output_surface));
6771 6774
6772 std::unique_ptr<LayerImpl> root = 6775 std::unique_ptr<LayerImpl> root =
6773 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 6776 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
6774 root->SetBounds(gfx::Size(10, 10)); 6777 root->SetBounds(gfx::Size(10, 10));
6775 root->SetDrawsContent(true); 6778 root->SetDrawsContent(true);
6776 root->test_properties()->force_render_surface = true; 6779 root->test_properties()->force_render_surface = true;
6777 host_impl_->active_tree()->SetRootLayer(std::move(root)); 6780 host_impl_->active_tree()->SetRootLayer(std::move(root));
6778 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); 6781 EXPECT_FALSE(provider->TestContext3d()->reshape_called());
6779 provider->TestContext3d()->clear_reshape_called(); 6782 provider->TestContext3d()->clear_reshape_called();
(...skipping 27 matching lines...) Expand all
6807 EXPECT_EQ(provider->TestContext3d()->width(), 20); 6810 EXPECT_EQ(provider->TestContext3d()->width(), 20);
6808 EXPECT_EQ(provider->TestContext3d()->height(), 30); 6811 EXPECT_EQ(provider->TestContext3d()->height(), 30);
6809 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); 6812 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f);
6810 host_impl_->DidDrawAllLayers(frame); 6813 host_impl_->DidDrawAllLayers(frame);
6811 provider->TestContext3d()->clear_reshape_called(); 6814 provider->TestContext3d()->clear_reshape_called();
6812 } 6815 }
6813 6816
6814 // Make sure damage tracking propagates all the way to the graphics context, 6817 // Make sure damage tracking propagates all the way to the graphics context,
6815 // where it should request to swap only the sub-buffer that is damaged. 6818 // where it should request to swap only the sub-buffer that is damaged.
6816 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { 6819 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
6817 scoped_refptr<TestContextProvider> context_provider( 6820 std::unique_ptr<TestContextProvider::DeferredCreate> provider_create(
6818 TestContextProvider::Create()); 6821 new TestContextProvider::DeferredCreate);
6819 context_provider->BindToCurrentThread(); 6822 provider_create->capabilities.post_sub_buffer = true;
6820 context_provider->TestContext3d()->set_have_post_sub_buffer(true);
6821
6822 std::unique_ptr<FakeOutputSurface> output_surface( 6823 std::unique_ptr<FakeOutputSurface> output_surface(
6823 FakeOutputSurface::Create3d(context_provider)); 6824 FakeOutputSurface::Create3d(std::move(provider_create)));
6824 FakeOutputSurface* fake_output_surface = output_surface.get(); 6825 FakeOutputSurface* fake_output_surface = output_surface.get();
6825 6826
6826 // This test creates its own LayerTreeHostImpl, so 6827 // This test creates its own LayerTreeHostImpl, so
6827 // that we can force partial swap enabled. 6828 // that we can force partial swap enabled.
6828 LayerTreeSettings settings = DefaultSettings(); 6829 LayerTreeSettings settings = DefaultSettings();
6829 settings.renderer_settings.partial_swap_enabled = true; 6830 settings.renderer_settings.partial_swap_enabled = true;
6830 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = 6831 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl =
6831 LayerTreeHostImpl::Create( 6832 LayerTreeHostImpl::Create(
6832 settings, this, &task_runner_provider_, &stats_instrumentation_, 6833 settings, this, &task_runner_provider_, &stats_instrumentation_,
6833 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0); 6834 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
6972 GLsizei height)); 6973 GLsizei height));
6973 }; 6974 };
6974 6975
6975 class MockContextHarness { 6976 class MockContextHarness {
6976 private: 6977 private:
6977 MockContext* context_; 6978 MockContext* context_;
6978 6979
6979 public: 6980 public:
6980 explicit MockContextHarness(MockContext* context) 6981 explicit MockContextHarness(MockContext* context)
6981 : context_(context) { 6982 : context_(context) {
6982 context_->set_have_post_sub_buffer(true);
6983
6984 // Catch "uninteresting" calls 6983 // Catch "uninteresting" calls
6985 EXPECT_CALL(*context_, useProgram(_)) 6984 EXPECT_CALL(*context_, useProgram(_))
6986 .Times(0); 6985 .Times(0);
6987 6986
6988 EXPECT_CALL(*context_, drawElements(_, _, _, _)) 6987 EXPECT_CALL(*context_, drawElements(_, _, _, _))
6989 .Times(0); 6988 .Times(0);
6990 6989
6991 // These are not asserted 6990 // These are not asserted
6992 EXPECT_CALL(*context_, uniformMatrix4fv(_, _, _, _)) 6991 EXPECT_CALL(*context_, uniformMatrix4fv(_, _, _, _))
6993 .WillRepeatedly(Return()); 6992 .WillRepeatedly(Return());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
7033 EXPECT_CALL(*context_, scissor(_, _, _, _)) 7032 EXPECT_CALL(*context_, scissor(_, _, _, _))
7034 .Times(0); 7033 .Times(0);
7035 } 7034 }
7036 }; 7035 };
7037 7036
7038 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { 7037 TEST_F(LayerTreeHostImplTest, NoPartialSwap) {
7039 std::unique_ptr<MockContext> mock_context_owned(new MockContext); 7038 std::unique_ptr<MockContext> mock_context_owned(new MockContext);
7040 MockContext* mock_context = mock_context_owned.get(); 7039 MockContext* mock_context = mock_context_owned.get();
7041 MockContextHarness harness(mock_context); 7040 MockContextHarness harness(mock_context);
7042 7041
7042 std::unique_ptr<TestContextProvider::DeferredCreate> compositor_create(
7043 new TestContextProvider::DeferredCreate);
7044 mock_context->set_have_post_sub_buffer(true);
7045 compositor_create->webcontext = std::move(mock_context_owned);
7046
7043 // Run test case 7047 // Run test case
7044 LayerTreeSettings settings = DefaultSettings(); 7048 LayerTreeSettings settings = DefaultSettings();
7045 settings.renderer_settings.partial_swap_enabled = false; 7049 settings.renderer_settings.partial_swap_enabled = false;
7046 CreateHostImpl(settings, 7050 CreateHostImpl(settings,
7047 FakeOutputSurface::Create3d(std::move(mock_context_owned))); 7051 FakeOutputSurface::Create3d(std::move(compositor_create)));
7048 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 7052 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
7049 7053
7050 // Without partial swap, and no clipping, no scissor is set. 7054 // Without partial swap, and no clipping, no scissor is set.
7051 harness.MustDrawSolidQuad(); 7055 harness.MustDrawSolidQuad();
7052 harness.MustSetNoScissor(); 7056 harness.MustSetNoScissor();
7053 { 7057 {
7054 LayerTreeHostImpl::FrameData frame; 7058 LayerTreeHostImpl::FrameData frame;
7055 SetNeedsRebuildPropertyTrees(); 7059 SetNeedsRebuildPropertyTrees();
7056 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7060 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7057 host_impl_->DrawLayers(&frame); 7061 host_impl_->DrawLayers(&frame);
(...skipping 11 matching lines...) Expand all
7069 LayerTreeHostImpl::FrameData frame; 7073 LayerTreeHostImpl::FrameData frame;
7070 SetNeedsRebuildPropertyTrees(); 7074 SetNeedsRebuildPropertyTrees();
7071 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7075 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7072 host_impl_->DrawLayers(&frame); 7076 host_impl_->DrawLayers(&frame);
7073 host_impl_->DidDrawAllLayers(frame); 7077 host_impl_->DidDrawAllLayers(frame);
7074 } 7078 }
7075 Mock::VerifyAndClearExpectations(&mock_context); 7079 Mock::VerifyAndClearExpectations(&mock_context);
7076 } 7080 }
7077 7081
7078 TEST_F(LayerTreeHostImplTest, PartialSwap) { 7082 TEST_F(LayerTreeHostImplTest, PartialSwap) {
7079 std::unique_ptr<MockContext> context_owned(new MockContext); 7083 std::unique_ptr<MockContext> mock_context_owned(new MockContext);
7080 MockContext* mock_context = context_owned.get(); 7084 MockContext* mock_context = mock_context_owned.get();
7081 MockContextHarness harness(mock_context); 7085 MockContextHarness harness(mock_context);
7082 7086
7087 std::unique_ptr<TestContextProvider::DeferredCreate> compositor_create(
7088 new TestContextProvider::DeferredCreate);
7089 mock_context->set_have_post_sub_buffer(true);
7090 compositor_create->webcontext = std::move(mock_context_owned);
7091
7083 LayerTreeSettings settings = DefaultSettings(); 7092 LayerTreeSettings settings = DefaultSettings();
7084 settings.renderer_settings.partial_swap_enabled = true; 7093 settings.renderer_settings.partial_swap_enabled = true;
7085 CreateHostImpl(settings, 7094 CreateHostImpl(settings,
7086 FakeOutputSurface::Create3d(std::move(context_owned))); 7095 FakeOutputSurface::Create3d(std::move(compositor_create)));
7087 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 7096 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
7088 7097
7089 // The first frame is not a partially-swapped one. No scissor should be set. 7098 // The first frame is not a partially-swapped one. No scissor should be set.
7090 harness.MustSetNoScissor(); 7099 harness.MustSetNoScissor();
7091 harness.MustDrawSolidQuad(); 7100 harness.MustDrawSolidQuad();
7092 { 7101 {
7093 LayerTreeHostImpl::FrameData frame; 7102 LayerTreeHostImpl::FrameData frame;
7094 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7103 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7095 host_impl_->DrawLayers(&frame); 7104 host_impl_->DrawLayers(&frame);
7096 host_impl_->DidDrawAllLayers(frame); 7105 host_impl_->DidDrawAllLayers(frame);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
7183 root->AddChild(std::move(child)); 7192 root->AddChild(std::move(child));
7184 7193
7185 my_host_impl->active_tree()->SetRootLayer(std::move(root)); 7194 my_host_impl->active_tree()->SetRootLayer(std::move(root));
7186 my_host_impl->active_tree()->BuildPropertyTreesForTesting(); 7195 my_host_impl->active_tree()->BuildPropertyTreesForTesting();
7187 return my_host_impl; 7196 return my_host_impl;
7188 } 7197 }
7189 7198
7190 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { 7199 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) {
7191 TestSharedBitmapManager shared_bitmap_manager; 7200 TestSharedBitmapManager shared_bitmap_manager;
7192 TestTaskGraphRunner task_graph_runner; 7201 TestTaskGraphRunner task_graph_runner;
7193 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 7202 std::unique_ptr<TestContextProvider::DeferredCreate> provider_create(
7194 provider->BindToCurrentThread(); 7203 new TestContextProvider::DeferredCreate);
7195 provider->TestContext3d()->set_have_post_sub_buffer(true); 7204 provider_create->capabilities.post_sub_buffer = true;
7196 std::unique_ptr<OutputSurface> output_surface( 7205 std::unique_ptr<OutputSurface> output_surface(
7197 FakeOutputSurface::Create3d(provider)); 7206 FakeOutputSurface::Create3d(std::move(provider_create)));
7198 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( 7207 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
7199 DefaultSettings(), true, this, &task_runner_provider_, 7208 DefaultSettings(), true, this, &task_runner_provider_,
7200 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, 7209 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_,
7201 output_surface.get()); 7210 output_surface.get());
7202 { 7211 {
7203 LayerTreeHostImpl::FrameData frame; 7212 LayerTreeHostImpl::FrameData frame;
7204 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); 7213 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
7205 7214
7206 // Verify all quads have been computed 7215 // Verify all quads have been computed
7207 ASSERT_EQ(2U, frame.render_passes.size()); 7216 ASSERT_EQ(2U, frame.render_passes.size());
7208 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 7217 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
7209 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 7218 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
7210 EXPECT_EQ(DrawQuad::SOLID_COLOR, 7219 EXPECT_EQ(DrawQuad::SOLID_COLOR,
7211 frame.render_passes[0]->quad_list.front()->material); 7220 frame.render_passes[0]->quad_list.front()->material);
7212 EXPECT_EQ(DrawQuad::RENDER_PASS, 7221 EXPECT_EQ(DrawQuad::RENDER_PASS,
7213 frame.render_passes[1]->quad_list.front()->material); 7222 frame.render_passes[1]->quad_list.front()->material);
7214 7223
7215 my_host_impl->DrawLayers(&frame); 7224 my_host_impl->DrawLayers(&frame);
7216 my_host_impl->DidDrawAllLayers(frame); 7225 my_host_impl->DidDrawAllLayers(frame);
7217 } 7226 }
7218 } 7227 }
7219 7228
7220 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 7229 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
7221 TestSharedBitmapManager shared_bitmap_manager; 7230 TestSharedBitmapManager shared_bitmap_manager;
7222 TestTaskGraphRunner task_graph_runner; 7231 TestTaskGraphRunner task_graph_runner;
7223 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 7232 std::unique_ptr<TestContextProvider::DeferredCreate> provider_create(
7224 provider->BindToCurrentThread(); 7233 new TestContextProvider::DeferredCreate);
7225 provider->TestContext3d()->set_have_post_sub_buffer(true); 7234 provider_create->capabilities.post_sub_buffer = true;
7226 std::unique_ptr<OutputSurface> output_surface( 7235 std::unique_ptr<OutputSurface> output_surface(
7227 FakeOutputSurface::Create3d(provider)); 7236 FakeOutputSurface::Create3d(std::move(provider_create)));
7228 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( 7237 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
7229 DefaultSettings(), false, this, &task_runner_provider_, 7238 DefaultSettings(), false, this, &task_runner_provider_,
7230 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, 7239 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_,
7231 output_surface.get()); 7240 output_surface.get());
7232 { 7241 {
7233 LayerTreeHostImpl::FrameData frame; 7242 LayerTreeHostImpl::FrameData frame;
7234 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); 7243 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
7235 7244
7236 // Verify all quads have been computed 7245 // Verify all quads have been computed
7237 ASSERT_EQ(2U, frame.render_passes.size()); 7246 ASSERT_EQ(2U, frame.render_passes.size());
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
7765 host_impl_->CreateUIResource(ui_resource_id, bitmap); 7774 host_impl_->CreateUIResource(ui_resource_id, bitmap);
7766 EXPECT_EQ(1u, context3d->NumTextures()); 7775 EXPECT_EQ(1u, context3d->NumTextures());
7767 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); 7776 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id);
7768 EXPECT_NE(0u, id1); 7777 EXPECT_NE(0u, id1);
7769 } 7778 }
7770 7779
7771 void ShutdownReleasesContext_Callback( 7780 void ShutdownReleasesContext_Callback(
7772 std::unique_ptr<CopyOutputResult> result) {} 7781 std::unique_ptr<CopyOutputResult> result) {}
7773 7782
7774 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { 7783 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
7775 scoped_refptr<TestContextProvider> context_provider = 7784 TestContextProvider* context_provider = nullptr;
7776 TestContextProvider::Create(); 7785 auto context_create = base::MakeUnique<TestContextProvider::DeferredCreate>();
7777 7786 context_create->created_context = &context_provider;
7778 CreateHostImpl(DefaultSettings(), 7787 CreateHostImpl(DefaultSettings(),
7779 FakeOutputSurface::Create3d(context_provider)); 7788 FakeOutputSurface::Create3d(std::move(context_create)));
7780 7789
7781 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 7790 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
7782 7791
7783 std::vector<std::unique_ptr<CopyOutputRequest>> requests; 7792 std::vector<std::unique_ptr<CopyOutputRequest>> requests;
7784 requests.push_back(CopyOutputRequest::CreateRequest( 7793 requests.push_back(CopyOutputRequest::CreateRequest(
7785 base::Bind(&ShutdownReleasesContext_Callback))); 7794 base::Bind(&ShutdownReleasesContext_Callback)));
7786 7795
7787 LayerImpl* root = host_impl_->active_tree()->root_layer(); 7796 LayerImpl* root = host_impl_->active_tree()->root_layer();
7788 root->PassCopyRequests(&requests); 7797 root->PassCopyRequests(&requests);
7789 7798
7790 LayerTreeHostImpl::FrameData frame; 7799 LayerTreeHostImpl::FrameData frame;
7791 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7800 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7792 host_impl_->DrawLayers(&frame); 7801 host_impl_->DrawLayers(&frame);
7793 host_impl_->DidDrawAllLayers(frame); 7802 host_impl_->DidDrawAllLayers(frame);
7794 7803
7804 scoped_refptr<TestContextProvider> saved_context_provider(context_provider);
7805
7795 // The CopyOutputResult's callback has a ref on the ContextProvider and a 7806 // The CopyOutputResult's callback has a ref on the ContextProvider and a
7796 // texture in a texture mailbox. 7807 // texture in a texture mailbox.
7797 EXPECT_FALSE(context_provider->HasOneRef()); 7808 EXPECT_FALSE(saved_context_provider->HasOneRef());
7798 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 7809 EXPECT_EQ(1u, saved_context_provider->TestContext3d()->NumTextures());
7799 7810
7800 host_impl_ = nullptr; 7811 host_impl_ = nullptr;
7801 7812
7802 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 7813 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
7803 // released, and the texture deleted. 7814 // released, and the texture deleted.
7804 EXPECT_TRUE(context_provider->HasOneRef()); 7815 EXPECT_TRUE(saved_context_provider->HasOneRef());
7805 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); 7816 EXPECT_EQ(0u, saved_context_provider->TestContext3d()->NumTextures());
7806 } 7817 }
7807 7818
7808 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { 7819 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
7809 // When flinging via touch, only the child should scroll (we should not 7820 // When flinging via touch, only the child should scroll (we should not
7810 // bubble). 7821 // bubble).
7811 gfx::Size surface_size(10, 10); 7822 gfx::Size surface_size(10, 10);
7812 gfx::Size content_size(20, 20); 7823 gfx::Size content_size(20, 20);
7813 std::unique_ptr<LayerImpl> root_ptr = 7824 std::unique_ptr<LayerImpl> root_ptr =
7814 LayerImpl::Create(host_impl_->active_tree(), 4); 7825 LayerImpl::Create(host_impl_->active_tree(), 4);
7815 std::unique_ptr<LayerImpl> root_clip = 7826 std::unique_ptr<LayerImpl> root_clip =
(...skipping 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after
10477 host_impl_->gpu_rasterization_status()); 10488 host_impl_->gpu_rasterization_status());
10478 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10489 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10479 10490
10480 host_impl_->SetHasGpuRasterizationTrigger(true); 10491 host_impl_->SetHasGpuRasterizationTrigger(true);
10481 host_impl_->SetContentIsSuitableForGpuRasterization(false); 10492 host_impl_->SetContentIsSuitableForGpuRasterization(false);
10482 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 10493 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT,
10483 host_impl_->gpu_rasterization_status()); 10494 host_impl_->gpu_rasterization_status());
10484 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10495 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10485 EXPECT_FALSE(host_impl_->use_msaa()); 10496 EXPECT_FALSE(host_impl_->use_msaa());
10486 10497
10487 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = 10498 std::unique_ptr<TestContextProvider::DeferredCreate> context_with_msaa(
10488 TestWebGraphicsContext3D::Create(); 10499 new TestContextProvider::DeferredCreate);
10489 context_with_msaa->SetMaxSamples(8); 10500 context_with_msaa->capabilities.max_samples = 8;
10490 10501
10491 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); 10502 LayerTreeSettings msaa_settings = GpuRasterizationEnabledSettings();
10492 msaaSettings.gpu_rasterization_msaa_sample_count = 4; 10503 msaa_settings.gpu_rasterization_msaa_sample_count = 4;
10493 EXPECT_TRUE(CreateHostImpl( 10504 EXPECT_TRUE(CreateHostImpl(msaa_settings, FakeOutputSurface::Create3d(
10494 msaaSettings, FakeOutputSurface::Create3d(std::move(context_with_msaa)))); 10505 std::move(context_with_msaa))));
10495 host_impl_->SetHasGpuRasterizationTrigger(true); 10506 host_impl_->SetHasGpuRasterizationTrigger(true);
10496 host_impl_->SetContentIsSuitableForGpuRasterization(false); 10507 host_impl_->SetContentIsSuitableForGpuRasterization(false);
10497 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, 10508 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
10498 host_impl_->gpu_rasterization_status()); 10509 host_impl_->gpu_rasterization_status());
10499 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 10510 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
10500 EXPECT_TRUE(host_impl_->use_msaa()); 10511 EXPECT_TRUE(host_impl_->use_msaa());
10501 10512
10502 LayerTreeSettings settings = DefaultSettings(); 10513 LayerTreeSettings settings = DefaultSettings();
10503 settings.gpu_rasterization_enabled = false; 10514 settings.gpu_rasterization_enabled = false;
10504 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); 10515 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d()));
(...skipping 12 matching lines...) Expand all
10517 host_impl_->gpu_rasterization_status()); 10528 host_impl_->gpu_rasterization_status());
10518 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 10529 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
10519 } 10530 }
10520 10531
10521 class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest { 10532 class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest {
10522 public: 10533 public:
10523 void CreateHostImplWithMsaaIsSlow(bool msaa_is_slow) { 10534 void CreateHostImplWithMsaaIsSlow(bool msaa_is_slow) {
10524 LayerTreeSettings settings = DefaultSettings(); 10535 LayerTreeSettings settings = DefaultSettings();
10525 settings.gpu_rasterization_enabled = true; 10536 settings.gpu_rasterization_enabled = true;
10526 settings.gpu_rasterization_msaa_sample_count = 4; 10537 settings.gpu_rasterization_msaa_sample_count = 4;
10527 auto context_provider = TestContextProvider::Create(); 10538 auto context_provider_create =
10528 context_provider->UnboundTestContext3d()->SetMaxSamples(4); 10539 base::MakeUnique<TestContextProvider::DeferredCreate>();
10529 context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow); 10540 context_provider_create->capabilities.max_samples = 4;
10541 context_provider_create->capabilities.msaa_is_slow = msaa_is_slow;
10530 auto msaa_is_normal_output_surface = 10542 auto msaa_is_normal_output_surface =
10531 FakeOutputSurface::Create3d(context_provider); 10543 FakeOutputSurface::Create3d(std::move(context_provider_create));
10532 EXPECT_TRUE( 10544 EXPECT_TRUE(
10533 CreateHostImpl(settings, std::move(msaa_is_normal_output_surface))); 10545 CreateHostImpl(settings, std::move(msaa_is_normal_output_surface)));
10534 } 10546 }
10535 }; 10547 };
10536 10548
10537 TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) { 10549 TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) {
10538 // Ensure that without the msaa_is_slow cap we raster unsuitable content with 10550 // Ensure that without the msaa_is_slow cap we raster unsuitable content with
10539 // msaa. 10551 // msaa.
10540 CreateHostImplWithMsaaIsSlow(false); 10552 CreateHostImplWithMsaaIsSlow(false);
10541 host_impl_->SetHasGpuRasterizationTrigger(true); 10553 host_impl_->SetHasGpuRasterizationTrigger(true);
(...skipping 10 matching lines...) Expand all
10552 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 10564 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT,
10553 host_impl_->gpu_rasterization_status()); 10565 host_impl_->gpu_rasterization_status());
10554 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10566 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10555 } 10567 }
10556 10568
10557 // A mock output surface which lets us detect calls to ForceReclaimResources. 10569 // A mock output surface which lets us detect calls to ForceReclaimResources.
10558 class MockReclaimResourcesOutputSurface : public FakeOutputSurface { 10570 class MockReclaimResourcesOutputSurface : public FakeOutputSurface {
10559 public: 10571 public:
10560 static std::unique_ptr<MockReclaimResourcesOutputSurface> Create3d() { 10572 static std::unique_ptr<MockReclaimResourcesOutputSurface> Create3d() {
10561 return base::WrapUnique(new MockReclaimResourcesOutputSurface( 10573 return base::WrapUnique(new MockReclaimResourcesOutputSurface(
10562 TestContextProvider::Create(), TestContextProvider::CreateWorker(), 10574 base::MakeUnique<TestContextProvider::DeferredCreate>(),
10563 false)); 10575 TestContextProvider::Create(), false));
10564 } 10576 }
10565 10577
10566 MOCK_METHOD0(ForceReclaimResources, void()); 10578 MOCK_METHOD0(ForceReclaimResources, void());
10567 10579
10568 protected: 10580 protected:
10569 MockReclaimResourcesOutputSurface( 10581 MockReclaimResourcesOutputSurface(
10570 scoped_refptr<ContextProvider> context_provider, 10582 std::unique_ptr<ContextProvider::DeferredCreate> context_provider_create,
10571 scoped_refptr<ContextProvider> worker_context_provider, 10583 scoped_refptr<ContextProvider> worker_context_provider,
10572 bool delegated_rendering) 10584 bool delegated_rendering)
10573 : FakeOutputSurface(context_provider, 10585 : FakeOutputSurface(std::move(context_provider_create),
10574 worker_context_provider, 10586 std::move(worker_context_provider),
10575 delegated_rendering) {} 10587 delegated_rendering) {}
10576 }; 10588 };
10577 10589
10578 // Display::Draw (and the planned Display Scheduler) currently rely on resources 10590 // Display::Draw (and the planned Display Scheduler) currently rely on resources
10579 // being reclaimed to block drawing between BeginCommit / Swap. This test 10591 // being reclaimed to block drawing between BeginCommit / Swap. This test
10580 // ensures that BeginCommit triggers ForceReclaimResources. See 10592 // ensures that BeginCommit triggers ForceReclaimResources. See
10581 // crbug.com/489515. 10593 // crbug.com/489515.
10582 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { 10594 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) {
10583 std::unique_ptr<MockReclaimResourcesOutputSurface> output_surface( 10595 std::unique_ptr<MockReclaimResourcesOutputSurface> output_surface(
10584 MockReclaimResourcesOutputSurface::Create3d()); 10596 MockReclaimResourcesOutputSurface::Create3d());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
10747 10759
10748 // Re-initialize with a software output surface. 10760 // Re-initialize with a software output surface.
10749 output_surface_ = FakeOutputSurface::CreateSoftware( 10761 output_surface_ = FakeOutputSurface::CreateSoftware(
10750 base::WrapUnique(new SoftwareOutputDevice)); 10762 base::WrapUnique(new SoftwareOutputDevice));
10751 host_impl_->InitializeRenderer(output_surface_.get()); 10763 host_impl_->InitializeRenderer(output_surface_.get());
10752 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10764 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10753 } 10765 }
10754 10766
10755 } // namespace 10767 } // namespace
10756 } // namespace cc 10768 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698