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

Unified Diff: cc/resources/raster_worker_pool.cc

Issue 83183005: Add synthetic delay points for latency testing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No need to loop over tasks in ImageRasterWorkerPool. Created 7 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
« no previous file with comments | « cc/resources/raster_worker_pool.h ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/raster_worker_pool.cc
diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc
index 06fd18e62e0ec2bdc9d440ee0ae6eb925c867ef4..ae2733c035628789fb22d56513674abf0dc7f43b 100644
--- a/cc/resources/raster_worker_pool.cc
+++ b/cc/resources/raster_worker_pool.cc
@@ -4,6 +4,7 @@
#include "cc/resources/raster_worker_pool.h"
+#include "base/debug/trace_event_synthetic_delay.h"
#include "base/json/json_writer.h"
#include "base/metrics/histogram.h"
#include "base/values.h"
@@ -35,6 +36,17 @@ class IdentityAllocator : public SkBitmap::Allocator {
// a tile is of solid color.
const bool kUseColorEstimator = true;
+// Synthetic delay for raster tasks that are required for activation. Global to
+// avoid static initializer on critical path.
+struct RasterRequiredForActivationSyntheticDelayInitializer {
+ RasterRequiredForActivationSyntheticDelayInitializer()
+ : delay(base::debug::TraceEventSyntheticDelay::Lookup(
+ "cc.RasterRequiredForActivation")) {}
+ base::debug::TraceEventSyntheticDelay* delay;
+};
+static base::LazyInstance<RasterRequiredForActivationSyntheticDelayInitializer>
+ g_raster_required_for_activation_delay = LAZY_INSTANCE_INITIALIZER;
+
class DisableLCDTextFilter : public SkDrawFilter {
public:
// SkDrawFilter interface.
@@ -306,9 +318,10 @@ class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask {
}
virtual void CompleteOnOriginThread() OVERRIDE {}
- private:
+ protected:
virtual ~RasterFinishedWorkerPoolTaskImpl() {}
+ private:
void RunOnOriginThread() const {
on_raster_finished_callback_.Run(this);
}
@@ -319,6 +332,42 @@ class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask {
DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl);
};
+class RasterRequiredForActivationFinishedWorkerPoolTaskImpl
+ : public RasterFinishedWorkerPoolTaskImpl {
+ public:
+ RasterRequiredForActivationFinishedWorkerPoolTaskImpl(
+ const Callback& on_raster_finished_callback,
+ bool has_tasks_required_for_activation)
+ : RasterFinishedWorkerPoolTaskImpl(on_raster_finished_callback),
+ has_tasks_required_for_activation_(has_tasks_required_for_activation) {
+ if (has_tasks_required_for_activation_) {
+ g_raster_required_for_activation_delay.Get().delay->BeginParallel(
+ &activation_delay_end_time_);
+ }
+ }
+
+ // Overridden from RasterFinishedWorkerPoolTaskImpl
reveman 2013/12/19 19:02:23 nit: add a ":" at the end of this line
+ virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE {
+ TRACE_EVENT0("cc",
+ "RasterRequiredForActivationFinishedWorkerPoolTaskImpl::"
+ "RunOnWorkerThread");
+ if (has_tasks_required_for_activation_) {
+ g_raster_required_for_activation_delay.Get().delay->EndParallel(
+ activation_delay_end_time_);
+ }
+ RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread(thread_index);
+ }
+
+ private:
+ virtual ~RasterRequiredForActivationFinishedWorkerPoolTaskImpl() {}
+
+ base::TimeTicks activation_delay_end_time_;
+ const bool has_tasks_required_for_activation_;
reveman 2013/12/19 19:02:23 nit: "size_t tasks_required_for_activation_count_"
+
+ DISALLOW_COPY_AND_ASSIGN(
+ RasterRequiredForActivationFinishedWorkerPoolTaskImpl);
+};
+
const char* kWorkerThreadNamePrefix = "CompositorRaster";
} // namespace
@@ -506,11 +555,13 @@ scoped_refptr<internal::WorkerPoolTask>
}
scoped_refptr<internal::WorkerPoolTask>
- RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask() {
+ RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask(
+ size_t tasks_required_for_activation_count) {
return make_scoped_refptr(
- new RasterFinishedWorkerPoolTaskImpl(
+ new RasterRequiredForActivationFinishedWorkerPoolTaskImpl(
base::Bind(&RasterWorkerPool::OnRasterRequiredForActivationFinished,
- weak_ptr_factory_.GetWeakPtr())));
+ weak_ptr_factory_.GetWeakPtr()),
+ tasks_required_for_activation_count > 0u));
}
void RasterWorkerPool::OnRasterFinished(
« no previous file with comments | « cc/resources/raster_worker_pool.h ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698