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/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "cc/debug/devtools_instrumentation.h" | 10 #include "cc/debug/devtools_instrumentation.h" |
11 #include "cc/debug/traced_value.h" | 11 #include "cc/debug/traced_value.h" |
12 #include "cc/resources/picture_pile_impl.h" | 12 #include "cc/resources/picture_pile_impl.h" |
13 #include "skia/ext/lazy_pixel_ref.h" | 13 #include "skia/ext/lazy_pixel_ref.h" |
14 #include "skia/ext/paint_simplifier.h" | 14 #include "skia/ext/paint_simplifier.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "third_party/skia/include/gpu/GrContext.h" | |
17 #include "third_party/skia/include/gpu/SkGpuDevice.h" | |
18 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | |
16 | 19 |
17 namespace cc { | 20 namespace cc { |
18 | 21 |
19 namespace { | 22 namespace { |
20 | 23 |
21 // Subclass of Allocator that takes a suitably allocated pointer and uses | 24 // Subclass of Allocator that takes a suitably allocated pointer and uses |
22 // it as the pixel memory for the bitmap. | 25 // it as the pixel memory for the bitmap. |
23 class IdentityAllocator : public SkBitmap::Allocator { | 26 class IdentityAllocator : public SkBitmap::Allocator { |
24 public: | 27 public: |
25 explicit IdentityAllocator(void* buffer) : buffer_(buffer) {} | 28 explicit IdentityAllocator(void* buffer) : buffer_(buffer) {} |
(...skipping 14 matching lines...) Expand all Loading... | |
40 // SkDrawFilter interface. | 43 // SkDrawFilter interface. |
41 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { | 44 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { |
42 if (type != SkDrawFilter::kText_Type) | 45 if (type != SkDrawFilter::kText_Type) |
43 return true; | 46 return true; |
44 | 47 |
45 paint->setLCDRenderText(false); | 48 paint->setLCDRenderText(false); |
46 return true; | 49 return true; |
47 } | 50 } |
48 }; | 51 }; |
49 | 52 |
50 class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask { | 53 class RasterWorkerPoolTaskSW : public internal::RasterWorkerPoolTask { |
51 public: | 54 public: |
52 RasterWorkerPoolTaskImpl(const Resource* resource, | 55 RasterWorkerPoolTaskSW(const Resource* resource, |
53 PicturePileImpl* picture_pile, | 56 PicturePileImpl* picture_pile, |
54 gfx::Rect content_rect, | 57 gfx::Rect content_rect, |
55 float contents_scale, | 58 float contents_scale, |
56 RasterMode raster_mode, | 59 RasterMode raster_mode, |
57 TileResolution tile_resolution, | 60 TileResolution tile_resolution, |
58 int layer_id, | 61 int layer_id, |
59 const void* tile_id, | 62 const void* tile_id, |
60 int source_frame_number, | 63 int source_frame_number, |
61 RenderingStatsInstrumentation* rendering_stats, | 64 RenderingStatsInstrumentation* rendering_stats, |
62 const RasterWorkerPool::RasterTask::Reply& reply, | 65 const RasterWorkerPool::RasterTask::Reply& reply, |
63 TaskVector* dependencies) | 66 TaskVector* dependencies) |
64 : internal::RasterWorkerPoolTask(resource, dependencies), | 67 : internal::RasterWorkerPoolTask(resource, dependencies), |
65 picture_pile_(picture_pile), | 68 picture_pile_(picture_pile), |
66 content_rect_(content_rect), | 69 content_rect_(content_rect), |
67 contents_scale_(contents_scale), | 70 contents_scale_(contents_scale), |
68 raster_mode_(raster_mode), | 71 raster_mode_(raster_mode), |
69 tile_resolution_(tile_resolution), | 72 tile_resolution_(tile_resolution), |
70 layer_id_(layer_id), | 73 layer_id_(layer_id), |
71 tile_id_(tile_id), | 74 tile_id_(tile_id), |
72 source_frame_number_(source_frame_number), | 75 source_frame_number_(source_frame_number), |
73 rendering_stats_(rendering_stats), | 76 rendering_stats_(rendering_stats), |
74 reply_(reply) {} | 77 reply_(reply) {} |
75 | 78 |
76 void RunAnalysisOnThread(unsigned thread_index) { | 79 void RunAnalysisOnThread(unsigned thread_index) { |
77 TRACE_EVENT1("cc", | 80 TRACE_EVENT1("cc", |
78 "RasterWorkerPoolTaskImpl::RunAnalysisOnThread", | 81 "RasterWorkerPoolTaskSW::RunAnalysisOnThread", |
79 "data", | 82 "data", |
80 TracedValue::FromValue(DataAsValue().release())); | 83 TracedValue::FromValue(DataAsValue().release())); |
81 | 84 |
82 DCHECK(picture_pile_.get()); | 85 DCHECK(picture_pile_.get()); |
83 DCHECK(rendering_stats_); | 86 DCHECK(rendering_stats_); |
84 | 87 |
85 PicturePileImpl* picture_clone = | 88 PicturePileImpl* picture_clone = |
86 picture_pile_->GetCloneForDrawingOnThread(thread_index); | 89 picture_pile_->GetCloneForDrawingOnThread(thread_index); |
87 | 90 |
88 DCHECK(picture_clone); | 91 DCHECK(picture_clone); |
89 | 92 |
90 picture_clone->AnalyzeInRect( | 93 picture_clone->AnalyzeInRect( |
91 content_rect_, contents_scale_, &analysis_, rendering_stats_); | 94 content_rect_, contents_scale_, &analysis_, rendering_stats_); |
92 | 95 |
93 // Record the solid color prediction. | 96 // Record the solid color prediction. |
94 UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed", | 97 UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed", |
95 analysis_.is_solid_color); | 98 analysis_.is_solid_color); |
96 | 99 |
97 // Clear the flag if we're not using the estimator. | 100 // Clear the flag if we're not using the estimator. |
98 analysis_.is_solid_color &= kUseColorEstimator; | 101 analysis_.is_solid_color &= kUseColorEstimator; |
99 } | 102 } |
100 | 103 |
101 bool RunRasterOnThread(unsigned thread_index, | 104 bool RunRasterOnThread(unsigned thread_index, |
102 void* buffer, | 105 void* buffer, |
103 gfx::Size size, | 106 gfx::Size size, |
104 int stride) { | 107 int stride) { |
105 TRACE_EVENT2( | 108 TRACE_EVENT2( |
106 "cc", "RasterWorkerPoolTaskImpl::RunRasterOnThread", | 109 "cc", "RasterWorkerPoolTaskSW::RunRasterOnThread", |
107 "data", | 110 "data", |
108 TracedValue::FromValue(DataAsValue().release()), | 111 TracedValue::FromValue(DataAsValue().release()), |
109 "raster_mode", | 112 "raster_mode", |
110 TracedValue::FromValue(RasterModeAsValue(raster_mode_).release())); | 113 TracedValue::FromValue(RasterModeAsValue(raster_mode_).release())); |
111 | 114 |
112 devtools_instrumentation::ScopedLayerTask raster_task( | 115 devtools_instrumentation::ScopedLayerTask raster_task( |
113 devtools_instrumentation::kRasterTask, layer_id_); | 116 devtools_instrumentation::kRasterTask, layer_id_); |
114 | 117 |
115 DCHECK(picture_pile_.get()); | 118 DCHECK(picture_pile_.get()); |
116 DCHECK(buffer); | 119 DCHECK(buffer); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 | 201 |
199 // Overridden from internal::RasterWorkerPoolTask: | 202 // Overridden from internal::RasterWorkerPoolTask: |
200 virtual bool RunOnWorkerThread(unsigned thread_index, | 203 virtual bool RunOnWorkerThread(unsigned thread_index, |
201 void* buffer, | 204 void* buffer, |
202 gfx::Size size, | 205 gfx::Size size, |
203 int stride) | 206 int stride) |
204 OVERRIDE { | 207 OVERRIDE { |
205 RunAnalysisOnThread(thread_index); | 208 RunAnalysisOnThread(thread_index); |
206 return RunRasterOnThread(thread_index, buffer, size, stride); | 209 return RunRasterOnThread(thread_index, buffer, size, stride); |
207 } | 210 } |
211 virtual void RunOnOriginThread() OVERRIDE { | |
212 NOTREACHED(); | |
213 } | |
208 virtual void CompleteOnOriginThread() OVERRIDE { | 214 virtual void CompleteOnOriginThread() OVERRIDE { |
209 reply_.Run(analysis_, !HasFinishedRunning() || WasCanceled()); | 215 reply_.Run(analysis_, !HasFinishedRunning() || WasCanceled()); |
210 } | 216 } |
211 | 217 |
212 protected: | 218 protected: |
213 virtual ~RasterWorkerPoolTaskImpl() {} | 219 virtual ~RasterWorkerPoolTaskSW() {} |
214 | 220 |
215 private: | 221 private: |
216 scoped_ptr<base::Value> DataAsValue() const { | 222 scoped_ptr<base::Value> DataAsValue() const { |
217 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 223 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
218 res->Set("tile_id", TracedValue::CreateIDRef(tile_id_).release()); | 224 res->Set("tile_id", TracedValue::CreateIDRef(tile_id_).release()); |
219 res->Set("resolution", TileResolutionAsValue(tile_resolution_).release()); | 225 res->Set("resolution", TileResolutionAsValue(tile_resolution_).release()); |
220 res->SetInteger("source_frame_number", source_frame_number_); | 226 res->SetInteger("source_frame_number", source_frame_number_); |
221 res->SetInteger("layer_id", layer_id_); | 227 res->SetInteger("layer_id", layer_id_); |
222 return res.PassAs<base::Value>(); | 228 return res.PassAs<base::Value>(); |
223 } | 229 } |
(...skipping 17 matching lines...) Expand all Loading... | |
241 gfx::Rect content_rect_; | 247 gfx::Rect content_rect_; |
242 float contents_scale_; | 248 float contents_scale_; |
243 RasterMode raster_mode_; | 249 RasterMode raster_mode_; |
244 TileResolution tile_resolution_; | 250 TileResolution tile_resolution_; |
245 int layer_id_; | 251 int layer_id_; |
246 const void* tile_id_; | 252 const void* tile_id_; |
247 int source_frame_number_; | 253 int source_frame_number_; |
248 RenderingStatsInstrumentation* rendering_stats_; | 254 RenderingStatsInstrumentation* rendering_stats_; |
249 const RasterWorkerPool::RasterTask::Reply reply_; | 255 const RasterWorkerPool::RasterTask::Reply reply_; |
250 | 256 |
251 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPoolTaskImpl); | 257 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPoolTaskSW); |
258 }; | |
259 | |
260 class RasterWorkerPoolTaskGPU : public internal::RasterWorkerPoolTask { | |
reveman
2013/12/17 00:28:48
Could we use RasterWorkerPoolTaskImpl for this ins
alokp
2013/12/17 22:12:15
Done.
| |
261 public: | |
262 RasterWorkerPoolTaskGPU(const Resource* resource, | |
263 PicturePileImpl* picture_pile, | |
264 gfx::Rect content_rect, | |
265 float contents_scale, | |
266 ResourceProvider* resource_provider, | |
267 ContextProvider* context_provider, | |
268 RenderingStatsInstrumentation* rendering_stats, | |
269 const RasterWorkerPool::RasterTask::Reply& reply, | |
270 TaskVector* dependencies) | |
271 : internal::RasterWorkerPoolTask(resource, dependencies), | |
272 picture_pile_(picture_pile), | |
273 content_rect_(content_rect), | |
274 contents_scale_(contents_scale), | |
275 resource_provider_(resource_provider), | |
276 context_provider_(context_provider), | |
277 rendering_stats_(rendering_stats), | |
278 reply_(reply) {} | |
279 | |
280 // Overridden from internal::RasterWorkerPoolTask: | |
281 virtual bool RunOnWorkerThread(unsigned thread_index, | |
282 void* buffer, | |
283 gfx::Size size, | |
284 int stride) OVERRIDE { | |
285 NOTREACHED(); | |
286 return false; | |
287 } | |
288 virtual void RunOnOriginThread() OVERRIDE { | |
289 DCHECK_NE(resource()->id(), 0u); | |
290 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, | |
291 resource()->id()); | |
292 DCHECK_NE(lock.texture_id(), 0u); | |
293 | |
294 GrBackendTextureDesc desc; | |
295 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | |
296 desc.fWidth = content_rect_.width(); | |
297 desc.fHeight = content_rect_.height(); | |
298 desc.fConfig = ToGrFormat(resource()->format()); | |
reveman
2013/12/17 00:28:48
How are GrPixelConfig formats used by Ganesh? Some
alokp
2013/12/17 22:12:15
Swizzling is never required when rasterizing with
| |
299 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | |
300 desc.fTextureHandle = lock.texture_id(); | |
301 | |
302 GrContext* gr_context = context_provider_->GrContext(); | |
303 skia::RefPtr<GrTexture> texture = | |
304 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); | |
305 skia::RefPtr<SkGpuDevice> device = | |
306 skia::AdoptRef(SkGpuDevice::Create(texture.get())); | |
307 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(new SkCanvas(device.get())); | |
308 | |
309 canvas->clear(SK_ColorTRANSPARENT); | |
310 picture_pile_->RasterDirect(canvas.get(), | |
311 content_rect_, | |
312 contents_scale_, | |
313 rendering_stats_); | |
314 gr_context->flush(); | |
reveman
2013/12/17 00:28:48
as you have a flush in CompleteOriginThreadTasks,
alokp
2013/12/17 22:12:15
Done.
| |
315 } | |
316 virtual void CompleteOnOriginThread() OVERRIDE { | |
317 reply_.Run(PicturePileImpl::Analysis(), false); | |
318 } | |
319 | |
320 protected: | |
321 virtual ~RasterWorkerPoolTaskGPU() {} | |
322 | |
323 static GrPixelConfig ToGrFormat(ResourceFormat format) { | |
324 switch (format) { | |
325 case RGBA_8888: return kRGBA_8888_GrPixelConfig; | |
326 case BGRA_8888: return kBGRA_8888_GrPixelConfig; | |
327 case RGBA_4444: return kRGBA_4444_GrPixelConfig; | |
328 default: break; | |
329 } | |
330 DCHECK(false) << "Unsupported resource format."; | |
331 return kSkia8888_GrPixelConfig; | |
332 } | |
333 | |
334 private: | |
335 scoped_refptr<PicturePileImpl> picture_pile_; | |
336 gfx::Rect content_rect_; | |
337 float contents_scale_; | |
338 ResourceProvider* resource_provider_; | |
339 ContextProvider* context_provider_; | |
340 RenderingStatsInstrumentation* rendering_stats_; | |
341 const RasterWorkerPool::RasterTask::Reply reply_; | |
252 }; | 342 }; |
253 | 343 |
254 class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask { | 344 class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask { |
255 public: | 345 public: |
256 ImageDecodeWorkerPoolTaskImpl(skia::LazyPixelRef* pixel_ref, | 346 ImageDecodeWorkerPoolTaskImpl(skia::LazyPixelRef* pixel_ref, |
257 int layer_id, | 347 int layer_id, |
258 RenderingStatsInstrumentation* rendering_stats, | 348 RenderingStatsInstrumentation* rendering_stats, |
259 const RasterWorkerPool::Task::Reply& reply) | 349 const RasterWorkerPool::Task::Reply& reply) |
260 : pixel_ref_(skia::SharePtr(pixel_ref)), | 350 : pixel_ref_(skia::SharePtr(pixel_ref)), |
261 layer_id_(layer_id), | 351 layer_id_(layer_id), |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 void RasterWorkerPool::Task::Reset() { | 480 void RasterWorkerPool::Task::Reset() { |
391 internal_ = NULL; | 481 internal_ = NULL; |
392 } | 482 } |
393 | 483 |
394 RasterWorkerPool::RasterTask::Queue::Queue() { | 484 RasterWorkerPool::RasterTask::Queue::Queue() { |
395 } | 485 } |
396 | 486 |
397 RasterWorkerPool::RasterTask::Queue::~Queue() { | 487 RasterWorkerPool::RasterTask::Queue::~Queue() { |
398 } | 488 } |
399 | 489 |
400 void RasterWorkerPool::RasterTask::Queue::Append( | 490 void RasterWorkerPool::RasterTask::Queue::Append(const RasterTask& task, |
401 const RasterTask& task, bool required_for_activation) { | 491 bool required_for_activation) { |
402 DCHECK(!task.is_null()); | 492 DCHECK(!task.is_null()); |
493 | |
494 if (task.must_run_on_origin_thread_) { | |
495 origin_thread_tasks_.push_back(task.internal_); | |
496 return; | |
497 } | |
498 | |
403 tasks_.push_back(task.internal_); | 499 tasks_.push_back(task.internal_); |
404 if (required_for_activation) | 500 if (required_for_activation) |
405 tasks_required_for_activation_.insert(task.internal_.get()); | 501 tasks_required_for_activation_.insert(task.internal_.get()); |
406 } | 502 } |
407 | 503 |
408 RasterWorkerPool::RasterTask::RasterTask() { | 504 RasterWorkerPool::RasterTask::RasterTask() { |
409 } | 505 } |
410 | 506 |
411 RasterWorkerPool::RasterTask::RasterTask( | 507 RasterWorkerPool::RasterTask::RasterTask( |
412 internal::RasterWorkerPoolTask* internal) | 508 internal::RasterWorkerPoolTask* internal, |
413 : internal_(internal) { | 509 bool must_run_on_origin_thread) |
510 : internal_(internal), | |
511 must_run_on_origin_thread_(must_run_on_origin_thread) { | |
414 } | 512 } |
415 | 513 |
416 void RasterWorkerPool::RasterTask::Reset() { | 514 void RasterWorkerPool::RasterTask::Reset() { |
417 internal_ = NULL; | 515 internal_ = NULL; |
418 } | 516 } |
419 | 517 |
420 RasterWorkerPool::RasterTask::~RasterTask() { | 518 RasterWorkerPool::RasterTask::~RasterTask() { |
421 } | 519 } |
422 | 520 |
423 // static | |
424 RasterWorkerPool::RasterTask RasterWorkerPool::CreateRasterTask( | 521 RasterWorkerPool::RasterTask RasterWorkerPool::CreateRasterTask( |
425 const Resource* resource, | 522 const Resource* resource, |
426 PicturePileImpl* picture_pile, | 523 PicturePileImpl* picture_pile, |
427 gfx::Rect content_rect, | 524 gfx::Rect content_rect, |
428 float contents_scale, | 525 float contents_scale, |
429 RasterMode raster_mode, | 526 RasterMode raster_mode, |
430 TileResolution tile_resolution, | 527 TileResolution tile_resolution, |
431 int layer_id, | 528 int layer_id, |
432 const void* tile_id, | 529 const void* tile_id, |
433 int source_frame_number, | 530 int source_frame_number, |
531 bool use_gpu_rasterization, | |
434 RenderingStatsInstrumentation* rendering_stats, | 532 RenderingStatsInstrumentation* rendering_stats, |
435 const RasterTask::Reply& reply, | 533 const RasterTask::Reply& reply, |
436 Task::Set* dependencies) { | 534 Task::Set* dependencies) { |
437 return RasterTask( | 535 internal::RasterWorkerPoolTask* impl = NULL; |
438 new RasterWorkerPoolTaskImpl(resource, | 536 if (use_gpu_rasterization) { |
439 picture_pile, | 537 impl = new RasterWorkerPoolTaskGPU(resource, |
440 content_rect, | 538 picture_pile, |
441 contents_scale, | 539 content_rect, |
442 raster_mode, | 540 contents_scale, |
443 tile_resolution, | 541 resource_provider_, |
444 layer_id, | 542 context_provider_, |
445 tile_id, | 543 rendering_stats, |
446 source_frame_number, | 544 reply, |
447 rendering_stats, | 545 &dependencies->tasks_); |
448 reply, | 546 } else { |
449 &dependencies->tasks_)); | 547 impl = new RasterWorkerPoolTaskSW(resource, |
548 picture_pile, | |
549 content_rect, | |
550 contents_scale, | |
551 raster_mode, | |
552 tile_resolution, | |
553 layer_id, | |
554 tile_id, | |
555 source_frame_number, | |
556 rendering_stats, | |
557 reply, | |
558 &dependencies->tasks_); | |
559 } | |
560 return RasterTask(impl, use_gpu_rasterization); | |
vmpstr
2013/12/17 21:04:37
This might be echoing some of David's comments, bu
alokp
2013/12/17 22:12:15
Done.
| |
450 } | 561 } |
451 | 562 |
452 // static | 563 // static |
453 RasterWorkerPool::Task RasterWorkerPool::CreateImageDecodeTask( | 564 RasterWorkerPool::Task RasterWorkerPool::CreateImageDecodeTask( |
454 skia::LazyPixelRef* pixel_ref, | 565 skia::LazyPixelRef* pixel_ref, |
455 int layer_id, | 566 int layer_id, |
456 RenderingStatsInstrumentation* stats_instrumentation, | 567 RenderingStatsInstrumentation* stats_instrumentation, |
457 const Task::Reply& reply) { | 568 const Task::Reply& reply) { |
458 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref, | 569 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref, |
459 layer_id, | 570 layer_id, |
460 stats_instrumentation, | 571 stats_instrumentation, |
461 reply)); | 572 reply)); |
462 } | 573 } |
463 | 574 |
464 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, | 575 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, |
576 ContextProvider* context_provider, | |
465 size_t num_threads) | 577 size_t num_threads) |
466 : WorkerPool(num_threads, kWorkerThreadNamePrefix), | 578 : WorkerPool(num_threads, kWorkerThreadNamePrefix), |
467 client_(NULL), | 579 client_(NULL), |
468 resource_provider_(resource_provider), | 580 resource_provider_(resource_provider), |
581 context_provider_(context_provider), | |
469 weak_ptr_factory_(this) { | 582 weak_ptr_factory_(this) { |
470 } | 583 } |
471 | 584 |
472 RasterWorkerPool::~RasterWorkerPool() { | 585 RasterWorkerPool::~RasterWorkerPool() { |
473 } | 586 } |
474 | 587 |
475 void RasterWorkerPool::SetClient(RasterWorkerPoolClient* client) { | 588 void RasterWorkerPool::SetClient(RasterWorkerPoolClient* client) { |
476 client_ = client; | 589 client_ = client; |
477 } | 590 } |
478 | 591 |
479 void RasterWorkerPool::Shutdown() { | 592 void RasterWorkerPool::Shutdown() { |
480 raster_tasks_.clear(); | 593 raster_tasks_.clear(); |
481 TaskGraph empty; | 594 TaskGraph empty; |
482 SetTaskGraph(&empty); | 595 SetTaskGraph(&empty); |
483 WorkerPool::Shutdown(); | 596 WorkerPool::Shutdown(); |
484 weak_ptr_factory_.InvalidateWeakPtrs(); | 597 weak_ptr_factory_.InvalidateWeakPtrs(); |
485 } | 598 } |
486 | 599 |
600 void RasterWorkerPool::CompleteOriginThreadTasks(RasterTask::Queue* queue) { | |
reveman
2013/12/17 00:28:48
I think this needs to be RunTasksOnOriginThread (O
alokp
2013/12/17 22:12:15
Done.
| |
601 if (queue->origin_thread_tasks_.empty()) | |
602 return; | |
603 | |
604 blink::WebGraphicsContext3D* context = context_provider_->Context3d(); | |
605 GrContext* gr_context = context_provider_->GrContext(); | |
606 context->makeContextCurrent(); | |
607 gr_context->resetContext(); | |
608 | |
609 for (RasterTaskVector::iterator it = queue->origin_thread_tasks_.begin(); | |
610 it != queue->origin_thread_tasks_.end(); ++it) { | |
611 internal::RasterWorkerPoolTask* task = (*it).get(); | |
612 task->RunOnOriginThread(); | |
613 task->CompleteOnOriginThread(); | |
reveman
2013/12/17 00:28:48
Task completion needs to be delayed until ::CheckF
alokp
2013/12/17 22:12:15
AFAICT ImageRasterWorkerPool never calls CheckForC
| |
614 } | |
615 | |
616 gr_context->flush(); | |
617 queue->origin_thread_tasks_.clear(); | |
618 } | |
619 | |
487 void RasterWorkerPool::SetRasterTasks(RasterTask::Queue* queue) { | 620 void RasterWorkerPool::SetRasterTasks(RasterTask::Queue* queue) { |
488 raster_tasks_.swap(queue->tasks_); | 621 raster_tasks_.swap(queue->tasks_); |
489 raster_tasks_required_for_activation_.swap( | 622 raster_tasks_required_for_activation_.swap( |
490 queue->tasks_required_for_activation_); | 623 queue->tasks_required_for_activation_); |
491 } | 624 } |
492 | 625 |
493 bool RasterWorkerPool::IsRasterTaskRequiredForActivation( | 626 bool RasterWorkerPool::IsRasterTaskRequiredForActivation( |
494 internal::RasterWorkerPoolTask* task) const { | 627 internal::RasterWorkerPoolTask* task) const { |
495 return | 628 return |
496 raster_tasks_required_for_activation_.find(task) != | 629 raster_tasks_required_for_activation_.find(task) != |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 | 720 |
588 internal::GraphNode* decode_node = CreateGraphNodeForTask( | 721 internal::GraphNode* decode_node = CreateGraphNodeForTask( |
589 decode_task, priority, graph); | 722 decode_task, priority, graph); |
590 decode_node->add_dependent(raster_node); | 723 decode_node->add_dependent(raster_node); |
591 } | 724 } |
592 | 725 |
593 return raster_node; | 726 return raster_node; |
594 } | 727 } |
595 | 728 |
596 } // namespace cc | 729 } // namespace cc |
OLD | NEW |