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" | |
14 #include "skia/ext/paint_simplifier.h" | 13 #include "skia/ext/paint_simplifier.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "third_party/skia/include/core/SkPixelRef.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // Subclass of Allocator that takes a suitably allocated pointer and uses | 21 // Subclass of Allocator that takes a suitably allocated pointer and uses |
22 // it as the pixel memory for the bitmap. | 22 // it as the pixel memory for the bitmap. |
23 class IdentityAllocator : public SkBitmap::Allocator { | 23 class IdentityAllocator : public SkBitmap::Allocator { |
24 public: | 24 public: |
25 explicit IdentityAllocator(void* buffer) : buffer_(buffer) {} | 25 explicit IdentityAllocator(void* buffer) : buffer_(buffer) {} |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 const void* tile_id_; | 246 const void* tile_id_; |
247 int source_frame_number_; | 247 int source_frame_number_; |
248 RenderingStatsInstrumentation* rendering_stats_; | 248 RenderingStatsInstrumentation* rendering_stats_; |
249 const RasterWorkerPool::RasterTask::Reply reply_; | 249 const RasterWorkerPool::RasterTask::Reply reply_; |
250 | 250 |
251 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPoolTaskImpl); | 251 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPoolTaskImpl); |
252 }; | 252 }; |
253 | 253 |
254 class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask { | 254 class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask { |
255 public: | 255 public: |
256 ImageDecodeWorkerPoolTaskImpl(skia::LazyPixelRef* pixel_ref, | 256 ImageDecodeWorkerPoolTaskImpl(SkPixelRef* pixel_ref, |
257 int layer_id, | 257 int layer_id, |
258 RenderingStatsInstrumentation* rendering_stats, | 258 RenderingStatsInstrumentation* rendering_stats, |
259 const RasterWorkerPool::Task::Reply& reply) | 259 const RasterWorkerPool::Task::Reply& reply) |
260 : pixel_ref_(skia::SharePtr(pixel_ref)), | 260 : pixel_ref_(skia::SharePtr(pixel_ref)), |
261 layer_id_(layer_id), | 261 layer_id_(layer_id), |
262 rendering_stats_(rendering_stats), | 262 rendering_stats_(rendering_stats), |
263 reply_(reply) {} | 263 reply_(reply) {} |
264 | 264 |
265 // Overridden from internal::WorkerPoolTask: | 265 // Overridden from internal::WorkerPoolTask: |
266 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { | 266 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
267 TRACE_EVENT0("cc", "ImageDecodeWorkerPoolTaskImpl::RunOnWorkerThread"); | 267 TRACE_EVENT0("cc", "ImageDecodeWorkerPoolTaskImpl::RunOnWorkerThread"); |
268 devtools_instrumentation::ScopedImageDecodeTask image_decode_task( | 268 devtools_instrumentation::ScopedImageDecodeTask image_decode_task( |
269 pixel_ref_.get()); | 269 pixel_ref_.get()); |
270 pixel_ref_->Decode(); | 270 // This will cause the image referred to by pixel ref to be decoded. |
| 271 pixel_ref_->lockPixels(); |
| 272 pixel_ref_->unlockPixels(); |
271 } | 273 } |
272 virtual void CompleteOnOriginThread() OVERRIDE { | 274 virtual void CompleteOnOriginThread() OVERRIDE { |
273 reply_.Run(!HasFinishedRunning()); | 275 reply_.Run(!HasFinishedRunning()); |
274 } | 276 } |
275 | 277 |
276 protected: | 278 protected: |
277 virtual ~ImageDecodeWorkerPoolTaskImpl() {} | 279 virtual ~ImageDecodeWorkerPoolTaskImpl() {} |
278 | 280 |
279 private: | 281 private: |
280 skia::RefPtr<skia::LazyPixelRef> pixel_ref_; | 282 skia::RefPtr<SkPixelRef> pixel_ref_; |
281 int layer_id_; | 283 int layer_id_; |
282 RenderingStatsInstrumentation* rendering_stats_; | 284 RenderingStatsInstrumentation* rendering_stats_; |
283 const RasterWorkerPool::Task::Reply reply_; | 285 const RasterWorkerPool::Task::Reply reply_; |
284 | 286 |
285 DISALLOW_COPY_AND_ASSIGN(ImageDecodeWorkerPoolTaskImpl); | 287 DISALLOW_COPY_AND_ASSIGN(ImageDecodeWorkerPoolTaskImpl); |
286 }; | 288 }; |
287 | 289 |
288 class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask { | 290 class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask { |
289 public: | 291 public: |
290 typedef base::Callback<void(const internal::WorkerPoolTask* source)> | 292 typedef base::Callback<void(const internal::WorkerPoolTask* source)> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 layer_id, | 446 layer_id, |
445 tile_id, | 447 tile_id, |
446 source_frame_number, | 448 source_frame_number, |
447 rendering_stats, | 449 rendering_stats, |
448 reply, | 450 reply, |
449 &dependencies->tasks_)); | 451 &dependencies->tasks_)); |
450 } | 452 } |
451 | 453 |
452 // static | 454 // static |
453 RasterWorkerPool::Task RasterWorkerPool::CreateImageDecodeTask( | 455 RasterWorkerPool::Task RasterWorkerPool::CreateImageDecodeTask( |
454 skia::LazyPixelRef* pixel_ref, | 456 SkPixelRef* pixel_ref, |
455 int layer_id, | 457 int layer_id, |
456 RenderingStatsInstrumentation* stats_instrumentation, | 458 RenderingStatsInstrumentation* stats_instrumentation, |
457 const Task::Reply& reply) { | 459 const Task::Reply& reply) { |
458 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref, | 460 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref, |
459 layer_id, | 461 layer_id, |
460 stats_instrumentation, | 462 stats_instrumentation, |
461 reply)); | 463 reply)); |
462 } | 464 } |
463 | 465 |
464 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, | 466 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 589 |
588 internal::GraphNode* decode_node = CreateGraphNodeForTask( | 590 internal::GraphNode* decode_node = CreateGraphNodeForTask( |
589 decode_task, priority, graph); | 591 decode_task, priority, graph); |
590 decode_node->add_dependent(raster_node); | 592 decode_node->add_dependent(raster_node); |
591 } | 593 } |
592 | 594 |
593 return raster_node; | 595 return raster_node; |
594 } | 596 } |
595 | 597 |
596 } // namespace cc | 598 } // namespace cc |
OLD | NEW |