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 |
| 39 // This Base class is used to expose methods of GpuCommandBufferStub used for | |
| 40 // testability. | |
| 41 class CONTENT_EXPORT GpuCommandBufferStubBase { | |
| 42 public: | |
| 43 struct CONTENT_EXPORT SurfaceState { | |
| 44 int32 surface_id; | |
| 45 bool visible; | |
| 46 base::TimeTicks last_used_time; | |
| 47 | |
| 48 SurfaceState(int32 surface_id, | |
| 49 bool visible, | |
| 50 base::TimeTicks last_used_time); | |
| 51 }; | |
| 52 | |
| 53 public: | |
| 54 virtual ~GpuCommandBufferStubBase() {} | |
| 55 | |
| 56 // Null if this is an offscreen commandbuffer. | |
| 57 virtual SurfaceState* surface_state() = 0; | |
|
jonathan.backer
2012/02/01 19:43:17
Can the surface state be modified? maybe return a
mmocny
2012/02/01 20:44:19
It is modified: last_used_time and visibility are
jonathan.backer
2012/02/01 21:39:14
Inside the Stub, we can use surface_state_ to modi
mmocny
2012/02/01 22:31:08
Done.
| |
| 58 | |
| 59 // This stubs' surface_id should *not* be in the affected_surface_ids list. | |
| 60 virtual const std::vector<int32>& affected_surface_ids() = 0; | |
| 61 | |
| 62 virtual void SendMemoryAllocationToProxy( | |
| 63 const GpuMemoryAllocation& allocation) = 0; | |
|
jonathan.backer
2012/02/01 19:43:17
Not used in this CL. Nix?
mmocny
2012/02/01 20:44:19
It is used by the Manage function. Even though it
| |
| 64 }; | |
| 65 | |
| 37 class GpuCommandBufferStub | 66 class GpuCommandBufferStub |
| 38 : public IPC::Channel::Listener, | 67 : public IPC::Channel::Listener, |
| 39 public IPC::Message::Sender, | 68 public IPC::Message::Sender, |
| 69 public GpuCommandBufferStubBase, | |
| 40 public base::SupportsWeakPtr<GpuCommandBufferStub> { | 70 public base::SupportsWeakPtr<GpuCommandBufferStub> { |
| 41 public: | 71 public: |
| 42 GpuCommandBufferStub( | 72 GpuCommandBufferStub( |
| 43 GpuChannel* channel, | 73 GpuChannel* channel, |
| 44 GpuCommandBufferStub* share_group, | 74 GpuCommandBufferStub* share_group, |
| 45 gfx::PluginWindowHandle handle, | 75 gfx::PluginWindowHandle handle, |
| 46 const gfx::Size& size, | 76 const gfx::Size& size, |
| 47 const gpu::gles2::DisallowedFeatures& disallowed_features, | 77 const gpu::gles2::DisallowedFeatures& disallowed_features, |
| 48 const std::string& allowed_extensions, | 78 const std::string& allowed_extensions, |
| 49 const std::vector<int32>& attribs, | 79 const std::vector<int32>& attribs, |
| 50 gfx::GpuPreference gpu_preference, | 80 gfx::GpuPreference gpu_preference, |
| 51 int32 route_id, | 81 int32 route_id, |
| 52 int32 surface_id, | 82 int32 surface_id, |
| 53 GpuWatchdog* watchdog, | 83 GpuWatchdog* watchdog, |
| 54 bool software); | 84 bool software); |
| 55 | 85 |
| 56 virtual ~GpuCommandBufferStub(); | 86 virtual ~GpuCommandBufferStub(); |
| 57 | 87 |
| 58 // IPC::Channel::Listener implementation: | 88 // IPC::Channel::Listener implementation: |
| 59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 89 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 60 | 90 |
| 61 // IPC::Message::Sender implementation: | 91 // IPC::Message::Sender implementation: |
| 62 virtual bool Send(IPC::Message* msg) OVERRIDE; | 92 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 63 | 93 |
| 94 // GpuCommandBufferStubBase implementation: | |
| 95 virtual GpuCommandBufferStubBase::SurfaceState* surface_state() OVERRIDE; | |
| 96 | |
| 97 // The affected_surface_ids field refers to others stubs' surfaces. This | |
| 98 // stubs' surface_id is found via surface state. | |
| 99 virtual const std::vector<int32>& affected_surface_ids() OVERRIDE; | |
|
jonathan.backer
2012/02/01 19:43:17
Chatted with mmocny offline. It appears that this
| |
| 100 | |
| 101 // Sends memory allocation limits to render process. | |
| 102 virtual void SendMemoryAllocationToProxy( | |
| 103 const GpuMemoryAllocation& allocation) OVERRIDE; | |
| 104 | |
| 64 // Whether this command buffer can currently handle IPC messages. | 105 // Whether this command buffer can currently handle IPC messages. |
| 65 bool IsScheduled(); | 106 bool IsScheduled(); |
| 66 | 107 |
| 67 // Whether this command buffer needs to be polled again in the future. | 108 // Whether this command buffer needs to be polled again in the future. |
| 68 bool HasMoreWork(); | 109 bool HasMoreWork(); |
| 69 | 110 |
| 70 // Set the swap interval according to the command line. | 111 // Set the swap interval according to the command line. |
| 71 void SetSwapInterval(); | 112 void SetSwapInterval(); |
| 72 | 113 |
| 73 gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 114 gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
| 74 gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } | 115 gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } |
| 75 | 116 |
| 76 // Identifies the target surface. | 117 // Identifies the target surface. |
| 77 int32 surface_id() const { return surface_id_; } | 118 int32 surface_id() const; |
|
jonathan.backer
2012/02/01 19:43:17
Why? Doesn't this prevent it from being inlined?
mmocny
2012/02/01 20:44:19
It may prevent it from being inlined (linkers can
jonathan.backer
2012/02/01 21:39:14
It's very trivial, IMHO.
mmocny
2012/02/01 22:31:08
Done.
| |
| 78 | 119 |
| 79 // Identifies the various GpuCommandBufferStubs in the GPU process belonging | 120 // Identifies the various GpuCommandBufferStubs in the GPU process belonging |
| 80 // to the same renderer process. | 121 // to the same renderer process. |
| 81 int32 route_id() const { return route_id_; } | 122 int32 route_id() const { return route_id_; } |
| 82 | 123 |
| 83 gfx::GpuPreference gpu_preference() { return gpu_preference_; } | 124 gfx::GpuPreference gpu_preference() { return gpu_preference_; } |
| 84 | 125 |
| 85 // Sends a message to the console. | 126 // Sends a message to the console. |
| 86 void SendConsoleMessage(int32 id, const std::string& message); | 127 void SendConsoleMessage(int32 id, const std::string& message); |
| 87 | 128 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 | 175 |
| 135 gfx::PluginWindowHandle handle_; | 176 gfx::PluginWindowHandle handle_; |
| 136 gfx::Size initial_size_; | 177 gfx::Size initial_size_; |
| 137 gpu::gles2::DisallowedFeatures disallowed_features_; | 178 gpu::gles2::DisallowedFeatures disallowed_features_; |
| 138 std::string allowed_extensions_; | 179 std::string allowed_extensions_; |
| 139 std::vector<int32> requested_attribs_; | 180 std::vector<int32> requested_attribs_; |
| 140 gfx::GpuPreference gpu_preference_; | 181 gfx::GpuPreference gpu_preference_; |
| 141 int32 route_id_; | 182 int32 route_id_; |
| 142 bool software_; | 183 bool software_; |
| 143 uint32 last_flush_count_; | 184 uint32 last_flush_count_; |
| 144 | 185 scoped_ptr<GpuCommandBufferStubBase::SurfaceState> surface_state_; |
| 145 // Identifies the window for the rendering results on the browser side. | 186 std::vector<int32> affected_surface_ids_; |
| 146 int32 surface_id_; | |
| 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 |