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

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

Issue 1127313003: Revert of cc: Adding BeginFrameTracker object and removing Now() from LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 virtual bool CreateHostImpl(const LayerTreeSettings& settings, 175 virtual bool CreateHostImpl(const LayerTreeSettings& settings,
176 scoped_ptr<OutputSurface> output_surface) { 176 scoped_ptr<OutputSurface> output_surface) {
177 host_impl_ = LayerTreeHostImpl::Create( 177 host_impl_ = LayerTreeHostImpl::Create(
178 settings, this, &proxy_, &stats_instrumentation_, 178 settings, this, &proxy_, &stats_instrumentation_,
179 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), 179 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(),
180 task_graph_runner_.get(), 0); 180 task_graph_runner_.get(), 0);
181 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); 181 bool init = host_impl_->InitializeRenderer(output_surface.Pass());
182 host_impl_->SetViewportSize(gfx::Size(10, 10)); 182 host_impl_->SetViewportSize(gfx::Size(10, 10));
183 // Set the BeginFrameArgs so that methods which use it are able to.
184 host_impl_->WillBeginImplFrame(
185 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
186 return init; 183 return init;
187 } 184 }
188 185
189 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { 186 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
190 root->SetPosition(gfx::PointF()); 187 root->SetPosition(gfx::PointF());
191 root->SetBounds(gfx::Size(10, 10)); 188 root->SetBounds(gfx::Size(10, 10));
192 root->SetContentBounds(gfx::Size(10, 10)); 189 root->SetContentBounds(gfx::Size(10, 10));
193 root->SetDrawsContent(true); 190 root->SetDrawsContent(true);
194 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 191 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
195 root->SetHasRenderSurface(true); 192 root->SetHasRenderSurface(true);
(...skipping 4850 matching lines...) Expand 10 before | Expand all | Expand 10 after
5046 5043
5047 // This test creates its own LayerTreeHostImpl, so 5044 // This test creates its own LayerTreeHostImpl, so
5048 // that we can force partial swap enabled. 5045 // that we can force partial swap enabled.
5049 LayerTreeSettings settings; 5046 LayerTreeSettings settings;
5050 settings.renderer_settings.partial_swap_enabled = true; 5047 settings.renderer_settings.partial_swap_enabled = true;
5051 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = 5048 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl =
5052 LayerTreeHostImpl::Create( 5049 LayerTreeHostImpl::Create(
5053 settings, this, &proxy_, &stats_instrumentation_, 5050 settings, this, &proxy_, &stats_instrumentation_,
5054 shared_bitmap_manager_.get(), NULL, task_graph_runner_.get(), 0); 5051 shared_bitmap_manager_.get(), NULL, task_graph_runner_.get(), 0);
5055 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); 5052 layer_tree_host_impl->InitializeRenderer(output_surface.Pass());
5056 layer_tree_host_impl->WillBeginImplFrame(
5057 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
5058 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); 5053 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500));
5059 5054
5060 scoped_ptr<LayerImpl> root = 5055 scoped_ptr<LayerImpl> root =
5061 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); 5056 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1);
5062 root->SetHasRenderSurface(true); 5057 root->SetHasRenderSurface(true);
5063 scoped_ptr<LayerImpl> child = 5058 scoped_ptr<LayerImpl> child =
5064 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); 5059 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
5065 child->SetPosition(gfx::PointF(12.f, 13.f)); 5060 child->SetPosition(gfx::PointF(12.f, 13.f));
5066 child->SetBounds(gfx::Size(14, 15)); 5061 child->SetBounds(gfx::Size(14, 15));
5067 child->SetContentBounds(gfx::Size(14, 15)); 5062 child->SetContentBounds(gfx::Size(14, 15));
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
5336 scoped_ptr<OutputSurface> output_surface( 5331 scoped_ptr<OutputSurface> output_surface(
5337 FakeOutputSurface::Create3d(provider)); 5332 FakeOutputSurface::Create3d(provider));
5338 provider->BindToCurrentThread(); 5333 provider->BindToCurrentThread();
5339 provider->TestContext3d()->set_have_post_sub_buffer(true); 5334 provider->TestContext3d()->set_have_post_sub_buffer(true);
5340 5335
5341 LayerTreeSettings settings; 5336 LayerTreeSettings settings;
5342 settings.renderer_settings.partial_swap_enabled = partial_swap; 5337 settings.renderer_settings.partial_swap_enabled = partial_swap;
5343 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( 5338 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create(
5344 settings, client, proxy, stats_instrumentation, manager, NULL, NULL, 0); 5339 settings, client, proxy, stats_instrumentation, manager, NULL, NULL, 0);
5345 my_host_impl->InitializeRenderer(output_surface.Pass()); 5340 my_host_impl->InitializeRenderer(output_surface.Pass());
5346 my_host_impl->WillBeginImplFrame(
5347 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
5348 my_host_impl->SetViewportSize(gfx::Size(100, 100)); 5341 my_host_impl->SetViewportSize(gfx::Size(100, 100));
5349 5342
5350 /* 5343 /*
5351 Layers are created as follows: 5344 Layers are created as follows:
5352 5345
5353 +--------------------+ 5346 +--------------------+
5354 | 1 | 5347 | 1 |
5355 | +-----------+ | 5348 | +-----------+ |
5356 | | 2 | | 5349 | | 2 | |
5357 | | +-------------------+ 5350 | | +-------------------+
(...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after
7656 begin_frame_args_ = args; 7649 begin_frame_args_ = args;
7657 } 7650 }
7658 7651
7659 const BeginFrameArgs& begin_frame_args() { return begin_frame_args_; } 7652 const BeginFrameArgs& begin_frame_args() { return begin_frame_args_; }
7660 7653
7661 private: 7654 private:
7662 BeginFrameArgs begin_frame_args_; 7655 BeginFrameArgs begin_frame_args_;
7663 }; 7656 };
7664 7657
7665 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { 7658 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) {
7666 host_impl_->DidFinishImplFrame();
7667
7668 BeginFrameArgs begin_frame_args = 7659 BeginFrameArgs begin_frame_args =
7669 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 7660 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
7670 FakeVideoFrameController controller; 7661 FakeVideoFrameController controller;
7671 7662
7672 host_impl_->WillBeginImplFrame(begin_frame_args); 7663 host_impl_->WillBeginImplFrame(begin_frame_args);
7673 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 7664 EXPECT_FALSE(controller.begin_frame_args().IsValid());
7674 host_impl_->AddVideoFrameController(&controller); 7665 host_impl_->AddVideoFrameController(&controller);
7675 EXPECT_TRUE(controller.begin_frame_args().IsValid()); 7666 EXPECT_TRUE(controller.begin_frame_args().IsValid());
7676 host_impl_->DidFinishImplFrame(); 7667 host_impl_->DidFinishImplFrame();
7677 } 7668 }
7678 7669
7679 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { 7670 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) {
7680 host_impl_->DidFinishImplFrame();
7681
7682 BeginFrameArgs begin_frame_args = 7671 BeginFrameArgs begin_frame_args =
7683 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 7672 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
7684 FakeVideoFrameController controller; 7673 FakeVideoFrameController controller;
7685 7674
7686 host_impl_->WillBeginImplFrame(begin_frame_args); 7675 host_impl_->WillBeginImplFrame(begin_frame_args);
7687 host_impl_->DidFinishImplFrame(); 7676 host_impl_->DidFinishImplFrame();
7688 7677
7689 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 7678 EXPECT_FALSE(controller.begin_frame_args().IsValid());
7690 host_impl_->AddVideoFrameController(&controller); 7679 host_impl_->AddVideoFrameController(&controller);
7691 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 7680 EXPECT_FALSE(controller.begin_frame_args().IsValid());
7692 7681
7693 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 7682 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
7694 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 7683 EXPECT_FALSE(controller.begin_frame_args().IsValid());
7695 host_impl_->WillBeginImplFrame(begin_frame_args); 7684 host_impl_->WillBeginImplFrame(begin_frame_args);
7696 EXPECT_TRUE(controller.begin_frame_args().IsValid()); 7685 EXPECT_TRUE(controller.begin_frame_args().IsValid());
7697 } 7686 }
7698 7687
7699 } // namespace 7688 } // namespace
7700 } // namespace cc 7689 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698