Chromium Code Reviews| 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 CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
| 6 #define CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 6 #define CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #if defined(ENABLE_GPU) | 9 #if defined(ENABLE_GPU) |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/id_map.h" | 14 #include "base/id_map.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "content/common/content_export.h" | |
| 16 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 17 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 17 #include "gpu/command_buffer/common/constants.h" | 18 #include "gpu/command_buffer/common/constants.h" |
| 18 #include "gpu/command_buffer/service/command_buffer_service.h" | 19 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 19 #include "gpu/command_buffer/service/context_group.h" | 20 #include "gpu/command_buffer/service/context_group.h" |
| 20 #include "gpu/command_buffer/service/gpu_scheduler.h" | 21 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 21 #include "ipc/ipc_channel.h" | 22 #include "ipc/ipc_channel.h" |
| 22 #include "ipc/ipc_message.h" | 23 #include "ipc/ipc_message.h" |
| 23 #include "ui/gfx/gl/gl_context.h" | 24 #include "ui/gfx/gl/gl_context.h" |
| 24 #include "ui/gfx/gl/gl_surface.h" | 25 #include "ui/gfx/gl/gl_surface.h" |
| 25 #include "ui/gfx/gl/gpu_preference.h" | 26 #include "ui/gfx/gl/gpu_preference.h" |
| 26 #include "ui/gfx/native_widget_types.h" | 27 #include "ui/gfx/native_widget_types.h" |
| 27 #include "ui/gfx/size.h" | 28 #include "ui/gfx/size.h" |
| 28 #include "ui/gfx/surface/transport_dib.h" | 29 #include "ui/gfx/surface/transport_dib.h" |
| 29 | 30 |
| 30 #if defined(OS_MACOSX) | 31 #if defined(OS_MACOSX) |
| 31 #include "ui/gfx/surface/accelerated_surface_mac.h" | 32 #include "ui/gfx/surface/accelerated_surface_mac.h" |
| 32 #endif | 33 #endif |
| 33 | 34 |
| 34 class GpuChannel; | 35 class GpuChannel; |
| 36 class GpuMemoryAllocation; | |
| 35 class GpuWatchdog; | 37 class GpuWatchdog; |
| 36 | 38 |
| 37 class GpuCommandBufferStub | 39 class CONTENT_EXPORT GpuCommandBufferStubBase { |
|
nduca
2012/02/01 00:01:17
Put a comment above this class explaining that exp
| |
| 40 public: | |
| 41 struct CONTENT_EXPORT SurfaceState { | |
| 42 int32 surface_id; | |
| 43 bool visible; | |
| 44 base::TimeTicks last_used_time; | |
| 45 | |
| 46 SurfaceState(int32 surface_id, | |
| 47 bool visible, | |
| 48 base::TimeTicks last_used_time); | |
| 49 }; | |
| 50 | |
| 51 public: | |
| 52 virtual ~GpuCommandBufferStubBase() {} | |
| 53 | |
| 54 // Null if surface_id == 0. | |
|
nduca
2012/02/01 00:01:17
Null if this is an offscreen commandbuffer. surfac
| |
| 55 virtual SurfaceState* surface_state() = 0; | |
| 56 | |
| 57 // This stubs' surface_id should *not* be in the affected_surface_ids list | |
| 58 virtual const std::vector<int32>& affected_surface_ids() = 0; | |
| 59 | |
| 60 virtual void SendMemoryAllocationToProxy( | |
| 61 const GpuMemoryAllocation& allocation) = 0; | |
| 62 }; | |
| 63 | |
| 64 class CONTENT_EXPORT GpuCommandBufferStub | |
| 38 : public IPC::Channel::Listener, | 65 : public IPC::Channel::Listener, |
| 39 public IPC::Message::Sender, | 66 public IPC::Message::Sender, |
| 67 public GpuCommandBufferStubBase, | |
| 40 public base::SupportsWeakPtr<GpuCommandBufferStub> { | 68 public base::SupportsWeakPtr<GpuCommandBufferStub> { |
| 41 public: | 69 public: |
| 42 GpuCommandBufferStub( | 70 GpuCommandBufferStub( |
| 43 GpuChannel* channel, | 71 GpuChannel* channel, |
| 44 GpuCommandBufferStub* share_group, | 72 GpuCommandBufferStub* share_group, |
| 45 gfx::PluginWindowHandle handle, | 73 gfx::PluginWindowHandle handle, |
| 46 const gfx::Size& size, | 74 const gfx::Size& size, |
| 47 const gpu::gles2::DisallowedFeatures& disallowed_features, | 75 const gpu::gles2::DisallowedFeatures& disallowed_features, |
| 48 const std::string& allowed_extensions, | 76 const std::string& allowed_extensions, |
| 49 const std::vector<int32>& attribs, | 77 const std::vector<int32>& attribs, |
| 50 gfx::GpuPreference gpu_preference, | 78 gfx::GpuPreference gpu_preference, |
| 51 int32 route_id, | 79 int32 route_id, |
| 52 int32 surface_id, | 80 int32 surface_id, |
| 53 GpuWatchdog* watchdog, | 81 GpuWatchdog* watchdog, |
| 54 bool software); | 82 bool software); |
| 55 | 83 |
| 56 virtual ~GpuCommandBufferStub(); | 84 virtual ~GpuCommandBufferStub(); |
| 57 | 85 |
| 58 // IPC::Channel::Listener implementation: | 86 // IPC::Channel::Listener implementation: |
| 59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 87 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 60 | 88 |
| 61 // IPC::Message::Sender implementation: | 89 // IPC::Message::Sender implementation: |
| 62 virtual bool Send(IPC::Message* msg) OVERRIDE; | 90 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 63 | 91 |
| 92 // GpuCommandBufferStubBase implementation: | |
| 93 virtual GpuCommandBufferStubBase::SurfaceState* surface_state() OVERRIDE; | |
| 94 // affected_surface_ids refers to others stubs' surfaces. This stubs' | |
|
nduca
2012/02/01 00:01:17
space between methods.
Change comment so that it
| |
| 95 // surface_id is found via surface state | |
| 96 virtual const std::vector<int32>& affected_surface_ids() OVERRIDE; | |
| 97 virtual void SendMemoryAllocationToProxy( | |
| 98 const GpuMemoryAllocation& allocation) OVERRIDE; | |
| 99 | |
| 100 | |
| 64 // Whether this command buffer can currently handle IPC messages. | 101 // Whether this command buffer can currently handle IPC messages. |
| 65 bool IsScheduled(); | 102 bool IsScheduled(); |
| 66 | 103 |
| 67 // Whether this command buffer needs to be polled again in the future. | 104 // Whether this command buffer needs to be polled again in the future. |
| 68 bool HasMoreWork(); | 105 bool HasMoreWork(); |
| 69 | 106 |
| 70 // Set the swap interval according to the command line. | 107 // Set the swap interval according to the command line. |
| 71 void SetSwapInterval(); | 108 void SetSwapInterval(); |
| 72 | 109 |
| 73 gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 110 gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
| 74 gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } | 111 gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } |
| 75 | 112 |
| 76 // Identifies the target surface. | 113 // Identifies the target surface. |
| 77 int32 surface_id() const { return surface_id_; } | 114 int32 surface_id() const { return (surface_state_.get()) ? |
|
nduca
2012/02/01 00:01:17
newline after the {
maybe move to cpp
| |
| 115 surface_state_->surface_id : 0; } | |
| 78 | 116 |
| 79 // Identifies the various GpuCommandBufferStubs in the GPU process belonging | 117 // Identifies the various GpuCommandBufferStubs in the GPU process belonging |
| 80 // to the same renderer process. | 118 // to the same renderer process. |
| 81 int32 route_id() const { return route_id_; } | 119 int32 route_id() const { return route_id_; } |
| 82 | 120 |
| 83 gfx::GpuPreference gpu_preference() { return gpu_preference_; } | 121 gfx::GpuPreference gpu_preference() { return gpu_preference_; } |
| 84 | 122 |
| 85 // Sends a message to the console. | 123 // Sends a message to the console. |
| 86 void SendConsoleMessage(int32 id, const std::string& message); | 124 void SendConsoleMessage(int32 id, const std::string& message); |
| 87 | 125 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 | 172 |
| 135 gfx::PluginWindowHandle handle_; | 173 gfx::PluginWindowHandle handle_; |
| 136 gfx::Size initial_size_; | 174 gfx::Size initial_size_; |
| 137 gpu::gles2::DisallowedFeatures disallowed_features_; | 175 gpu::gles2::DisallowedFeatures disallowed_features_; |
| 138 std::string allowed_extensions_; | 176 std::string allowed_extensions_; |
| 139 std::vector<int32> requested_attribs_; | 177 std::vector<int32> requested_attribs_; |
| 140 gfx::GpuPreference gpu_preference_; | 178 gfx::GpuPreference gpu_preference_; |
| 141 int32 route_id_; | 179 int32 route_id_; |
| 142 bool software_; | 180 bool software_; |
| 143 uint32 last_flush_count_; | 181 uint32 last_flush_count_; |
| 182 scoped_ptr<GpuCommandBufferStubBase::SurfaceState> surface_state_; | |
| 183 std::vector<int32> affected_surface_ids_; | |
| 144 | 184 |
| 145 // Identifies the window for the rendering results on the browser side. | 185 // Identifies the window for the rendering results on the browser side. |
| 146 int32 surface_id_; | 186 int32 surface_id_; |
|
nduca
2012/02/01 00:01:17
Are you deleting this? Looks like you've gotten 99
| |
| 147 | 187 |
| 148 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 188 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
| 149 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | 189 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
| 150 scoped_ptr<gpu::GpuScheduler> scheduler_; | 190 scoped_ptr<gpu::GpuScheduler> scheduler_; |
| 151 scoped_refptr<gfx::GLContext> context_; | 191 scoped_refptr<gfx::GLContext> context_; |
| 152 scoped_refptr<gfx::GLSurface> surface_; | 192 scoped_refptr<gfx::GLSurface> surface_; |
| 153 | 193 |
| 154 // SetParent may be called before Initialize, in which case we need to keep | 194 // SetParent may be called before Initialize, in which case we need to keep |
| 155 // around the parent stub, so that Initialize can set the parent correctly. | 195 // around the parent stub, so that Initialize can set the parent correctly. |
| 156 base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; | 196 base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; |
| 157 uint32 parent_texture_for_initialization_; | 197 uint32 parent_texture_for_initialization_; |
| 158 | 198 |
| 159 GpuWatchdog* watchdog_; | 199 GpuWatchdog* watchdog_; |
| 160 | 200 |
| 161 // Zero or more video decoders owned by this stub, keyed by their | 201 // Zero or more video decoders owned by this stub, keyed by their |
| 162 // decoder_route_id. | 202 // decoder_route_id. |
| 163 IDMap<GpuVideoDecodeAccelerator, IDMapOwnPointer> video_decoders_; | 203 IDMap<GpuVideoDecodeAccelerator, IDMapOwnPointer> video_decoders_; |
| 164 | 204 |
| 165 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | 205 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); |
| 166 }; | 206 }; |
| 167 | 207 |
| 168 #endif // defined(ENABLE_GPU) | 208 #endif // defined(ENABLE_GPU) |
| 169 | 209 |
| 170 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 210 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
| OLD | NEW |