OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/atomic_ref_count.h" | 10 #include "base/atomic_ref_count.h" |
11 #include "base/atomicops.h" | 11 #include "base/atomicops.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "gpu/command_buffer/common/command_buffer.h" | |
19 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 18 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
20 #include "gpu/command_buffer/service/cmd_parser.h" | 19 #include "gpu/command_buffer/service/cmd_parser.h" |
| 20 #include "gpu/command_buffer/service/command_buffer_service.h" |
21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
22 #include "gpu/gpu_export.h" | 22 #include "gpu/gpu_export.h" |
23 | 23 |
24 namespace gfx { | 24 namespace gfx { |
25 class GLFence; | 25 class GLFence; |
26 } | 26 } |
27 | 27 |
28 namespace gpu { | 28 namespace gpu { |
29 | 29 |
30 class PreemptionFlag | 30 class PreemptionFlag |
(...skipping 14 matching lines...) Expand all Loading... |
45 }; | 45 }; |
46 | 46 |
47 // This class schedules commands that have been flushed. They are received via | 47 // This class schedules commands that have been flushed. They are received via |
48 // a command buffer and forwarded to a command parser. TODO(apatrick): This | 48 // a command buffer and forwarded to a command parser. TODO(apatrick): This |
49 // class should not know about the decoder. Do not add additional dependencies | 49 // class should not know about the decoder. Do not add additional dependencies |
50 // on it. | 50 // on it. |
51 class GPU_EXPORT GpuScheduler | 51 class GPU_EXPORT GpuScheduler |
52 : NON_EXPORTED_BASE(public CommandBufferEngine), | 52 : NON_EXPORTED_BASE(public CommandBufferEngine), |
53 public base::SupportsWeakPtr<GpuScheduler> { | 53 public base::SupportsWeakPtr<GpuScheduler> { |
54 public: | 54 public: |
55 GpuScheduler(CommandBuffer* command_buffer, | 55 GpuScheduler(CommandBufferServiceBase* command_buffer, |
56 AsyncAPIInterface* handler, | 56 AsyncAPIInterface* handler, |
57 gles2::GLES2Decoder* decoder); | 57 gles2::GLES2Decoder* decoder); |
58 | 58 |
59 virtual ~GpuScheduler(); | 59 virtual ~GpuScheduler(); |
60 | 60 |
61 void PutChanged(); | 61 void PutChanged(); |
62 | 62 |
63 void SetPreemptByFlag(scoped_refptr<PreemptionFlag> flag) { | 63 void SetPreemptByFlag(scoped_refptr<PreemptionFlag> flag) { |
64 preemption_flag_ = flag; | 64 preemption_flag_ = flag; |
65 } | 65 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 bool IsPreempted(); | 107 bool IsPreempted(); |
108 | 108 |
109 private: | 109 private: |
110 // Artificially reschedule if the scheduler is still unscheduled after a | 110 // Artificially reschedule if the scheduler is still unscheduled after a |
111 // timeout. | 111 // timeout. |
112 void RescheduleTimeOut(); | 112 void RescheduleTimeOut(); |
113 | 113 |
114 // The GpuScheduler holds a weak reference to the CommandBuffer. The | 114 // The GpuScheduler holds a weak reference to the CommandBuffer. The |
115 // CommandBuffer owns the GpuScheduler and holds a strong reference to it | 115 // CommandBuffer owns the GpuScheduler and holds a strong reference to it |
116 // through the ProcessCommands callback. | 116 // through the ProcessCommands callback. |
117 CommandBuffer* command_buffer_; | 117 CommandBufferServiceBase* command_buffer_; |
118 | 118 |
119 // The parser uses this to execute commands. | 119 // The parser uses this to execute commands. |
120 AsyncAPIInterface* handler_; | 120 AsyncAPIInterface* handler_; |
121 | 121 |
122 // Does not own decoder. TODO(apatrick): The GpuScheduler shouldn't need a | 122 // Does not own decoder. TODO(apatrick): The GpuScheduler shouldn't need a |
123 // pointer to the decoder, it is only used to initialize the CommandParser, | 123 // pointer to the decoder, it is only used to initialize the CommandParser, |
124 // which could be an argument to the constructor, and to determine the | 124 // which could be an argument to the constructor, and to determine the |
125 // reason for context lost. | 125 // reason for context lost. |
126 gles2::GLES2Decoder* decoder_; | 126 gles2::GLES2Decoder* decoder_; |
127 | 127 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // If non-NULL and |preemption_flag_->IsSet()|, exit PutChanged early. | 159 // If non-NULL and |preemption_flag_->IsSet()|, exit PutChanged early. |
160 scoped_refptr<PreemptionFlag> preemption_flag_; | 160 scoped_refptr<PreemptionFlag> preemption_flag_; |
161 bool was_preempted_; | 161 bool was_preempted_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(GpuScheduler); | 163 DISALLOW_COPY_AND_ASSIGN(GpuScheduler); |
164 }; | 164 }; |
165 | 165 |
166 } // namespace gpu | 166 } // namespace gpu |
167 | 167 |
168 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 168 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
OLD | NEW |