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

Side by Side Diff: cc/raster_worker_pool.h

Issue 11593030: cc: Add RasterWorkerPool class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win build. Created 7 years, 11 months 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
« no previous file with comments | « cc/cc.gyp ('k') | cc/raster_worker_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_RASTER_WORKER_POOL_H_
6 #define CC_RASTER_WORKER_POOL_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/threading/thread.h"
13 #include "cc/rendering_stats.h"
14 #include "ui/gfx/rect.h"
15
16 namespace skia {
17 class LazyPixelRef;
18 }
19
20 namespace cc {
21 class PicturePileImpl;
22
23 class RasterWorkerPool {
24 public:
25 explicit RasterWorkerPool(size_t num_raster_threads);
26 virtual ~RasterWorkerPool();
27
28 static scoped_ptr<RasterWorkerPool> Create(size_t num_raster_threads) {
29 return make_scoped_ptr(new RasterWorkerPool(num_raster_threads));
30 }
31
32 bool IsBusy();
33
34 void PostRasterTaskAndReply(PicturePileImpl* picture_pile,
35 uint8* buffer,
36 const gfx::Rect& rect,
37 float contents_scale,
38 const base::Closure& reply);
39 void PostImageDecodeTaskAndReply(skia::LazyPixelRef* pixel_ref,
40 const base::Closure& reply);
41
42 void GetRenderingStats(RenderingStats* stats);
43
44 private:
45 class Thread : public base::Thread {
46 public:
47 class Task {
48 public:
49 Task(Thread* thread);
50 ~Task();
51
52 private:
53 friend class RasterWorkerPool;
54
55 Thread* thread_;
56 RenderingStats rendering_stats_;
57
58 DISALLOW_COPY_AND_ASSIGN(Task);
59 };
60
61 Thread(const std::string name);
62 virtual ~Thread();
63
64 int num_pending_tasks() const { return num_pending_tasks_; }
65 RenderingStats& rendering_stats() { return rendering_stats_; }
66
67 private:
68 int num_pending_tasks_;
69 RenderingStats rendering_stats_;
70
71 DISALLOW_COPY_AND_ASSIGN(Thread);
72 };
73
74 class PendingTaskComparator {
75 public:
76 bool operator() (const Thread* a, const Thread* b) const {
77 return a->num_pending_tasks() < b->num_pending_tasks();
78 }
79 };
80
81 Thread::Task* CreateTask();
82 void DestroyTask(Thread::Task* task);
83
84 void OnTaskCompleted(Thread::Task* task,
85 const base::Closure& reply);
86 void OnRasterTaskCompleted(Thread::Task* task,
87 scoped_refptr<PicturePileImpl> picture_pile,
88 const base::Closure& reply);
89
90 typedef std::vector<Thread*> ThreadVector;
91 ThreadVector raster_threads_;
92
93 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool);
94 };
95
96 } // namespace cc
97
98 #endif // CC_RASTER_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « cc/cc.gyp ('k') | cc/raster_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698