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

Side by Side Diff: cc/resources/raster_worker_pool.cc

Issue 111143005: cc: Gather and lock/unlock SkDiscardablePixelRefs instead of skia::LazyPixelRefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
vmpstr 2013/12/20 17:41:06 include third_party/skia/include/core/SkPixelRef.h
reveman 2013/12/20 18:22:19 Done. And required now that I removed the include
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"
16 15
17 namespace cc { 16 namespace cc {
18 17
19 namespace { 18 namespace {
20 19
21 // Subclass of Allocator that takes a suitably allocated pointer and uses 20 // Subclass of Allocator that takes a suitably allocated pointer and uses
22 // it as the pixel memory for the bitmap. 21 // it as the pixel memory for the bitmap.
23 class IdentityAllocator : public SkBitmap::Allocator { 22 class IdentityAllocator : public SkBitmap::Allocator {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 const void* tile_id_; 245 const void* tile_id_;
247 int source_frame_number_; 246 int source_frame_number_;
248 RenderingStatsInstrumentation* rendering_stats_; 247 RenderingStatsInstrumentation* rendering_stats_;
249 const RasterWorkerPool::RasterTask::Reply reply_; 248 const RasterWorkerPool::RasterTask::Reply reply_;
250 249
251 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPoolTaskImpl); 250 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPoolTaskImpl);
252 }; 251 };
253 252
254 class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask { 253 class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask {
255 public: 254 public:
256 ImageDecodeWorkerPoolTaskImpl(skia::LazyPixelRef* pixel_ref, 255 ImageDecodeWorkerPoolTaskImpl(SkPixelRef* pixel_ref,
257 int layer_id, 256 int layer_id,
258 RenderingStatsInstrumentation* rendering_stats, 257 RenderingStatsInstrumentation* rendering_stats,
259 const RasterWorkerPool::Task::Reply& reply) 258 const RasterWorkerPool::Task::Reply& reply)
260 : pixel_ref_(skia::SharePtr(pixel_ref)), 259 : pixel_ref_(skia::SharePtr(pixel_ref)),
261 layer_id_(layer_id), 260 layer_id_(layer_id),
262 rendering_stats_(rendering_stats), 261 rendering_stats_(rendering_stats),
263 reply_(reply) {} 262 reply_(reply) {}
264 263
265 // Overridden from internal::WorkerPoolTask: 264 // Overridden from internal::WorkerPoolTask:
266 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { 265 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE {
267 TRACE_EVENT0("cc", "ImageDecodeWorkerPoolTaskImpl::RunOnWorkerThread"); 266 TRACE_EVENT0("cc", "ImageDecodeWorkerPoolTaskImpl::RunOnWorkerThread");
268 devtools_instrumentation::ScopedImageDecodeTask image_decode_task( 267 devtools_instrumentation::ScopedImageDecodeTask image_decode_task(
269 pixel_ref_.get()); 268 pixel_ref_.get());
270 pixel_ref_->Decode(); 269 // This will cause the image referred to by pixel ref to be decoded.
270 pixel_ref_->lockPixels();
vmpstr 2013/12/20 17:41:06 This will still keep it in some sort of a cache, r
reveman 2013/12/20 18:22:19 This is exactly the same thing that LazyPixelRef::
271 pixel_ref_->unlockPixels();
271 } 272 }
272 virtual void CompleteOnOriginThread() OVERRIDE { 273 virtual void CompleteOnOriginThread() OVERRIDE {
273 reply_.Run(!HasFinishedRunning()); 274 reply_.Run(!HasFinishedRunning());
274 } 275 }
275 276
276 protected: 277 protected:
277 virtual ~ImageDecodeWorkerPoolTaskImpl() {} 278 virtual ~ImageDecodeWorkerPoolTaskImpl() {}
278 279
279 private: 280 private:
280 skia::RefPtr<skia::LazyPixelRef> pixel_ref_; 281 skia::RefPtr<SkPixelRef> pixel_ref_;
281 int layer_id_; 282 int layer_id_;
282 RenderingStatsInstrumentation* rendering_stats_; 283 RenderingStatsInstrumentation* rendering_stats_;
283 const RasterWorkerPool::Task::Reply reply_; 284 const RasterWorkerPool::Task::Reply reply_;
284 285
285 DISALLOW_COPY_AND_ASSIGN(ImageDecodeWorkerPoolTaskImpl); 286 DISALLOW_COPY_AND_ASSIGN(ImageDecodeWorkerPoolTaskImpl);
286 }; 287 };
287 288
288 class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask { 289 class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask {
289 public: 290 public:
290 typedef base::Callback<void(const internal::WorkerPoolTask* source)> 291 typedef base::Callback<void(const internal::WorkerPoolTask* source)>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 layer_id, 445 layer_id,
445 tile_id, 446 tile_id,
446 source_frame_number, 447 source_frame_number,
447 rendering_stats, 448 rendering_stats,
448 reply, 449 reply,
449 &dependencies->tasks_)); 450 &dependencies->tasks_));
450 } 451 }
451 452
452 // static 453 // static
453 RasterWorkerPool::Task RasterWorkerPool::CreateImageDecodeTask( 454 RasterWorkerPool::Task RasterWorkerPool::CreateImageDecodeTask(
454 skia::LazyPixelRef* pixel_ref, 455 SkPixelRef* pixel_ref,
455 int layer_id, 456 int layer_id,
456 RenderingStatsInstrumentation* stats_instrumentation, 457 RenderingStatsInstrumentation* stats_instrumentation,
457 const Task::Reply& reply) { 458 const Task::Reply& reply) {
458 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref, 459 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref,
459 layer_id, 460 layer_id,
460 stats_instrumentation, 461 stats_instrumentation,
461 reply)); 462 reply));
462 } 463 }
463 464
464 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, 465 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 588
588 internal::GraphNode* decode_node = CreateGraphNodeForTask( 589 internal::GraphNode* decode_node = CreateGraphNodeForTask(
589 decode_task, priority, graph); 590 decode_task, priority, graph);
590 decode_node->add_dependent(raster_node); 591 decode_node->add_dependent(raster_node);
591 } 592 }
592 593
593 return raster_node; 594 return raster_node;
594 } 595 }
595 596
596 } // namespace cc 597 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698