OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/resources/raster_worker_pool.h" | 5 #include "cc/resources/raster_worker_pool.h" |
6 | 6 |
7 #include "base/debug/trace_event_synthetic_delay.h" | |
7 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
8 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "cc/debug/devtools_instrumentation.h" | 11 #include "cc/debug/devtools_instrumentation.h" |
11 #include "cc/debug/traced_value.h" | 12 #include "cc/debug/traced_value.h" |
12 #include "cc/resources/picture_pile_impl.h" | 13 #include "cc/resources/picture_pile_impl.h" |
13 #include "skia/ext/lazy_pixel_ref.h" | 14 #include "skia/ext/lazy_pixel_ref.h" |
14 #include "skia/ext/paint_simplifier.h" | 15 #include "skia/ext/paint_simplifier.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
16 | 17 |
(...skipping 11 matching lines...) Expand all Loading... | |
28 return true; | 29 return true; |
29 } | 30 } |
30 private: | 31 private: |
31 void* buffer_; | 32 void* buffer_; |
32 }; | 33 }; |
33 | 34 |
34 // Flag to indicate whether we should try and detect that | 35 // Flag to indicate whether we should try and detect that |
35 // a tile is of solid color. | 36 // a tile is of solid color. |
36 const bool kUseColorEstimator = true; | 37 const bool kUseColorEstimator = true; |
37 | 38 |
39 template <const char* delay_name> | |
reveman
2013/12/18 20:55:18
As this is only used for cc.RasterRequiredForActiv
Sami
2013/12/19 12:49:21
Good point, done.
| |
40 struct SyntheticDelayInitializer { | |
41 SyntheticDelayInitializer() | |
42 : delay(base::debug::TraceEventSyntheticDelay::Lookup(delay_name)) {} | |
43 base::debug::TraceEventSyntheticDelay* delay; | |
44 }; | |
45 | |
46 // Synthetic delay for raster tasks that are required for activation. Global to | |
47 // avoid static initializer on critical path. | |
48 const char kRasterRequiredForActivation[] = "cc.RasterRequiredForActivation"; | |
49 static base::LazyInstance< | |
50 SyntheticDelayInitializer<kRasterRequiredForActivation> > | |
51 g_raster_required_for_activation_delay = LAZY_INSTANCE_INITIALIZER; | |
52 | |
38 class DisableLCDTextFilter : public SkDrawFilter { | 53 class DisableLCDTextFilter : public SkDrawFilter { |
39 public: | 54 public: |
40 // SkDrawFilter interface. | 55 // SkDrawFilter interface. |
41 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { | 56 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { |
42 if (type != SkDrawFilter::kText_Type) | 57 if (type != SkDrawFilter::kText_Type) |
43 return true; | 58 return true; |
44 | 59 |
45 paint->setLCDRenderText(false); | 60 paint->setLCDRenderText(false); |
46 return true; | 61 return true; |
47 } | 62 } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 | 299 |
285 DISALLOW_COPY_AND_ASSIGN(ImageDecodeWorkerPoolTaskImpl); | 300 DISALLOW_COPY_AND_ASSIGN(ImageDecodeWorkerPoolTaskImpl); |
286 }; | 301 }; |
287 | 302 |
288 class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask { | 303 class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask { |
289 public: | 304 public: |
290 typedef base::Callback<void(const internal::WorkerPoolTask* source)> | 305 typedef base::Callback<void(const internal::WorkerPoolTask* source)> |
291 Callback; | 306 Callback; |
292 | 307 |
293 RasterFinishedWorkerPoolTaskImpl( | 308 RasterFinishedWorkerPoolTaskImpl( |
294 const Callback& on_raster_finished_callback) | 309 const Callback& on_raster_finished_callback, |
310 bool has_tasks_required_for_activation) | |
295 : origin_loop_(base::MessageLoopProxy::current().get()), | 311 : origin_loop_(base::MessageLoopProxy::current().get()), |
296 on_raster_finished_callback_(on_raster_finished_callback) { | 312 on_raster_finished_callback_(on_raster_finished_callback), |
313 has_tasks_required_for_activation_(has_tasks_required_for_activation) { | |
314 if (has_tasks_required_for_activation_) { | |
315 g_raster_required_for_activation_delay.Get().delay->BeginParallel( | |
316 &activation_delay_end_time_); | |
317 } | |
297 } | 318 } |
298 | 319 |
299 // Overridden from internal::WorkerPoolTask: | 320 // Overridden from internal::WorkerPoolTask: |
300 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { | 321 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
301 TRACE_EVENT0("cc", "RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread"); | 322 TRACE_EVENT0("cc", "RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread"); |
323 if (has_tasks_required_for_activation_) { | |
324 g_raster_required_for_activation_delay.Get().delay->EndParallel( | |
325 activation_delay_end_time_); | |
326 } | |
302 origin_loop_->PostTask( | 327 origin_loop_->PostTask( |
303 FROM_HERE, | 328 FROM_HERE, |
304 base::Bind(&RasterFinishedWorkerPoolTaskImpl::RunOnOriginThread, | 329 base::Bind(&RasterFinishedWorkerPoolTaskImpl::RunOnOriginThread, |
305 this)); | 330 this)); |
306 } | 331 } |
307 virtual void CompleteOnOriginThread() OVERRIDE {} | 332 virtual void CompleteOnOriginThread() OVERRIDE {} |
308 | 333 |
309 private: | 334 private: |
310 virtual ~RasterFinishedWorkerPoolTaskImpl() {} | 335 virtual ~RasterFinishedWorkerPoolTaskImpl() {} |
311 | 336 |
312 void RunOnOriginThread() const { | 337 void RunOnOriginThread() const { |
313 on_raster_finished_callback_.Run(this); | 338 on_raster_finished_callback_.Run(this); |
314 } | 339 } |
315 | 340 |
316 scoped_refptr<base::MessageLoopProxy> origin_loop_; | 341 scoped_refptr<base::MessageLoopProxy> origin_loop_; |
317 const Callback on_raster_finished_callback_; | 342 const Callback on_raster_finished_callback_; |
343 const bool has_tasks_required_for_activation_; | |
344 base::TimeTicks activation_delay_end_time_; | |
reveman
2013/12/18 20:55:18
Maybe cleaner to add a RasterRequiredForActivation
Sami
2013/12/19 12:49:21
Agreed, that's much nicer.
| |
318 | 345 |
319 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); | 346 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); |
320 }; | 347 }; |
321 | 348 |
322 const char* kWorkerThreadNamePrefix = "CompositorRaster"; | 349 const char* kWorkerThreadNamePrefix = "CompositorRaster"; |
323 | 350 |
324 } // namespace | 351 } // namespace |
325 | 352 |
326 namespace internal { | 353 namespace internal { |
327 | 354 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 return | 522 return |
496 raster_tasks_required_for_activation_.find(task) != | 523 raster_tasks_required_for_activation_.find(task) != |
497 raster_tasks_required_for_activation_.end(); | 524 raster_tasks_required_for_activation_.end(); |
498 } | 525 } |
499 | 526 |
500 scoped_refptr<internal::WorkerPoolTask> | 527 scoped_refptr<internal::WorkerPoolTask> |
501 RasterWorkerPool::CreateRasterFinishedTask() { | 528 RasterWorkerPool::CreateRasterFinishedTask() { |
502 return make_scoped_refptr( | 529 return make_scoped_refptr( |
503 new RasterFinishedWorkerPoolTaskImpl( | 530 new RasterFinishedWorkerPoolTaskImpl( |
504 base::Bind(&RasterWorkerPool::OnRasterFinished, | 531 base::Bind(&RasterWorkerPool::OnRasterFinished, |
505 weak_ptr_factory_.GetWeakPtr()))); | 532 weak_ptr_factory_.GetWeakPtr()), |
533 false)); | |
506 } | 534 } |
507 | 535 |
508 scoped_refptr<internal::WorkerPoolTask> | 536 scoped_refptr<internal::WorkerPoolTask> |
509 RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask() { | 537 RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask( |
538 bool has_tasks_required_for_activation) { | |
reveman
2013/12/18 20:55:18
Is it necessary to avoid this when has_tasks_requi
Sami
2013/12/19 12:49:21
The problem is that having no tasks required for a
reveman
2013/12/19 17:29:28
OK, I can see why that happens.
| |
510 return make_scoped_refptr( | 539 return make_scoped_refptr( |
511 new RasterFinishedWorkerPoolTaskImpl( | 540 new RasterFinishedWorkerPoolTaskImpl( |
512 base::Bind(&RasterWorkerPool::OnRasterRequiredForActivationFinished, | 541 base::Bind(&RasterWorkerPool::OnRasterRequiredForActivationFinished, |
513 weak_ptr_factory_.GetWeakPtr()))); | 542 weak_ptr_factory_.GetWeakPtr()), |
543 has_tasks_required_for_activation)); | |
514 } | 544 } |
515 | 545 |
516 void RasterWorkerPool::OnRasterFinished( | 546 void RasterWorkerPool::OnRasterFinished( |
517 const internal::WorkerPoolTask* source) { | 547 const internal::WorkerPoolTask* source) { |
518 TRACE_EVENT0("cc", "RasterWorkerPool::OnRasterFinished"); | 548 TRACE_EVENT0("cc", "RasterWorkerPool::OnRasterFinished"); |
519 | 549 |
520 // Early out if current |raster_finished_task_| is not the source. | 550 // Early out if current |raster_finished_task_| is not the source. |
521 if (source != raster_finished_task_.get()) | 551 if (source != raster_finished_task_.get()) |
522 return; | 552 return; |
523 | 553 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 | 617 |
588 internal::GraphNode* decode_node = CreateGraphNodeForTask( | 618 internal::GraphNode* decode_node = CreateGraphNodeForTask( |
589 decode_task, priority, graph); | 619 decode_task, priority, graph); |
590 decode_node->add_dependent(raster_node); | 620 decode_node->add_dependent(raster_node); |
591 } | 621 } |
592 | 622 |
593 return raster_node; | 623 return raster_node; |
594 } | 624 } |
595 | 625 |
596 } // namespace cc | 626 } // namespace cc |
OLD | NEW |