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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index ea8a29f46560dbaf88d13c08f9247dd7c3da857a..951d95179700d4f85b33ce24545c3c8e93b44bb9 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -71,7 +71,6 @@
#include "cc/trees/tree_synchronizer.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/GLES2/gl2extchromium.h"
-#include "ui/gfx/frame_time.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
@@ -220,7 +219,6 @@ LayerTreeHostImpl::LayerTreeHostImpl(
device_scale_factor_(1.f),
overhang_ui_resource_id_(0),
resourceless_software_draw_(false),
- begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()),
animation_registrar_(AnimationRegistrar::Create()),
rendering_stats_instrumentation_(rendering_stats_instrumentation),
micro_benchmark_controller_(this),
@@ -374,6 +372,9 @@ bool LayerTreeHostImpl::CanDraw() const {
}
void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
+ // DCHECK(!current_begin_frame_args_.HasFinished());
+ // DCHECK(monotonic_time == current_begin_frame_args_.Get().frame_time)
+ // << "Called animate with unknown frame time!?";
if (input_handler_client_)
input_handler_client_->Animate(monotonic_time);
AnimatePageScale(monotonic_time);
@@ -1632,11 +1633,7 @@ bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) {
}
void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
- // Sample the frame time now. This time will be used for updating animations
- // when we draw.
- UpdateCurrentBeginFrameArgs(args);
- // Cache the begin impl frame interval
- begin_impl_frame_interval_ = args.interval;
+ current_begin_frame_args_.Start(args);
if (required_for_draw_tile_is_top_of_raster_queue_) {
// Optimistically schedule a draw, as a tile required for draw is at the top
@@ -2409,7 +2406,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
curve->UpdateTarget(
animation->TrimTimeToCurrentIteration(
- CurrentBeginFrameArgs().frame_time).InSecondsF(),
+ current_begin_frame_args_.Get().frame_time).InSecondsF(),
new_target);
return ScrollStarted;
@@ -3224,26 +3221,24 @@ TreePriority LayerTreeHostImpl::GetTreePriority() const {
void LayerTreeHostImpl::UpdateCurrentBeginFrameArgs(
const BeginFrameArgs& args) {
- DCHECK(!current_begin_frame_args_.IsValid());
- current_begin_frame_args_ = args;
- // TODO(skyostil): Stop overriding the frame time once the usage of frame
- // timing is unified.
- current_begin_frame_args_.frame_time = gfx::FrameTime::Now();
+ current_begin_frame_args_.Start(args);
}
void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() {
- current_begin_frame_args_ = BeginFrameArgs();
+ 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
}
BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const {
- // Try to use the current frame time to keep animations non-jittery. But if
- // we're not in a frame (because this is during an input event or a delayed
- // task), fall back to physical time. This should still be monotonic.
- if (current_begin_frame_args_.IsValid())
- return current_begin_frame_args_;
- return BeginFrameArgs::Create(
- BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(),
- BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
+ // TODO(mithro): Remove this section once all calls to CurrentBeginFrameArgs
+ // which happens outside frame rendering are fixed.
+ if (current_begin_frame_args_.HasFinished()) {
+ return current_begin_frame_args_.Last();
+ }
+ return current_begin_frame_args_.Get();
+}
+
+base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const {
+ return current_begin_frame_args_.Interval();
}
scoped_refptr<base::debug::ConvertableToTraceFormat>

Powered by Google App Engine
This is Rietveld 408576698