| 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/containers/scoped_ptr_hash_map.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "gpu/command_buffer/client/gpu_control.h" | 11 #include "gpu/command_buffer/client/gpu_control.h" |
| 12 #include "gpu/command_buffer/service/feature_info.h" | 12 #include "gpu/command_buffer/service/feature_info.h" |
| 13 #include "ui/gfx/gpu_memory_buffer.h" |
| 13 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 class GLContext; | 18 class GLContext; |
| 18 class GLShareGroup; | 19 class GLShareGroup; |
| 19 class GLSurface; | 20 class GLSurface; |
| 20 | 21 |
| 21 } | 22 } |
| 22 | 23 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 53 // Whether or not glBindXXX generates a resource. | 54 // Whether or not glBindXXX generates a resource. |
| 54 bool bind_generates_resource; | 55 bool bind_generates_resource; |
| 55 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs. | 56 // Whether or not the context is auto-lost when GL_OUT_OF_MEMORY occurs. |
| 56 bool lose_context_when_out_of_memory; | 57 bool lose_context_when_out_of_memory; |
| 57 // Whether or not it's ok to lose the context. | 58 // Whether or not it's ok to lose the context. |
| 58 bool context_lost_allowed; | 59 bool context_lost_allowed; |
| 59 }; | 60 }; |
| 60 GLManager(); | 61 GLManager(); |
| 61 virtual ~GLManager(); | 62 virtual ~GLManager(); |
| 62 | 63 |
| 64 static scoped_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( |
| 65 const gfx::Size& size, |
| 66 gfx::GpuMemoryBuffer::Format format); |
| 67 |
| 63 void Initialize(const Options& options); | 68 void Initialize(const Options& options); |
| 64 void Destroy(); | 69 void Destroy(); |
| 65 | 70 |
| 66 void MakeCurrent(); | 71 void MakeCurrent(); |
| 67 | 72 |
| 68 void SetSurface(gfx::GLSurface* surface); | 73 void SetSurface(gfx::GLSurface* surface); |
| 69 | 74 |
| 70 gles2::GLES2Decoder* decoder() const { | 75 gles2::GLES2Decoder* decoder() const { |
| 71 return decoder_.get(); | 76 return decoder_.get(); |
| 72 } | 77 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 84 } | 89 } |
| 85 | 90 |
| 86 gfx::GLContext* context() { | 91 gfx::GLContext* context() { |
| 87 return context_.get(); | 92 return context_.get(); |
| 88 } | 93 } |
| 89 | 94 |
| 90 const gpu::gles2::FeatureInfo::Workarounds& workarounds() const; | 95 const gpu::gles2::FeatureInfo::Workarounds& workarounds() const; |
| 91 | 96 |
| 92 // GpuControl implementation. | 97 // GpuControl implementation. |
| 93 virtual Capabilities GetCapabilities() override; | 98 virtual Capabilities GetCapabilities() override; |
| 94 virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(size_t width, | 99 virtual int32 CreateImage(ClientBuffer buffer, |
| 95 size_t height, | 100 size_t width, |
| 96 unsigned internalformat, | 101 size_t height, |
| 97 unsigned usage, | 102 unsigned internalformat) override; |
| 98 int32* id) override; | 103 virtual void DestroyImage(int32 id) override; |
| 99 virtual void DestroyGpuMemoryBuffer(int32 id) override; | 104 virtual int32 CreateGpuMemoryBufferImage(size_t width, |
| 105 size_t height, |
| 106 unsigned internalformat, |
| 107 unsigned usage) override; |
| 100 virtual uint32 InsertSyncPoint() override; | 108 virtual uint32 InsertSyncPoint() override; |
| 101 virtual uint32 InsertFutureSyncPoint() override; | 109 virtual uint32 InsertFutureSyncPoint() override; |
| 102 virtual void RetireSyncPoint(uint32 sync_point) override; | 110 virtual void RetireSyncPoint(uint32 sync_point) override; |
| 103 virtual void SignalSyncPoint(uint32 sync_point, | 111 virtual void SignalSyncPoint(uint32 sync_point, |
| 104 const base::Closure& callback) override; | 112 const base::Closure& callback) override; |
| 105 virtual void SignalQuery(uint32 query, | 113 virtual void SignalQuery(uint32 query, |
| 106 const base::Closure& callback) override; | 114 const base::Closure& callback) override; |
| 107 virtual void SetSurfaceVisible(bool visible) override; | 115 virtual void SetSurfaceVisible(bool visible) override; |
| 108 virtual uint32 CreateStreamTexture(uint32 texture_id) override; | 116 virtual uint32 CreateStreamTexture(uint32 texture_id) override; |
| 109 | 117 |
| 110 private: | 118 private: |
| 111 void PumpCommands(); | 119 void PumpCommands(); |
| 112 bool GetBufferChanged(int32 transfer_buffer_id); | 120 bool GetBufferChanged(int32 transfer_buffer_id); |
| 113 void SetupBaseContext(); | 121 void SetupBaseContext(); |
| 114 | 122 |
| 115 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 123 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
| 116 scoped_refptr<gfx::GLShareGroup> share_group_; | 124 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 117 scoped_ptr<CommandBufferService> command_buffer_; | 125 scoped_ptr<CommandBufferService> command_buffer_; |
| 118 scoped_ptr<gles2::GLES2Decoder> decoder_; | 126 scoped_ptr<gles2::GLES2Decoder> decoder_; |
| 119 scoped_ptr<GpuScheduler> gpu_scheduler_; | 127 scoped_ptr<GpuScheduler> gpu_scheduler_; |
| 120 scoped_refptr<gfx::GLSurface> surface_; | 128 scoped_refptr<gfx::GLSurface> surface_; |
| 121 scoped_refptr<gfx::GLContext> context_; | 129 scoped_refptr<gfx::GLContext> context_; |
| 122 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; | 130 scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; |
| 123 scoped_ptr<TransferBuffer> transfer_buffer_; | 131 scoped_ptr<TransferBuffer> transfer_buffer_; |
| 124 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; | 132 scoped_ptr<gles2::GLES2Implementation> gles2_implementation_; |
| 125 bool context_lost_allowed_; | 133 bool context_lost_allowed_; |
| 126 | 134 |
| 127 // Client GpuControl implementation. | |
| 128 base::ScopedPtrHashMap<int32, gfx::GpuMemoryBuffer> gpu_memory_buffers_; | |
| 129 | |
| 130 // Used on Android to virtualize GL for all contexts. | 135 // Used on Android to virtualize GL for all contexts. |
| 131 static int use_count_; | 136 static int use_count_; |
| 132 static scoped_refptr<gfx::GLShareGroup>* base_share_group_; | 137 static scoped_refptr<gfx::GLShareGroup>* base_share_group_; |
| 133 static scoped_refptr<gfx::GLSurface>* base_surface_; | 138 static scoped_refptr<gfx::GLSurface>* base_surface_; |
| 134 static scoped_refptr<gfx::GLContext>* base_context_; | 139 static scoped_refptr<gfx::GLContext>* base_context_; |
| 135 }; | 140 }; |
| 136 | 141 |
| 137 } // namespace gpu | 142 } // namespace gpu |
| 138 | 143 |
| 139 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ | 144 #endif // GPU_COMMAND_BUFFER_TESTS_GL_MANAGER_H_ |
| OLD | NEW |