| Index: cc/raster_worker_pool.h
|
| diff --git a/cc/raster_worker_pool.h b/cc/raster_worker_pool.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0c4d3867088e7a0c8ed5c7508935c6376ad4c031
|
| --- /dev/null
|
| +++ b/cc/raster_worker_pool.h
|
| @@ -0,0 +1,98 @@
|
| +// 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_POOL_H_
|
| +#define CC_RASTER_WORKER_POOL_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/callback.h"
|
| +#include "base/threading/thread.h"
|
| +#include "cc/rendering_stats.h"
|
| +#include "ui/gfx/rect.h"
|
| +
|
| +namespace skia {
|
| +class LazyPixelRef;
|
| +}
|
| +
|
| +namespace cc {
|
| +class PicturePileImpl;
|
| +
|
| +class RasterWorkerPool {
|
| + public:
|
| + explicit RasterWorkerPool(size_t num_raster_threads);
|
| + virtual ~RasterWorkerPool();
|
| +
|
| + static scoped_ptr<RasterWorkerPool> Create(size_t num_raster_threads) {
|
| + return make_scoped_ptr(new RasterWorkerPool(num_raster_threads));
|
| + }
|
| +
|
| + bool IsBusy();
|
| +
|
| + void PostRasterTaskAndReply(PicturePileImpl* picture_pile,
|
| + uint8* buffer,
|
| + const gfx::Rect& rect,
|
| + float contents_scale,
|
| + const base::Closure& reply);
|
| + void PostImageDecodeTaskAndReply(skia::LazyPixelRef* pixel_ref,
|
| + const base::Closure& reply);
|
| +
|
| + void GetRenderingStats(RenderingStats* stats);
|
| +
|
| + private:
|
| + class Thread : public base::Thread {
|
| + public:
|
| + class Task {
|
| + public:
|
| + Task(Thread* thread);
|
| + ~Task();
|
| +
|
| + private:
|
| + friend class RasterWorkerPool;
|
| +
|
| + Thread* thread_;
|
| + RenderingStats rendering_stats_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(Task);
|
| + };
|
| +
|
| + Thread(const std::string name);
|
| + virtual ~Thread();
|
| +
|
| + int num_pending_tasks() const { return num_pending_tasks_; }
|
| + RenderingStats& rendering_stats() { return rendering_stats_; }
|
| +
|
| + private:
|
| + int num_pending_tasks_;
|
| + RenderingStats rendering_stats_;
|
| +
|
| + 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();
|
| + }
|
| + };
|
| +
|
| + Thread::Task* CreateTask();
|
| + void DestroyTask(Thread::Task* task);
|
| +
|
| + void OnTaskCompleted(Thread::Task* task,
|
| + const base::Closure& reply);
|
| + void OnRasterTaskCompleted(Thread::Task* task,
|
| + scoped_refptr<PicturePileImpl> picture_pile,
|
| + const base::Closure& reply);
|
| +
|
| + typedef std::vector<Thread*> ThreadVector;
|
| + ThreadVector raster_threads_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool);
|
| +};
|
| +
|
| +} // namespace cc
|
| +
|
| +#endif // CC_RASTER_WORKER_POOL_H_
|
|
|