| 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 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 namespace gpu { | 41 namespace gpu { |
| 42 namespace gles2 { | 42 namespace gles2 { |
| 43 class MailboxManager; | 43 class MailboxManager; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 // This Base class is used to expose methods of GpuCommandBufferStub used for | 47 // This Base class is used to expose methods of GpuCommandBufferStub used for |
| 48 // testability. | 48 // testability. |
| 49 class CONTENT_EXPORT GpuCommandBufferStubBase { | 49 class CONTENT_EXPORT GpuCommandBufferStubBase { |
| 50 public: | 50 public: |
| 51 struct CONTENT_EXPORT SurfaceState { | 51 struct CONTENT_EXPORT MemoryManagerState { |
| 52 int32 surface_id; | 52 // Offscreen commandbuffers will not have a surface. |
| 53 bool has_surface; |
| 53 bool visible; | 54 bool visible; |
| 55 bool client_has_memory_allocation_changed_callback; |
| 56 // The last used time is determined by the last time that visibility |
| 57 // was changed. |
| 54 base::TimeTicks last_used_time; | 58 base::TimeTicks last_used_time; |
| 55 | 59 |
| 56 SurfaceState(int32 surface_id, | 60 MemoryManagerState( |
| 57 bool visible, | 61 bool has_surface, |
| 58 base::TimeTicks last_used_time); | 62 bool visible, |
| 63 base::TimeTicks last_used_time); |
| 59 }; | 64 }; |
| 60 | 65 |
| 61 public: | 66 public: |
| 62 virtual ~GpuCommandBufferStubBase() {} | 67 virtual ~GpuCommandBufferStubBase() {} |
| 63 | 68 |
| 64 // Will not have surface state if this is an offscreen commandbuffer. | 69 virtual const MemoryManagerState& memory_manager_state() const = 0; |
| 65 virtual bool client_has_memory_allocation_changed_callback() const = 0; | |
| 66 virtual bool has_surface_state() const = 0; | |
| 67 virtual const SurfaceState& surface_state() const = 0; | |
| 68 | 70 |
| 69 virtual gfx::Size GetSurfaceSize() const = 0; | 71 virtual gfx::Size GetSurfaceSize() const = 0; |
| 70 | 72 |
| 71 virtual bool IsInSameContextShareGroup( | 73 virtual bool IsInSameContextShareGroup( |
| 72 const GpuCommandBufferStubBase& other) const = 0; | 74 const GpuCommandBufferStubBase& other) const = 0; |
| 73 | 75 |
| 74 virtual void SetMemoryAllocation( | 76 virtual void SetMemoryAllocation( |
| 75 const GpuMemoryAllocation& allocation) = 0; | 77 const GpuMemoryAllocation& allocation) = 0; |
| 76 | 78 |
| 77 virtual bool GetTotalGpuMemory(size_t* bytes) = 0; | 79 virtual bool GetTotalGpuMemory(size_t* bytes) = 0; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 112 |
| 111 virtual ~GpuCommandBufferStub(); | 113 virtual ~GpuCommandBufferStub(); |
| 112 | 114 |
| 113 // IPC::Listener implementation: | 115 // IPC::Listener implementation: |
| 114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 116 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 115 | 117 |
| 116 // IPC::Sender implementation: | 118 // IPC::Sender implementation: |
| 117 virtual bool Send(IPC::Message* msg) OVERRIDE; | 119 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 118 | 120 |
| 119 // GpuCommandBufferStubBase implementation: | 121 // GpuCommandBufferStubBase implementation: |
| 120 virtual bool client_has_memory_allocation_changed_callback() const OVERRIDE; | 122 virtual const GpuCommandBufferStubBase::MemoryManagerState& |
| 121 virtual bool has_surface_state() const OVERRIDE; | 123 memory_manager_state() const OVERRIDE; |
| 122 virtual const GpuCommandBufferStubBase::SurfaceState& surface_state() const | |
| 123 OVERRIDE; | |
| 124 | 124 |
| 125 // Returns surface size. | 125 // Returns surface size. |
| 126 virtual gfx::Size GetSurfaceSize() const OVERRIDE; | 126 virtual gfx::Size GetSurfaceSize() const OVERRIDE; |
| 127 | 127 |
| 128 // Returns true iff |other| is in the same context share group as this stub. | 128 // Returns true iff |other| is in the same context share group as this stub. |
| 129 virtual bool IsInSameContextShareGroup( | 129 virtual bool IsInSameContextShareGroup( |
| 130 const GpuCommandBufferStubBase& other) const OVERRIDE; | 130 const GpuCommandBufferStubBase& other) const OVERRIDE; |
| 131 | 131 |
| 132 // Sets buffer usage depending on Memory Allocation | 132 // Sets buffer usage depending on Memory Allocation |
| 133 virtual void SetMemoryAllocation( | 133 virtual void SetMemoryAllocation( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 146 | 146 |
| 147 // Delay an echo message until the command buffer has been rescheduled. | 147 // Delay an echo message until the command buffer has been rescheduled. |
| 148 void DelayEcho(IPC::Message*); | 148 void DelayEcho(IPC::Message*); |
| 149 | 149 |
| 150 gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 150 gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
| 151 gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } | 151 gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } |
| 152 GpuChannel* channel() const { return channel_; } | 152 GpuChannel* channel() const { return channel_; } |
| 153 | 153 |
| 154 // Identifies the target surface. | 154 // Identifies the target surface. |
| 155 int32 surface_id() const { | 155 int32 surface_id() const { |
| 156 return (surface_state_.get()) ? surface_state_->surface_id : 0; | 156 return surface_id_; |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Identifies the various GpuCommandBufferStubs in the GPU process belonging | 159 // Identifies the various GpuCommandBufferStubs in the GPU process belonging |
| 160 // to the same renderer process. | 160 // to the same renderer process. |
| 161 int32 route_id() const { return route_id_; } | 161 int32 route_id() const { return route_id_; } |
| 162 | 162 |
| 163 gfx::GpuPreference gpu_preference() { return gpu_preference_; } | 163 gfx::GpuPreference gpu_preference() { return gpu_preference_; } |
| 164 | 164 |
| 165 // Sends a message to the console. | 165 // Sends a message to the console. |
| 166 void SendConsoleMessage(int32 id, const std::string& message); | 166 void SendConsoleMessage(int32 id, const std::string& message); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // The group of contexts that share namespaces with this context. | 249 // The group of contexts that share namespaces with this context. |
| 250 scoped_refptr<gpu::gles2::ContextGroup> context_group_; | 250 scoped_refptr<gpu::gles2::ContextGroup> context_group_; |
| 251 | 251 |
| 252 gfx::GLSurfaceHandle handle_; | 252 gfx::GLSurfaceHandle handle_; |
| 253 gfx::Size initial_size_; | 253 gfx::Size initial_size_; |
| 254 gpu::gles2::DisallowedFeatures disallowed_features_; | 254 gpu::gles2::DisallowedFeatures disallowed_features_; |
| 255 std::string allowed_extensions_; | 255 std::string allowed_extensions_; |
| 256 std::vector<int32> requested_attribs_; | 256 std::vector<int32> requested_attribs_; |
| 257 gfx::GpuPreference gpu_preference_; | 257 gfx::GpuPreference gpu_preference_; |
| 258 int32 route_id_; | 258 int32 route_id_; |
| 259 int32 surface_id_; |
| 259 bool software_; | 260 bool software_; |
| 260 bool client_has_memory_allocation_changed_callback_; | |
| 261 uint32 last_flush_count_; | 261 uint32 last_flush_count_; |
| 262 scoped_ptr<GpuCommandBufferStubBase::SurfaceState> surface_state_; | 262 scoped_ptr<MemoryManagerState> memory_manager_state_; |
| 263 | 263 |
| 264 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 264 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
| 265 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | 265 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
| 266 scoped_ptr<gpu::GpuScheduler> scheduler_; | 266 scoped_ptr<gpu::GpuScheduler> scheduler_; |
| 267 scoped_refptr<gfx::GLContext> context_; | 267 scoped_refptr<gfx::GLContext> context_; |
| 268 scoped_refptr<gfx::GLSurface> surface_; | 268 scoped_refptr<gfx::GLSurface> surface_; |
| 269 | 269 |
| 270 // SetParent may be called before Initialize, in which case we need to keep | 270 // SetParent may be called before Initialize, in which case we need to keep |
| 271 // around the parent stub, so that Initialize can set the parent correctly. | 271 // around the parent stub, so that Initialize can set the parent correctly. |
| 272 base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; | 272 base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 290 | 290 |
| 291 scoped_refptr<gpu::RefCountedCounter> preempt_by_counter_; | 291 scoped_refptr<gpu::RefCountedCounter> preempt_by_counter_; |
| 292 | 292 |
| 293 GURL active_url_; | 293 GURL active_url_; |
| 294 size_t active_url_hash_; | 294 size_t active_url_hash_; |
| 295 | 295 |
| 296 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | 296 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); |
| 297 }; | 297 }; |
| 298 | 298 |
| 299 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 299 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
| OLD | NEW |