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

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

Issue 787763006: cc: Adding BeginFrameTracker object and removing Now() from LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing gn bots. Created 6 years 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "cc/scheduler/delay_based_time_source.h" 64 #include "cc/scheduler/delay_based_time_source.h"
65 #include "cc/trees/damage_tracker.h" 65 #include "cc/trees/damage_tracker.h"
66 #include "cc/trees/layer_tree_host.h" 66 #include "cc/trees/layer_tree_host.h"
67 #include "cc/trees/layer_tree_host_common.h" 67 #include "cc/trees/layer_tree_host_common.h"
68 #include "cc/trees/layer_tree_impl.h" 68 #include "cc/trees/layer_tree_impl.h"
69 #include "cc/trees/occlusion_tracker.h" 69 #include "cc/trees/occlusion_tracker.h"
70 #include "cc/trees/single_thread_proxy.h" 70 #include "cc/trees/single_thread_proxy.h"
71 #include "cc/trees/tree_synchronizer.h" 71 #include "cc/trees/tree_synchronizer.h"
72 #include "gpu/command_buffer/client/gles2_interface.h" 72 #include "gpu/command_buffer/client/gles2_interface.h"
73 #include "gpu/GLES2/gl2extchromium.h" 73 #include "gpu/GLES2/gl2extchromium.h"
74 #include "ui/gfx/frame_time.h"
75 #include "ui/gfx/geometry/rect_conversions.h" 74 #include "ui/gfx/geometry/rect_conversions.h"
76 #include "ui/gfx/geometry/size_conversions.h" 75 #include "ui/gfx/geometry/size_conversions.h"
77 #include "ui/gfx/geometry/vector2d_conversions.h" 76 #include "ui/gfx/geometry/vector2d_conversions.h"
78 77
79 namespace cc { 78 namespace cc {
80 namespace { 79 namespace {
81 80
82 // Small helper class that saves the current viewport location as the user sees 81 // Small helper class that saves the current viewport location as the user sees
83 // it and resets to the same location. 82 // it and resets to the same location.
84 class ViewportAnchor { 83 class ViewportAnchor {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 memory_history_(MemoryHistory::Create()), 212 memory_history_(MemoryHistory::Create()),
214 debug_rect_history_(DebugRectHistory::Create()), 213 debug_rect_history_(DebugRectHistory::Create()),
215 texture_mailbox_deleter_(new TextureMailboxDeleter( 214 texture_mailbox_deleter_(new TextureMailboxDeleter(
216 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() 215 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
217 : proxy_->MainThreadTaskRunner())), 216 : proxy_->MainThreadTaskRunner())),
218 max_memory_needed_bytes_(0), 217 max_memory_needed_bytes_(0),
219 zero_budget_(false), 218 zero_budget_(false),
220 device_scale_factor_(1.f), 219 device_scale_factor_(1.f),
221 overhang_ui_resource_id_(0), 220 overhang_ui_resource_id_(0),
222 resourceless_software_draw_(false), 221 resourceless_software_draw_(false),
223 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()),
224 animation_registrar_(AnimationRegistrar::Create()), 222 animation_registrar_(AnimationRegistrar::Create()),
225 rendering_stats_instrumentation_(rendering_stats_instrumentation), 223 rendering_stats_instrumentation_(rendering_stats_instrumentation),
226 micro_benchmark_controller_(this), 224 micro_benchmark_controller_(this),
227 shared_bitmap_manager_(shared_bitmap_manager), 225 shared_bitmap_manager_(shared_bitmap_manager),
228 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 226 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
229 id_(id), 227 id_(id),
230 requires_high_res_to_draw_(false), 228 requires_high_res_to_draw_(false),
231 required_for_draw_tile_is_top_of_raster_queue_(false) { 229 required_for_draw_tile_is_top_of_raster_queue_(false) {
232 DCHECK(proxy_->IsImplThread()); 230 DCHECK(proxy_->IsImplThread());
233 DidVisibilityChange(this, visible_); 231 DidVisibilityChange(this, visible_);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (EvictedUIResourcesExist()) { 365 if (EvictedUIResourcesExist()) {
368 TRACE_EVENT_INSTANT0( 366 TRACE_EVENT_INSTANT0(
369 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", 367 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated",
370 TRACE_EVENT_SCOPE_THREAD); 368 TRACE_EVENT_SCOPE_THREAD);
371 return false; 369 return false;
372 } 370 }
373 return true; 371 return true;
374 } 372 }
375 373
376 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { 374 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
375 // DCHECK(!current_begin_frame_args_.HasFinished());
376 // DCHECK(monotonic_time == current_begin_frame_args_.Get().frame_time)
377 // << "Called animate with unknown frame time!?";
377 if (input_handler_client_) 378 if (input_handler_client_)
378 input_handler_client_->Animate(monotonic_time); 379 input_handler_client_->Animate(monotonic_time);
379 AnimatePageScale(monotonic_time); 380 AnimatePageScale(monotonic_time);
380 AnimateLayers(monotonic_time); 381 AnimateLayers(monotonic_time);
381 AnimateScrollbars(monotonic_time); 382 AnimateScrollbars(monotonic_time);
382 AnimateTopControls(monotonic_time); 383 AnimateTopControls(monotonic_time);
383 } 384 }
384 385
385 void LayerTreeHostImpl::PrepareTiles() { 386 void LayerTreeHostImpl::PrepareTiles() {
386 if (!tile_manager_) 387 if (!tile_manager_)
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 "input", 1626 "input",
1626 "LatencyInfo.Flow", 1627 "LatencyInfo.Flow",
1627 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), 1628 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id),
1628 "SwapBuffers"); 1629 "SwapBuffers");
1629 } 1630 }
1630 renderer_->SwapBuffers(metadata); 1631 renderer_->SwapBuffers(metadata);
1631 return true; 1632 return true;
1632 } 1633 }
1633 1634
1634 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { 1635 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
1635 // Sample the frame time now. This time will be used for updating animations 1636 current_begin_frame_args_.Start(args);
1636 // when we draw.
1637 UpdateCurrentBeginFrameArgs(args);
1638 // Cache the begin impl frame interval
1639 begin_impl_frame_interval_ = args.interval;
1640 1637
1641 if (required_for_draw_tile_is_top_of_raster_queue_) { 1638 if (required_for_draw_tile_is_top_of_raster_queue_) {
1642 // Optimistically schedule a draw, as a tile required for draw is at the top 1639 // Optimistically schedule a draw, as a tile required for draw is at the top
1643 // of the current raster queue. This will let us expect the tile to complete 1640 // of the current raster queue. This will let us expect the tile to complete
1644 // and draw it within the impl frame we are beginning now. 1641 // and draw it within the impl frame we are beginning now.
1645 SetNeedsRedraw(); 1642 SetNeedsRedraw();
1646 } 1643 }
1647 } 1644 }
1648 1645
1649 void LayerTreeHostImpl::UpdateViewportContainerSizes() { 1646 void LayerTreeHostImpl::UpdateViewportContainerSizes() {
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 ScrollOffsetAnimationCurve* curve = 2399 ScrollOffsetAnimationCurve* curve =
2403 animation->curve()->ToScrollOffsetAnimationCurve(); 2400 animation->curve()->ToScrollOffsetAnimationCurve();
2404 2401
2405 gfx::ScrollOffset new_target = 2402 gfx::ScrollOffset new_target =
2406 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta); 2403 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta);
2407 new_target.SetToMax(gfx::ScrollOffset()); 2404 new_target.SetToMax(gfx::ScrollOffset());
2408 new_target.SetToMin(layer_impl->MaxScrollOffset()); 2405 new_target.SetToMin(layer_impl->MaxScrollOffset());
2409 2406
2410 curve->UpdateTarget( 2407 curve->UpdateTarget(
2411 animation->TrimTimeToCurrentIteration( 2408 animation->TrimTimeToCurrentIteration(
2412 CurrentBeginFrameArgs().frame_time).InSecondsF(), 2409 current_begin_frame_args_.Get().frame_time).InSecondsF(),
2413 new_target); 2410 new_target);
2414 2411
2415 return ScrollStarted; 2412 return ScrollStarted;
2416 } 2413 }
2417 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling 2414 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling
2418 // behavior as ScrollBy to determine which layer to animate, but we do not 2415 // behavior as ScrollBy to determine which layer to animate, but we do not
2419 // do the Android-specific things in ScrollBy like showing top controls. 2416 // do the Android-specific things in ScrollBy like showing top controls.
2420 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel); 2417 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel);
2421 if (scroll_status == ScrollStarted) { 2418 if (scroll_status == ScrollStarted) {
2422 gfx::Vector2dF pending_delta = scroll_delta; 2419 gfx::Vector2dF pending_delta = scroll_delta;
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 global_tile_state_.tree_priority = priority; 3214 global_tile_state_.tree_priority = priority;
3218 DidModifyTilePriorities(); 3215 DidModifyTilePriorities();
3219 } 3216 }
3220 3217
3221 TreePriority LayerTreeHostImpl::GetTreePriority() const { 3218 TreePriority LayerTreeHostImpl::GetTreePriority() const {
3222 return global_tile_state_.tree_priority; 3219 return global_tile_state_.tree_priority;
3223 } 3220 }
3224 3221
3225 void LayerTreeHostImpl::UpdateCurrentBeginFrameArgs( 3222 void LayerTreeHostImpl::UpdateCurrentBeginFrameArgs(
3226 const BeginFrameArgs& args) { 3223 const BeginFrameArgs& args) {
3227 DCHECK(!current_begin_frame_args_.IsValid()); 3224 current_begin_frame_args_.Start(args);
3228 current_begin_frame_args_ = args;
3229 // TODO(skyostil): Stop overriding the frame time once the usage of frame
3230 // timing is unified.
3231 current_begin_frame_args_.frame_time = gfx::FrameTime::Now();
3232 } 3225 }
3233 3226
3234 void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() { 3227 void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() {
3235 current_begin_frame_args_ = BeginFrameArgs(); 3228 current_begin_frame_args_.Finish();
brianderson 2014/12/18 02:01:38 I forget why we need to reset the current args. Ca
mithro-old 2014/12/18 17:22:41 See my reasoning else were. I think the fact that
3236 } 3229 }
3237 3230
3238 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { 3231 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const {
3239 // Try to use the current frame time to keep animations non-jittery. But if 3232 // TODO(mithro): Remove this section once all calls to CurrentBeginFrameArgs
3240 // we're not in a frame (because this is during an input event or a delayed 3233 // which happens outside frame rendering are fixed.
3241 // task), fall back to physical time. This should still be monotonic. 3234 if (current_begin_frame_args_.HasFinished()) {
3242 if (current_begin_frame_args_.IsValid()) 3235 return current_begin_frame_args_.Last();
3243 return current_begin_frame_args_; 3236 }
3244 return BeginFrameArgs::Create( 3237 return current_begin_frame_args_.Get();
3245 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), 3238 }
3246 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); 3239
3240 base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const {
3241 return current_begin_frame_args_.Interval();
3247 } 3242 }
3248 3243
3249 scoped_refptr<base::debug::ConvertableToTraceFormat> 3244 scoped_refptr<base::debug::ConvertableToTraceFormat>
3250 LayerTreeHostImpl::AsValue() const { 3245 LayerTreeHostImpl::AsValue() const {
3251 return AsValueWithFrame(NULL); 3246 return AsValueWithFrame(NULL);
3252 } 3247 }
3253 3248
3254 scoped_refptr<base::debug::ConvertableToTraceFormat> 3249 scoped_refptr<base::debug::ConvertableToTraceFormat>
3255 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { 3250 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const {
3256 scoped_refptr<base::debug::TracedValue> state = 3251 scoped_refptr<base::debug::TracedValue> state =
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3481 } 3476 }
3482 3477
3483 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3478 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3484 std::vector<PictureLayerImpl*>::iterator it = 3479 std::vector<PictureLayerImpl*>::iterator it =
3485 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3480 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3486 DCHECK(it != picture_layers_.end()); 3481 DCHECK(it != picture_layers_.end());
3487 picture_layers_.erase(it); 3482 picture_layers_.erase(it);
3488 } 3483 }
3489 3484
3490 } // namespace cc 3485 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698