Chromium Code Reviews| Index: cc/raster_worker.h |
| diff --git a/cc/raster_worker.h b/cc/raster_worker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8a88fa071ac8c2af287f6485ba36d7f99fed39b9 |
| --- /dev/null |
| +++ b/cc/raster_worker.h |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_RASTER_WORKER_H_ |
| +#define CC_RASTER_WORKER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "base/threading/thread.h" |
| +#include "cc/rendering_stats.h" |
| +#include "cc/scoped_ptr_vector.h" |
| +#include "ui/gfx/rect.h" |
| + |
| +namespace skia { |
| +class LazyPixelRef; |
| +} |
| + |
| +namespace cc { |
| +class PicturePileImpl; |
| + |
| +class RasterWorker { |
|
nduca
2012/12/19 04:46:50
RasterThreadPool? Worker implies that it is only o
reveman
2012/12/27 15:26:58
Right. I made it RasterWorkerPool in latest patch,
|
| + public: |
| + explicit RasterWorker(size_t num_raster_threads); |
| + virtual ~RasterWorker(); |
| + |
| + static scoped_ptr<RasterWorker> Create(size_t num_raster_threads) { |
| + return make_scoped_ptr(new RasterWorker(num_raster_threads)); |
| + } |
| + |
| + bool IsBusy(); |
| + |
| + void PostRasterTaskAndReply(PicturePileImpl* picture_pile, |
| + uint8_t* buffer, |
| + const gfx::Rect& rect, |
| + float contents_scale, |
| + const base::Closure& reply); |
| + void PostImageDecodingTaskAndReply(skia::LazyPixelRef* pixel_ref, |
| + const base::Closure& reply); |
| + |
| + void GetRenderingStats(RenderingStats* stats); |
| + |
| + private: |
| + class Thread : public base::Thread { |
| + public: |
| + Thread(const std::string name); |
| + virtual ~Thread(); |
| + |
| + int num_pending_tasks() const { return num_pending_tasks_; } |
| + |
| + private: |
| + friend class RasterWorker; |
| + |
| + int num_pending_tasks_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Thread); |
| + }; |
| + |
| + class PendingTaskComparator { |
| + public: |
| + bool operator() (const Thread* a, const Thread* b) const { |
| + return a->num_pending_tasks() < b->num_pending_tasks(); |
| + } |
| + }; |
| + |
| + typedef base::Callback<void(RenderingStats* stats)> TaskCallback; |
| + |
| + void PostTaskAndReply(const TaskCallback& task, const base::Closure& reply); |
| + void RunTaskOnRasterThread(const TaskCallback& task, RenderingStats* stats); |
| + void OnTaskCompleted(Thread* thread, |
| + RenderingStats* stats, |
| + const base::Closure& reply); |
| + |
| + typedef ScopedPtrVector<Thread> ThreadVector; |
| + ThreadVector raster_threads_; |
| + |
| + RenderingStats rendering_stats_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RasterWorker); |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_RASTER_WORKER_H_ |