| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_IN_PROCESS_COMMAND_BUFFER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "gpu/command_buffer/common/command_buffer.h" | 16 #include "gpu/command_buffer/common/command_buffer.h" |
| 17 #include "gpu/gpu_export.h" | 17 #include "gpu/gpu_export.h" |
| 18 #include "ui/gfx/gpu_memory_buffer.h" | 18 #include "ui/gfx/gpu_memory_buffer.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 20 #include "ui/gl/gl_surface.h" |
| 20 #include "ui/gl/gpu_preference.h" | 21 #include "ui/gl/gpu_preference.h" |
| 21 | 22 |
| 23 namespace base { |
| 24 class SequenceChecker; |
| 25 } |
| 26 |
| 22 namespace gfx { | 27 namespace gfx { |
| 23 class GLContext; | 28 class GLContext; |
| 24 class GLImage; | 29 class GLImage; |
| 25 class GLSurface; | 30 class GLSurface; |
| 26 class Size; | 31 class Size; |
| 27 } | 32 } |
| 28 | 33 |
| 29 namespace gpu { | 34 namespace gpu { |
| 30 | 35 |
| 31 namespace gles2 { | 36 namespace gles2 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 50 // The callback will be called from different client threads. After the | 55 // The callback will be called from different client threads. After the |
| 51 // callback is issued, the client is expected to eventually call | 56 // callback is issued, the client is expected to eventually call |
| 52 // ProcessGpuWorkOnCurrentThread(). The latter cannot be called from different | 57 // ProcessGpuWorkOnCurrentThread(). The latter cannot be called from different |
| 53 // threads. | 58 // threads. |
| 54 // The callback needs to be set before any context is created. | 59 // The callback needs to be set before any context is created. |
| 55 static void SetScheduleCallback(const base::Closure& callback); | 60 static void SetScheduleCallback(const base::Closure& callback); |
| 56 static void ProcessGpuWorkOnCurrentThread(); | 61 static void ProcessGpuWorkOnCurrentThread(); |
| 57 | 62 |
| 58 static void EnableVirtualizedContext(); | 63 static void EnableVirtualizedContext(); |
| 59 | 64 |
| 60 bool Initialize(bool is_offscreen, | 65 // If |surface| is not NULL, use it directly; in this case, the command |
| 66 // buffer gpu thread must be the same as the client thread. Otherwise create |
| 67 // a new GLSurface. |
| 68 bool Initialize(scoped_refptr<gfx::GLSurface> surface, |
| 69 bool is_offscreen, |
| 61 bool share_resources, | 70 bool share_resources, |
| 62 gfx::AcceleratedWidget window, | 71 gfx::AcceleratedWidget window, |
| 63 const gfx::Size& size, | 72 const gfx::Size& size, |
| 64 const char* allowed_extensions, | 73 const char* allowed_extensions, |
| 65 const std::vector<int32>& attribs, | 74 const std::vector<int32>& attribs, |
| 66 gfx::GpuPreference gpu_preference, | 75 gfx::GpuPreference gpu_preference, |
| 67 const base::Closure& context_lost_callback, | 76 const base::Closure& context_lost_callback, |
| 68 unsigned int share_group_id); | 77 unsigned int share_group_id); |
| 69 void Destroy(); | 78 void Destroy(); |
| 70 void SignalSyncPoint(unsigned sync_point, | 79 void SignalSyncPoint(unsigned sync_point, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void FlushOnGpuThread(int32 put_offset); | 120 void FlushOnGpuThread(int32 put_offset); |
| 112 void CreateImageOnGpuThread(gfx::GpuMemoryBufferHandle buffer, | 121 void CreateImageOnGpuThread(gfx::GpuMemoryBufferHandle buffer, |
| 113 gfx::Size size, | 122 gfx::Size size, |
| 114 unsigned int image_id); | 123 unsigned int image_id); |
| 115 void RemoveImageOnGpuThread(unsigned int image_id); | 124 void RemoveImageOnGpuThread(unsigned int image_id); |
| 116 bool MakeCurrent(); | 125 bool MakeCurrent(); |
| 117 bool IsContextLost(); | 126 bool IsContextLost(); |
| 118 base::Closure WrapCallback(const base::Closure& callback); | 127 base::Closure WrapCallback(const base::Closure& callback); |
| 119 State GetStateFast(); | 128 State GetStateFast(); |
| 120 void QueueTask(const base::Closure& task) { queue_->QueueTask(task); } | 129 void QueueTask(const base::Closure& task) { queue_->QueueTask(task); } |
| 130 void CheckSequencedThread(); |
| 121 | 131 |
| 122 // Callbacks: | 132 // Callbacks: |
| 123 void OnContextLost(); | 133 void OnContextLost(); |
| 124 void OnResizeView(gfx::Size size, float scale_factor); | 134 void OnResizeView(gfx::Size size, float scale_factor); |
| 125 bool GetBufferChanged(int32 transfer_buffer_id); | 135 bool GetBufferChanged(int32 transfer_buffer_id); |
| 126 void PumpCommands(); | 136 void PumpCommands(); |
| 127 | 137 |
| 128 // Members accessed on the gpu thread (possibly with the exception of | 138 // Members accessed on the gpu thread (possibly with the exception of |
| 129 // creation): | 139 // creation): |
| 130 bool context_lost_; | 140 bool context_lost_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 142 int32 last_put_offset_; | 152 int32 last_put_offset_; |
| 143 | 153 |
| 144 // Accessed on both threads: | 154 // Accessed on both threads: |
| 145 scoped_ptr<CommandBuffer> command_buffer_; | 155 scoped_ptr<CommandBuffer> command_buffer_; |
| 146 base::Lock command_buffer_lock_; | 156 base::Lock command_buffer_lock_; |
| 147 base::WaitableEvent flush_event_; | 157 base::WaitableEvent flush_event_; |
| 148 scoped_ptr<SchedulerClient> queue_; | 158 scoped_ptr<SchedulerClient> queue_; |
| 149 State state_after_last_flush_; | 159 State state_after_last_flush_; |
| 150 base::Lock state_after_last_flush_lock_; | 160 base::Lock state_after_last_flush_lock_; |
| 151 | 161 |
| 162 // Only used with explicit scheduling and the gpu thread is the same as |
| 163 // the client thread. |
| 164 scoped_ptr<base::SequenceChecker> sequence_checker_; |
| 165 |
| 152 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); | 166 DISALLOW_COPY_AND_ASSIGN(InProcessCommandBuffer); |
| 153 }; | 167 }; |
| 154 | 168 |
| 155 } // namespace gpu | 169 } // namespace gpu |
| 156 | 170 |
| 157 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 171 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
| OLD | NEW |