OLD | NEW |
---|---|
(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_H_ | |
6 #define CC_RASTER_WORKER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/threading/thread.h" | |
12 #include "cc/rendering_stats.h" | |
13 #include "cc/scoped_ptr_vector.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 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,
| |
24 public: | |
25 explicit RasterWorker(size_t num_raster_threads); | |
26 virtual ~RasterWorker(); | |
27 | |
28 static scoped_ptr<RasterWorker> Create(size_t num_raster_threads) { | |
29 return make_scoped_ptr(new RasterWorker(num_raster_threads)); | |
30 } | |
31 | |
32 bool IsBusy(); | |
33 | |
34 void PostRasterTaskAndReply(PicturePileImpl* picture_pile, | |
35 uint8_t* buffer, | |
36 const gfx::Rect& rect, | |
37 float contents_scale, | |
38 const base::Closure& reply); | |
39 void PostImageDecodingTaskAndReply(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 Thread(const std::string name); | |
48 virtual ~Thread(); | |
49 | |
50 int num_pending_tasks() const { return num_pending_tasks_; } | |
51 | |
52 private: | |
53 friend class RasterWorker; | |
54 | |
55 int num_pending_tasks_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(Thread); | |
58 }; | |
59 | |
60 class PendingTaskComparator { | |
61 public: | |
62 bool operator() (const Thread* a, const Thread* b) const { | |
63 return a->num_pending_tasks() < b->num_pending_tasks(); | |
64 } | |
65 }; | |
66 | |
67 typedef base::Callback<void(RenderingStats* stats)> TaskCallback; | |
68 | |
69 void PostTaskAndReply(const TaskCallback& task, const base::Closure& reply); | |
70 void RunTaskOnRasterThread(const TaskCallback& task, RenderingStats* stats); | |
71 void OnTaskCompleted(Thread* thread, | |
72 RenderingStats* stats, | |
73 const base::Closure& reply); | |
74 | |
75 typedef ScopedPtrVector<Thread> ThreadVector; | |
76 ThreadVector raster_threads_; | |
77 | |
78 RenderingStats rendering_stats_; | |
79 | |
80 DISALLOW_COPY_AND_ASSIGN(RasterWorker); | |
81 }; | |
82 | |
83 } // namespace cc | |
84 | |
85 #endif // CC_RASTER_WORKER_H_ | |
OLD | NEW |