Add ICU message format support
[chromium-blink-merge.git] / cc / raster / pixel_buffer_tile_task_worker_pool.h
blob2c6aeb98228a552493550cda2c6606cc74a159f1
1 // Copyright 2013 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.
5 #ifndef CC_RASTER_PIXEL_BUFFER_TILE_TASK_WORKER_POOL_H_
6 #define CC_RASTER_PIXEL_BUFFER_TILE_TASK_WORKER_POOL_H_
8 #include <deque>
9 #include <vector>
11 #include "base/memory/weak_ptr.h"
12 #include "base/values.h"
13 #include "cc/base/delayed_unique_notifier.h"
14 #include "cc/output/context_provider.h"
15 #include "cc/raster/tile_task_runner.h"
16 #include "cc/raster/tile_task_worker_pool.h"
18 namespace base {
19 namespace trace_event {
20 class ConvertableToTraceFormat;
21 class TracedValue;
25 namespace cc {
26 class ResourceProvider;
28 class CC_EXPORT PixelBufferTileTaskWorkerPool : public TileTaskWorkerPool,
29 public TileTaskRunner,
30 public TileTaskClient {
31 public:
32 ~PixelBufferTileTaskWorkerPool() override;
34 static scoped_ptr<TileTaskWorkerPool> Create(
35 base::SequencedTaskRunner* task_runner,
36 TaskGraphRunner* task_graph_runner,
37 ContextProvider* context_provider,
38 ResourceProvider* resource_provider,
39 size_t max_transfer_buffer_usage_bytes);
41 // Overridden from TileTaskWorkerPool:
42 TileTaskRunner* AsTileTaskRunner() override;
44 // Overridden from TileTaskRunner:
45 void SetClient(TileTaskRunnerClient* client) override;
46 void Shutdown() override;
47 void ScheduleTasks(TileTaskQueue* queue) override;
48 void CheckForCompletedTasks() override;
49 ResourceFormat GetResourceFormat() const override;
50 bool GetResourceRequiresSwizzle() const override;
52 // Overridden from TileTaskClient:
53 scoped_ptr<RasterBuffer> AcquireBufferForRaster(
54 const Resource* resource,
55 uint64_t resource_content_id,
56 uint64_t previous_content_id) override;
57 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override;
59 private:
60 struct RasterTaskState {
61 class TaskComparator {
62 public:
63 explicit TaskComparator(const RasterTask* task) : task_(task) {}
65 bool operator()(const RasterTaskState& state) const {
66 return state.task == task_;
69 private:
70 const RasterTask* task_;
73 typedef std::vector<RasterTaskState> Vector;
75 RasterTaskState(RasterTask* task, const TaskSetCollection& task_sets);
77 enum { UNSCHEDULED, SCHEDULED, UPLOADING, COMPLETED } type;
78 RasterTask* task;
79 TaskSetCollection task_sets;
82 typedef std::deque<scoped_refptr<RasterTask>> RasterTaskDeque;
84 PixelBufferTileTaskWorkerPool(base::SequencedTaskRunner* task_runner,
85 TaskGraphRunner* task_graph_runner,
86 ContextProvider* context_provider,
87 ResourceProvider* resource_provider,
88 size_t max_transfer_buffer_usage_bytes);
90 void OnTaskSetFinished(TaskSet task_set);
91 void FlushUploads();
92 void CheckForCompletedUploads();
93 void CheckForCompletedRasterTasks();
94 void ScheduleMoreTasks();
95 size_t PendingRasterTaskCount() const;
96 TaskSetCollection PendingTasks() const;
97 void CheckForCompletedRasterizerTasks();
99 const char* StateName() const;
100 scoped_refptr<base::trace_event::ConvertableToTraceFormat> StateAsValue()
101 const;
102 void ThrottleStateAsValueInto(
103 base::trace_event::TracedValue* throttle_state) const;
105 scoped_refptr<base::SequencedTaskRunner> task_runner_;
106 TaskGraphRunner* task_graph_runner_;
107 const NamespaceToken namespace_token_;
108 TileTaskRunnerClient* client_;
109 ContextProvider* context_provider_;
110 ResourceProvider* resource_provider_;
112 bool shutdown_;
114 TileTaskQueue raster_tasks_;
115 RasterTaskState::Vector raster_task_states_;
116 RasterTaskDeque raster_tasks_with_pending_upload_;
117 RasterTask::Vector completed_raster_tasks_;
118 TileTask::Vector completed_image_decode_tasks_;
120 size_t scheduled_raster_task_count_;
121 size_t task_counts_[kNumberOfTaskSets];
122 size_t bytes_pending_upload_;
123 size_t max_bytes_pending_upload_;
124 bool has_performed_uploads_since_last_flush_;
126 TaskSetCollection should_notify_client_if_no_tasks_are_pending_;
127 TaskSetCollection task_set_finished_tasks_pending_;
129 DelayedUniqueNotifier check_for_completed_raster_task_notifier_;
131 scoped_refptr<TileTask> task_set_finished_tasks_[kNumberOfTaskSets];
133 // Task graph used when scheduling tasks and vector used to gather
134 // completed tasks.
135 TaskGraph graph_;
136 Task::Vector completed_tasks_;
138 base::WeakPtrFactory<PixelBufferTileTaskWorkerPool>
139 task_set_finished_weak_ptr_factory_;
141 DISALLOW_COPY_AND_ASSIGN(PixelBufferTileTaskWorkerPool);
144 } // namespace cc
146 #endif // CC_RASTER_PIXEL_BUFFER_TILE_TASK_WORKER_POOL_H_