Commit d7309448 authored by caseq@chromium.org's avatar caseq@chromium.org

cc: add more devtools instrumentation

This adds didRequestMainThreadFrame() and didDrawFrame() so we can better
track impl-side frame lifecycle in DevTools

R=danakj, nduca

Review URL: https://codereview.chromium.org/144463016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251127 0039d316-1c4b-4281-b951-d872f2087c98
parent f1ccb865
......@@ -20,6 +20,8 @@ const char kPixelRefId[] = "pixelRefId";
const char kImageDecodeTask[] = "ImageDecodeTask";
const char kBeginFrame[] = "BeginFrame";
const char kActivateLayerTree[] = "ActivateLayerTree";
const char kRequestMainThreadFrame[] = "RequestMainThreadFrame";
const char kDrawFrame[] = "DrawFrame";
} // namespace internal
const char kRasterTask[] = "RasterTask";
......@@ -86,7 +88,7 @@ struct ScopedLayerObjectTracker
DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker);
};
inline void didActivateLayerTree(int layer_tree_host_id, int frame_id) {
inline void DidActivateLayerTree(int layer_tree_host_id, int frame_id) {
TRACE_EVENT_INSTANT2(internal::kCategory,
internal::kActivateLayerTree,
TRACE_EVENT_SCOPE_THREAD,
......@@ -94,13 +96,29 @@ inline void didActivateLayerTree(int layer_tree_host_id, int frame_id) {
internal::kFrameId, frame_id);
}
inline void didBeginFrame(int layer_tree_host_id) {
inline void DidBeginFrame(int layer_tree_host_id) {
TRACE_EVENT_INSTANT1(internal::kCategory,
internal::kBeginFrame,
TRACE_EVENT_SCOPE_THREAD,
internal::kLayerTreeId, layer_tree_host_id);
}
inline void DidDrawFrame(int layer_tree_host_id) {
TRACE_EVENT_INSTANT1(internal::kCategory,
internal::kDrawFrame,
TRACE_EVENT_SCOPE_THREAD,
internal::kLayerTreeId,
layer_tree_host_id);
}
inline void DidRequestMainThreadFrame(int layer_tree_host_id) {
TRACE_EVENT_INSTANT1(internal::kCategory,
internal::kRequestMainThreadFrame,
TRACE_EVENT_SCOPE_THREAD,
internal::kLayerTreeId,
layer_tree_host_id);
}
} // namespace devtools_instrumentation
} // namespace cc
......
......@@ -215,6 +215,7 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
last_begin_impl_frame_args_ = args;
last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate();
state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_);
devtools_instrumentation::DidBeginFrame(layer_tree_host_id_);
if (settings_.switch_to_low_latency_if_possible) {
state_machine_.SetSkipBeginMainFrameToReduceLatency(
......@@ -228,7 +229,6 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
return;
state_machine_.OnBeginImplFrameDeadlinePending();
devtools_instrumentation::didBeginFrame(layer_tree_host_id_);
if (settings_.using_synchronous_renderer_compositor) {
// The synchronous renderer compositor has to make its GL calls
// within this call to BeginImplFrame.
......
......@@ -410,7 +410,7 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
// If we're not in impl-side painting, the tree is immediately
// considered active.
sync_tree->DidBecomeActive();
devtools_instrumentation::didActivateLayerTree(id_, source_frame_number_);
devtools_instrumentation::DidActivateLayerTree(id_, source_frame_number_);
}
micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
......
......@@ -1343,7 +1343,6 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame,
fps_counter_->SaveTimeStamp(frame_begin_time,
!output_surface_->context_provider());
bool on_main_thread = false;
rendering_stats_instrumentation_->IncrementFrameCount(
1, on_main_thread);
......@@ -1437,6 +1436,7 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame,
}
active_tree_->root_layer()->ResetAllChangeTrackingForSubtree();
devtools_instrumentation::DidDrawFrame(id_);
BenchmarkInstrumentation::IssueImplThreadRenderingStatsEvent(
rendering_stats_instrumentation_->impl_thread_rendering_stats());
rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats();
......@@ -1635,8 +1635,8 @@ void LayerTreeHostImpl::ActivatePendingTree() {
if (time_source_client_adapter_ && time_source_client_adapter_->Active())
DCHECK(active_tree_->root_layer());
devtools_instrumentation::didActivateLayerTree(id_,
active_tree_->source_frame_number());
devtools_instrumentation::DidActivateLayerTree(
id_, active_tree_->source_frame_number());
}
void LayerTreeHostImpl::SetVisible(bool visible) {
......
......@@ -14,6 +14,7 @@
#include "base/metrics/histogram.h"
#include "cc/base/swap_promise.h"
#include "cc/debug/benchmark_instrumentation.h"
#include "cc/debug/devtools_instrumentation.h"
#include "cc/input/input_handler.h"
#include "cc/output/context_provider.h"
#include "cc/output/output_surface.h"
......@@ -84,7 +85,7 @@ ThreadProxy::ThreadProxy(
: Proxy(impl_task_runner),
main_thread_only_vars_unsafe_(this, layer_tree_host->id()),
main_thread_or_blocked_vars_unsafe_(layer_tree_host),
compositor_thread_vars_unsafe_(this) {
compositor_thread_vars_unsafe_(this, layer_tree_host->id()) {
TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
DCHECK(IsMainThread());
DCHECK(this->layer_tree_host());
......@@ -120,8 +121,10 @@ ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() {
return layer_tree_host->contents_texture_manager();
}
ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy)
: contents_texture_manager(NULL),
ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy,
int layer_tree_host_id)
: layer_tree_host_id(layer_tree_host_id),
contents_texture_manager(NULL),
begin_main_frame_sent_completion_event(NULL),
readback_request(NULL),
commit_completion_event(NULL),
......@@ -688,8 +691,7 @@ void ThreadProxy::Start() {
FROM_HERE,
base::Bind(&ThreadProxy::InitializeImplOnImplThread,
base::Unretained(this),
&completion,
main().layer_tree_host_id));
&completion));
completion.Wait();
main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr();
......@@ -782,7 +784,8 @@ void ThreadProxy::ScheduledActionSendBeginMainFrame() {
base::Bind(&ThreadProxy::BeginMainFrame,
main_thread_weak_ptr_,
base::Passed(&begin_main_frame_state)));
devtools_instrumentation::DidRequestMainThreadFrame(
impl().layer_tree_host_id);
if (impl().begin_main_frame_sent_completion_event) {
impl().begin_main_frame_sent_completion_event->Signal();
impl().begin_main_frame_sent_completion_event = NULL;
......@@ -1443,8 +1446,7 @@ void ThreadProxy::HasInitializedOutputSurfaceOnImplThread(
completion->Signal();
}
void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion,
int layer_tree_host_id) {
void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
DCHECK(IsImplThread());
impl().layer_tree_host_impl =
......@@ -1463,7 +1465,7 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion,
scheduler_settings.throttle_frame_production =
settings.throttle_frame_production;
impl().scheduler =
Scheduler::Create(this, scheduler_settings, layer_tree_host_id);
Scheduler::Create(this, scheduler_settings, impl().layer_tree_host_id);
impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
......
......@@ -167,8 +167,7 @@ class ThreadProxy : public Proxy,
void BeginMainFrameAbortedOnImplThread(bool did_handle);
void RequestReadbackOnImplThread(ReadbackRequest* request);
void FinishAllRenderingOnImplThread(CompletionEvent* completion);
void InitializeImplOnImplThread(CompletionEvent* completion,
int layer_tree_host_id);
void InitializeImplOnImplThread(CompletionEvent* completion);
void SetLayerTreeHostClientReadyOnImplThread();
void SetVisibleOnImplThread(CompletionEvent* completion, bool visible);
void UpdateBackgroundAnimateTicking();
......@@ -255,9 +254,11 @@ class ThreadProxy : public Proxy,
const MainThreadOrBlockedMainThread& blocked_main() const;
struct CompositorThreadOnly {
explicit CompositorThreadOnly(ThreadProxy* proxy);
CompositorThreadOnly(ThreadProxy* proxy, int layer_tree_host_id);
~CompositorThreadOnly();
const int layer_tree_host_id;
// Copy of the main thread side contents texture manager for work
// that needs to be done on the compositor thread.
PrioritizedResourceManager* contents_texture_manager;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment