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

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 for Brian's comments. 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 LayerTreeHostImpl::LayerTreeHostImpl( 182 LayerTreeHostImpl::LayerTreeHostImpl(
184 const LayerTreeSettings& settings, 183 const LayerTreeSettings& settings,
185 LayerTreeHostImplClient* client, 184 LayerTreeHostImplClient* client,
186 Proxy* proxy, 185 Proxy* proxy,
187 RenderingStatsInstrumentation* rendering_stats_instrumentation, 186 RenderingStatsInstrumentation* rendering_stats_instrumentation,
188 SharedBitmapManager* shared_bitmap_manager, 187 SharedBitmapManager* shared_bitmap_manager,
189 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 188 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
190 int id) 189 int id)
191 : client_(client), 190 : client_(client),
192 proxy_(proxy), 191 proxy_(proxy),
192 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
193 use_gpu_rasterization_(false), 193 use_gpu_rasterization_(false),
194 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), 194 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE),
195 input_handler_client_(NULL), 195 input_handler_client_(NULL),
196 did_lock_scrolling_layer_(false), 196 did_lock_scrolling_layer_(false),
197 should_bubble_scrolls_(false), 197 should_bubble_scrolls_(false),
198 wheel_scrolling_(false), 198 wheel_scrolling_(false),
199 scroll_affects_scroll_handler_(false), 199 scroll_affects_scroll_handler_(false),
200 scroll_layer_id_when_mouse_over_scrollbar_(0), 200 scroll_layer_id_when_mouse_over_scrollbar_(0),
201 tile_priorities_dirty_(false), 201 tile_priorities_dirty_(false),
202 root_layer_scroll_offset_delegate_(NULL), 202 root_layer_scroll_offset_delegate_(NULL),
(...skipping 10 matching lines...) Expand all
213 memory_history_(MemoryHistory::Create()), 213 memory_history_(MemoryHistory::Create()),
214 debug_rect_history_(DebugRectHistory::Create()), 214 debug_rect_history_(DebugRectHistory::Create()),
215 texture_mailbox_deleter_(new TextureMailboxDeleter( 215 texture_mailbox_deleter_(new TextureMailboxDeleter(
216 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() 216 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner()
217 : proxy_->MainThreadTaskRunner())), 217 : proxy_->MainThreadTaskRunner())),
218 max_memory_needed_bytes_(0), 218 max_memory_needed_bytes_(0),
219 zero_budget_(false), 219 zero_budget_(false),
220 device_scale_factor_(1.f), 220 device_scale_factor_(1.f),
221 overhang_ui_resource_id_(0), 221 overhang_ui_resource_id_(0),
222 resourceless_software_draw_(false), 222 resourceless_software_draw_(false),
223 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()),
224 animation_registrar_(AnimationRegistrar::Create()), 223 animation_registrar_(AnimationRegistrar::Create()),
225 rendering_stats_instrumentation_(rendering_stats_instrumentation), 224 rendering_stats_instrumentation_(rendering_stats_instrumentation),
226 micro_benchmark_controller_(this), 225 micro_benchmark_controller_(this),
227 shared_bitmap_manager_(shared_bitmap_manager), 226 shared_bitmap_manager_(shared_bitmap_manager),
228 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 227 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
229 id_(id), 228 id_(id),
230 requires_high_res_to_draw_(false), 229 requires_high_res_to_draw_(false),
231 required_for_draw_tile_is_top_of_raster_queue_(false) { 230 required_for_draw_tile_is_top_of_raster_queue_(false) {
232 DCHECK(proxy_->IsImplThread()); 231 DCHECK(proxy_->IsImplThread());
233 DidVisibilityChange(this, visible_); 232 DidVisibilityChange(this, visible_);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (EvictedUIResourcesExist()) { 366 if (EvictedUIResourcesExist()) {
368 TRACE_EVENT_INSTANT0( 367 TRACE_EVENT_INSTANT0(
369 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", 368 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated",
370 TRACE_EVENT_SCOPE_THREAD); 369 TRACE_EVENT_SCOPE_THREAD);
371 return false; 370 return false;
372 } 371 }
373 return true; 372 return true;
374 } 373 }
375 374
376 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { 375 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
376 // DCHECK(!current_begin_frame_tracker_.HasFinished());
377 // DCHECK(monotonic_time == current_begin_frame_tracker_.Get().frame_time)
378 // << "Called animate with unknown frame time!?";
377 if (input_handler_client_) 379 if (input_handler_client_)
378 input_handler_client_->Animate(monotonic_time); 380 input_handler_client_->Animate(monotonic_time);
379 AnimatePageScale(monotonic_time); 381 AnimatePageScale(monotonic_time);
380 AnimateLayers(monotonic_time); 382 AnimateLayers(monotonic_time);
381 AnimateScrollbars(monotonic_time); 383 AnimateScrollbars(monotonic_time);
382 AnimateTopControls(monotonic_time); 384 AnimateTopControls(monotonic_time);
383 } 385 }
384 386
385 void LayerTreeHostImpl::PrepareTiles() { 387 void LayerTreeHostImpl::PrepareTiles() {
386 if (!tile_manager_) 388 if (!tile_manager_)
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 "input", 1628 "input",
1627 "LatencyInfo.Flow", 1629 "LatencyInfo.Flow",
1628 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), 1630 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id),
1629 "SwapBuffers"); 1631 "SwapBuffers");
1630 } 1632 }
1631 renderer_->SwapBuffers(metadata); 1633 renderer_->SwapBuffers(metadata);
1632 return true; 1634 return true;
1633 } 1635 }
1634 1636
1635 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { 1637 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
1636 // Sample the frame time now. This time will be used for updating animations 1638 current_begin_frame_tracker_.Start(args);
1637 // when we draw.
1638 UpdateCurrentBeginFrameArgs(args);
1639 // Cache the begin impl frame interval
1640 begin_impl_frame_interval_ = args.interval;
1641 1639
1642 if (required_for_draw_tile_is_top_of_raster_queue_) { 1640 if (required_for_draw_tile_is_top_of_raster_queue_) {
1643 // Optimistically schedule a draw, as a tile required for draw is at the top 1641 // Optimistically schedule a draw, as a tile required for draw is at the top
1644 // of the current raster queue. This will let us expect the tile to complete 1642 // of the current raster queue. This will let us expect the tile to complete
1645 // and draw it within the impl frame we are beginning now. 1643 // and draw it within the impl frame we are beginning now.
1646 SetNeedsRedraw(); 1644 SetNeedsRedraw();
1647 } 1645 }
1648 } 1646 }
1649 1647
1650 void LayerTreeHostImpl::UpdateViewportContainerSizes() { 1648 void LayerTreeHostImpl::UpdateViewportContainerSizes() {
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 ScrollOffsetAnimationCurve* curve = 2401 ScrollOffsetAnimationCurve* curve =
2404 animation->curve()->ToScrollOffsetAnimationCurve(); 2402 animation->curve()->ToScrollOffsetAnimationCurve();
2405 2403
2406 gfx::ScrollOffset new_target = 2404 gfx::ScrollOffset new_target =
2407 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta); 2405 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta);
2408 new_target.SetToMax(gfx::ScrollOffset()); 2406 new_target.SetToMax(gfx::ScrollOffset());
2409 new_target.SetToMin(layer_impl->MaxScrollOffset()); 2407 new_target.SetToMin(layer_impl->MaxScrollOffset());
2410 2408
2411 curve->UpdateTarget( 2409 curve->UpdateTarget(
2412 animation->TrimTimeToCurrentIteration( 2410 animation->TrimTimeToCurrentIteration(
2413 CurrentBeginFrameArgs().frame_time).InSecondsF(), 2411 current_begin_frame_tracker_.Get().frame_time)
2412 .InSecondsF(),
2414 new_target); 2413 new_target);
2415 2414
2416 return ScrollStarted; 2415 return ScrollStarted;
2417 } 2416 }
2418 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling 2417 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling
2419 // behavior as ScrollBy to determine which layer to animate, but we do not 2418 // behavior as ScrollBy to determine which layer to animate, but we do not
2420 // do the Android-specific things in ScrollBy like showing top controls. 2419 // do the Android-specific things in ScrollBy like showing top controls.
2421 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel); 2420 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel);
2422 if (scroll_status == ScrollStarted) { 2421 if (scroll_status == ScrollStarted) {
2423 gfx::Vector2dF pending_delta = scroll_delta; 2422 gfx::Vector2dF pending_delta = scroll_delta;
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
3212 if (global_tile_state_.tree_priority == priority) 3211 if (global_tile_state_.tree_priority == priority)
3213 return; 3212 return;
3214 global_tile_state_.tree_priority = priority; 3213 global_tile_state_.tree_priority = priority;
3215 DidModifyTilePriorities(); 3214 DidModifyTilePriorities();
3216 } 3215 }
3217 3216
3218 TreePriority LayerTreeHostImpl::GetTreePriority() const { 3217 TreePriority LayerTreeHostImpl::GetTreePriority() const {
3219 return global_tile_state_.tree_priority; 3218 return global_tile_state_.tree_priority;
3220 } 3219 }
3221 3220
3222 void LayerTreeHostImpl::UpdateCurrentBeginFrameArgs(
3223 const BeginFrameArgs& args) {
3224 DCHECK(!current_begin_frame_args_.IsValid());
3225 current_begin_frame_args_ = args;
3226 // TODO(skyostil): Stop overriding the frame time once the usage of frame
3227 // timing is unified.
3228 current_begin_frame_args_.frame_time = gfx::FrameTime::Now();
3229 }
3230
3231 void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() { 3221 void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() {
3232 current_begin_frame_args_ = BeginFrameArgs(); 3222 current_begin_frame_tracker_.Finish();
3233 } 3223 }
3234 3224
3235 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { 3225 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const {
3236 // Try to use the current frame time to keep animations non-jittery. But if 3226 // TODO(mithro): Remove this section once all calls to CurrentBeginFrameArgs
3237 // we're not in a frame (because this is during an input event or a delayed 3227 // which happens outside frame rendering are fixed.
3238 // task), fall back to physical time. This should still be monotonic. 3228 if (current_begin_frame_tracker_.HasFinished()) {
3239 if (current_begin_frame_args_.IsValid()) 3229 return current_begin_frame_tracker_.Last();
3240 return current_begin_frame_args_; 3230 }
3241 return BeginFrameArgs::Create( 3231 return current_begin_frame_tracker_.Get();
3242 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), 3232 }
3243 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); 3233
3234 base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const {
3235 return current_begin_frame_tracker_.Interval();
3244 } 3236 }
3245 3237
3246 scoped_refptr<base::debug::ConvertableToTraceFormat> 3238 scoped_refptr<base::debug::ConvertableToTraceFormat>
3247 LayerTreeHostImpl::AsValue() const { 3239 LayerTreeHostImpl::AsValue() const {
3248 return AsValueWithFrame(NULL); 3240 return AsValueWithFrame(NULL);
3249 } 3241 }
3250 3242
3251 scoped_refptr<base::debug::ConvertableToTraceFormat> 3243 scoped_refptr<base::debug::ConvertableToTraceFormat>
3252 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { 3244 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const {
3253 scoped_refptr<base::debug::TracedValue> state = 3245 scoped_refptr<base::debug::TracedValue> state =
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3478 } 3470 }
3479 3471
3480 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3472 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3481 std::vector<PictureLayerImpl*>::iterator it = 3473 std::vector<PictureLayerImpl*>::iterator it =
3482 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3474 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3483 DCHECK(it != picture_layers_.end()); 3475 DCHECK(it != picture_layers_.end());
3484 picture_layers_.erase(it); 3476 picture_layers_.erase(it);
3485 } 3477 }
3486 3478
3487 } // namespace cc 3479 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698