| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CC_RASTER_WORKER_POOL_H_ | 5 #ifndef CC_RASTER_WORKER_POOL_H_ |
| 6 #define CC_RASTER_WORKER_POOL_H_ | 6 #define CC_RASTER_WORKER_POOL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "cc/rendering_stats.h" | 13 #include "cc/rendering_stats.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 15 | 15 |
| 16 namespace skia { | 16 namespace skia { |
| 17 class LazyPixelRef; | 17 class LazyPixelRef; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 class PicturePileImpl; | 21 class PicturePileImpl; |
| 22 | 22 |
| 23 class RasterWorkerPool { | 23 class RasterWorkerPool { |
| 24 public: | 24 public: |
| 25 explicit RasterWorkerPool(size_t num_raster_threads); | |
| 26 virtual ~RasterWorkerPool(); | 25 virtual ~RasterWorkerPool(); |
| 27 | 26 |
| 28 static scoped_ptr<RasterWorkerPool> Create(size_t num_raster_threads) { | 27 static scoped_ptr<RasterWorkerPool> Create( |
| 29 return make_scoped_ptr(new RasterWorkerPool(num_raster_threads)); | 28 size_t num_raster_threads, bool record_rendering_stats) { |
| 29 return make_scoped_ptr(new RasterWorkerPool( |
| 30 num_raster_threads, record_rendering_stats)); |
| 30 } | 31 } |
| 31 | 32 |
| 32 // Starts the worker pool. Returns true if the worker pool was successfully | 33 // Starts the worker pool. Returns true if the worker pool was successfully |
| 33 // started; otherwise, returns false. | 34 // started; otherwise, returns false. |
| 34 bool Start(); | 35 bool Start(); |
| 35 | 36 |
| 36 // Tells the worker pool to stop and returns once all pending tasks have | 37 // Tells the worker pool to stop and returns once all pending tasks have |
| 37 // completed. | 38 // completed. |
| 38 void Stop(); | 39 void Stop(); |
| 39 | 40 |
| 40 // Returns true if the worker pool has been started, and not yet stopped. | 41 // Returns true if the worker pool has been started, and not yet stopped. |
| 41 bool IsRunning() const; | 42 bool IsRunning() const; |
| 42 | 43 |
| 43 bool IsBusy(); | 44 bool IsBusy(); |
| 44 | 45 |
| 45 void PostRasterTaskAndReply(PicturePileImpl* picture_pile, | 46 void PostRasterTaskAndReply(PicturePileImpl* picture_pile, |
| 46 uint8* buffer, | 47 uint8* buffer, |
| 47 const gfx::Rect& rect, | 48 const gfx::Rect& rect, |
| 48 float contents_scale, | 49 float contents_scale, |
| 49 const base::Closure& reply); | 50 const base::Closure& reply); |
| 50 void PostImageDecodeTaskAndReply(skia::LazyPixelRef* pixel_ref, | 51 void PostImageDecodeTaskAndReply(skia::LazyPixelRef* pixel_ref, |
| 51 const base::Closure& reply); | 52 const base::Closure& reply); |
| 52 | 53 |
| 53 void GetRenderingStats(RenderingStats* stats); | 54 void GetRenderingStats(RenderingStats* stats); |
| 54 | 55 |
| 55 private: | 56 private: |
| 57 RasterWorkerPool(size_t num_raster_threads, bool record_rendering_stats); |
| 58 |
| 56 class Thread : public base::Thread { | 59 class Thread : public base::Thread { |
| 57 public: | 60 public: |
| 58 class Task { | 61 class Task { |
| 59 public: | 62 public: |
| 60 Task(Thread* thread); | 63 Task(Thread* thread); |
| 61 ~Task(); | 64 ~Task(); |
| 62 | 65 |
| 63 private: | 66 private: |
| 64 friend class RasterWorkerPool; | 67 friend class RasterWorkerPool; |
| 65 | 68 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 scoped_refptr<PicturePileImpl> picture_pile, | 103 scoped_refptr<PicturePileImpl> picture_pile, |
| 101 const base::Closure& reply); | 104 const base::Closure& reply); |
| 102 | 105 |
| 103 void SortRasterThreadsIfNeeded(); | 106 void SortRasterThreadsIfNeeded(); |
| 104 | 107 |
| 105 bool is_running_; | 108 bool is_running_; |
| 106 | 109 |
| 107 typedef std::vector<Thread*> ThreadVector; | 110 typedef std::vector<Thread*> ThreadVector; |
| 108 ThreadVector raster_threads_; | 111 ThreadVector raster_threads_; |
| 109 bool raster_threads_need_sorting_; | 112 bool raster_threads_need_sorting_; |
| 113 bool record_rendering_stats_; |
| 110 | 114 |
| 111 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool); | 115 DISALLOW_COPY_AND_ASSIGN(RasterWorkerPool); |
| 112 }; | 116 }; |
| 113 | 117 |
| 114 } // namespace cc | 118 } // namespace cc |
| 115 | 119 |
| 116 #endif // CC_RASTER_WORKER_POOL_H_ | 120 #endif // CC_RASTER_WORKER_POOL_H_ |
| OLD | NEW |