| 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_TESTS_GL_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/containers/scoped_ptr_hash_map.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "gpu/command_buffer/client/gpu_control.h" |
| 10 #include "gpu/command_buffer/service/feature_info.h" | 12 #include "gpu/command_buffer/service/feature_info.h" |
| 11 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
| 12 | 14 |
| 13 namespace gfx { | 15 namespace gfx { |
| 14 | 16 |
| 15 class GLContext; | 17 class GLContext; |
| 16 class GLShareGroup; | 18 class GLShareGroup; |
| 17 class GLSurface; | 19 class GLSurface; |
| 18 | 20 |
| 19 } | 21 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 32 class MailboxManager; | 34 class MailboxManager; |
| 33 class GLES2Decoder; | 35 class GLES2Decoder; |
| 34 class GLES2CmdHelper; | 36 class GLES2CmdHelper; |
| 35 class GLES2Implementation; | 37 class GLES2Implementation; |
| 36 class ImageFactory; | 38 class ImageFactory; |
| 37 class ImageManager; | 39 class ImageManager; |
| 38 class ShareGroup; | 40 class ShareGroup; |
| 39 | 41 |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 class GLManager { | 44 class GLManager : private GpuControl { |
| 43 public: | 45 public: |
| 44 struct Options { | 46 struct Options { |
| 45 Options(); | 47 Options(); |
| 46 // The size of the backbuffer. | 48 // The size of the backbuffer. |
| 47 gfx::Size size; | 49 gfx::Size size; |
| 48 // If not null will share resources with this context. | 50 // If not null will share resources with this context. |
| 49 GLManager* share_group_manager; | 51 GLManager* share_group_manager; |
| 50 // If not null will share a mailbox manager with this context. | 52 // If not null will share a mailbox manager with this context. |
| 51 GLManager* share_mailbox_manager; | 53 GLManager* share_mailbox_manager; |
| 52 // If not null will create a virtual manager based on this context. | 54 // If not null will create a virtual manager based on this context. |
| 53 GLManager* virtual_manager; | 55 GLManager* virtual_manager; |
| 54 // Whether or not glBindXXX generates a resource. | 56 // Whether or not glBindXXX generates a resource. |
| 55 bool bind_generates_resource; | 57 bool bind_generates_resource; |
| 56 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs. | 58 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs. |
| 57 bool lose_context_when_out_of_memory; | 59 bool lose_context_when_out_of_memory; |
| 58 // Whether or not it's ok to lose the context. | 60 // Whether or not it's ok to lose the context. |
| 59 bool context_lost_allowed; | 61 bool context_lost_allowed; |
| 60 // Image manager to be used. | 62 // Image manager to be used. |
| 61 gles2::ImageManager* image_manager; | 63 gles2::ImageManager* image_manager; |
| 62 // GpuMemoryBuffer factory to be used. | 64 // GpuMemoryBuffer factory to be used. |
| 63 GpuMemoryBufferFactory* gpu_memory_buffer_factory; | 65 GpuMemoryBufferFactory* gpu_memory_buffer_factory; |
| 64 }; | 66 }; |
| 65 GLManager(); | 67 GLManager(); |
| 66 ~GLManager(); | 68 virtual ~GLManager(); |
| 67 | 69 |
| 68 void Initialize(const Options& options); | 70 void Initialize(const Options& options); |
| 69 void Destroy(); | 71 void Destroy(); |
| 70 | 72 |
| 71 void MakeCurrent(); | 73 void MakeCurrent(); |
| 72 | 74 |
| 73 void SetSurface(gfx::GLSurface* surface); | 75 void SetSurface(gfx::GLSurface* surface); |
| 74 | 76 |
| 75 gles2::GLES2Decoder* decoder() const { | 77 gles2::GLES2Decoder* decoder() const { |
| 76 return decoder_.get(); | 78 return decoder_.get(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 87 gles2::GLES2Implementation* gles2_implementation() const { | 89 gles2::GLES2Implementation* gles2_implementation() const { |
| 88 return gles2_implementation_.get(); | 90 return gles2_implementation_.get(); |
| 89 } | 91 } |
| 90 | 92 |
| 91 gfx::GLContext* context() { | 93 gfx::GLContext* context() { |
| 92 return context_.get(); | 94 return context_.get(); |
| 93 } | 95 } |
| 94 | 96 |
| 95 const gpu::gles2::FeatureInfo::Workarounds& workarounds() const; | 97 const gpu::gles2::FeatureInfo::Workarounds& workarounds() const; |
| 96 | 98 |
| 99 // GpuControl implementation. |
| 100 virtual Capabilities GetCapabilities() OVERRIDE; |
| 101 virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(size_t width, |
| 102 size_t height, |
| 103 unsigned internalformat, |
| 104 int32* id) OVERRIDE; |
| 105 virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE; |
| 106 virtual uint32 InsertSyncPoint() OVERRIDE; |
| 107 virtual void SignalSyncPoint(uint32 sync_point, |
| 108 const base::Closure& callback) OVERRIDE; |
| 109 virtual void SignalQuery(uint32 query, |
| 110 const base::Closure& callback) OVERRIDE; |
| 111 virtual void SetSurfaceVisible(bool visible) OVERRIDE; |
| 112 virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) OVERRIDE; |
| 113 virtual void Echo(const base::Closure& callback) OVERRIDE; |
| 114 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE; |
| 115 |
| 97 private: | 116 private: |
| 98 void PumpCommands(); | 117 void PumpCommands(); |
| 99 bool GetBufferChanged(int32 transfer_buffer_id); | 118 bool GetBufferChanged(int32 transfer_buffer_id); |
| 100 void SetupBaseContext(); | 119 void SetupBaseContext(); |
| 101 | 120 |
| 102 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 121 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
| 103 scoped_refptr<gfx::GLShareGroup> share_group_; | 122 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 104 scoped_ptr<CommandBufferService> command_buffer_; | 123 scoped_ptr<CommandBufferService> command_buffer_; |
| 105 scoped_ptr<GpuControlService> gpu_control_; | 124 scoped_ptr<GpuControlService> gpu_control_service_; |
| 106 scoped_ptr<gles2::GLES2Decoder> decoder_; | 125 scoped_ptr<gles2::GLES2Decoder> decoder_; |
| 107 scoped_ptr<GpuScheduler> gpu_scheduler_; | 126 scoped_ptr<GpuScheduler> gpu_scheduler_; |
| 108 scoped_refptr<gfx::GLSurface> surface_; | 127 scoped_refptr<gfx::GLSurface> surface_; |
| 109 scoped_refptr<gfx::GLContext> context_; | 128 scoped_refptr<gfx::GLContext> context_; |
| 110 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; | 129 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; |
| 111 scoped_ptr<TransferBuffer> transfer_buffer_; | 130 scoped_ptr<TransferBuffer> transfer_buffer_; |
| 112 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; | 131 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; |
| 113 bool context_lost_allowed_; | 132 bool context_lost_allowed_; |
| 114 | 133 |
| 134 // Client GpuControl implementation. |
| 135 GpuMemoryBufferFactory* gpu_memory_buffer_factory_; |
| 136 base::ScopedPtrHashMap<int32, gfx::GpuMemoryBuffer> memory_buffers_; |
| 137 |
| 115 // Used on Android to virtualize GL for all contexts. | 138 // Used on Android to virtualize GL for all contexts. |
| 116 static int use_count_; | 139 static int use_count_; |
| 117 static scoped_refptr<gfx::GLShareGroup>* base_share_group_; | 140 static scoped_refptr<gfx::GLShareGroup>* base_share_group_; |
| 118 static scoped_refptr<gfx::GLSurface>* base_surface_; | 141 static scoped_refptr<gfx::GLSurface>* base_surface_; |
| 119 static scoped_refptr<gfx::GLContext>* base_context_; | 142 static scoped_refptr<gfx::GLContext>* base_context_; |
| 120 }; | 143 }; |
| 121 | 144 |
| 122 } // namespace gpu | 145 } // namespace gpu |
| 123 | 146 |
| 124 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ | 147 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
| OLD | NEW |