| 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_BLINK_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_ | 5 #ifndef GPU_BLINK_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_ |
| 6 #define GPU_BLINK_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_ | 6 #define GPU_BLINK_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "gpu/blink/gpu_blink_export.h" | 14 #include "gpu/blink/gpu_blink_export.h" |
| 15 #include "gpu/blink/webgraphicscontext3d_impl.h" | 15 #include "gpu/blink/webgraphicscontext3d_impl.h" |
| 16 #include "gpu/command_buffer/client/gl_in_process_context.h" | 16 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 17 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 17 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 18 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 20 | 20 |
| 21 namespace gpu { | 21 namespace gpu { |
| 22 class ContextSupport; | 22 class ContextSupport; |
| 23 class GLInProcessContext; | 23 class GLInProcessContext; |
| 24 | 24 |
| 25 namespace gles2 { | 25 namespace gles2 { |
| 26 class GLES2Interface; | 26 class GLES2Interface; |
| 27 class GLES2Implementation; | 27 class GLES2Implementation; |
| 28 struct ContextCreationAttribHelper; | 28 struct ContextCreationAttribHelper; |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace gpu_blink { | 32 namespace gpu_blink { |
| 33 | 33 |
| 34 class GPU_BLINK_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl | 34 class GPU_BLINK_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl |
| 35 : public WebGraphicsContext3DImpl { | 35 : public WebGraphicsContext3DImpl { |
| 36 public: | 36 public: |
| 37 enum MappedMemoryReclaimLimit { | 37 enum MappedMemoryReclaimLimit { |
| 38 kNoLimit = 0, | 38 kNoLimit = 0, |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> | 41 static std::unique_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> |
| 42 CreateOffscreenContext( | 42 CreateOffscreenContext( |
| 43 const gpu::gles2::ContextCreationAttribHelper& attributes); | 43 const gpu::gles2::ContextCreationAttribHelper& attributes); |
| 44 | 44 |
| 45 static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext( | 45 static std::unique_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> |
| 46 scoped_ptr<::gpu::GLInProcessContext> context, | 46 WrapContext(std::unique_ptr<::gpu::GLInProcessContext> context, |
| 47 const gpu::gles2::ContextCreationAttribHelper& attributes); | 47 const gpu::gles2::ContextCreationAttribHelper& attributes); |
| 48 | 48 |
| 49 ~WebGraphicsContext3DInProcessCommandBufferImpl() override; | 49 ~WebGraphicsContext3DInProcessCommandBufferImpl() override; |
| 50 | 50 |
| 51 size_t GetMappedMemoryLimit(); | 51 size_t GetMappedMemoryLimit(); |
| 52 | 52 |
| 53 bool InitializeOnCurrentThread(); | 53 bool InitializeOnCurrentThread(); |
| 54 void SetLock(base::Lock* lock); | 54 void SetLock(base::Lock* lock); |
| 55 | 55 |
| 56 ::gpu::ContextSupport* GetContextSupport(); | 56 ::gpu::ContextSupport* GetContextSupport(); |
| 57 | 57 |
| 58 ::gpu::gles2::GLES2Implementation* GetImplementation() { | 58 ::gpu::gles2::GLES2Implementation* GetImplementation() { |
| 59 return real_gl_; | 59 return real_gl_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 WebGraphicsContext3DInProcessCommandBufferImpl( | 63 WebGraphicsContext3DInProcessCommandBufferImpl( |
| 64 scoped_ptr<::gpu::GLInProcessContext> context, | 64 std::unique_ptr<::gpu::GLInProcessContext> context, |
| 65 const gpu::gles2::ContextCreationAttribHelper& attributes, | 65 const gpu::gles2::ContextCreationAttribHelper& attributes, |
| 66 bool is_offscreen, | 66 bool is_offscreen, |
| 67 gfx::AcceleratedWidget window); | 67 gfx::AcceleratedWidget window); |
| 68 | 68 |
| 69 void OnContextLost(); | 69 void OnContextLost(); |
| 70 | 70 |
| 71 bool MaybeInitializeGL(); | 71 bool MaybeInitializeGL(); |
| 72 | 72 |
| 73 // Used to try to find bugs in code that calls gl directly through the gl api | 73 // Used to try to find bugs in code that calls gl directly through the gl api |
| 74 // instead of going through WebGraphicsContext3D. | 74 // instead of going through WebGraphicsContext3D. |
| 75 void ClearContext(); | 75 void ClearContext(); |
| 76 | 76 |
| 77 ::gpu::gles2::ContextCreationAttribHelper attributes_; | 77 ::gpu::gles2::ContextCreationAttribHelper attributes_; |
| 78 | 78 |
| 79 bool is_offscreen_; | 79 bool is_offscreen_; |
| 80 // Only used when not offscreen. | 80 // Only used when not offscreen. |
| 81 gfx::AcceleratedWidget window_; | 81 gfx::AcceleratedWidget window_; |
| 82 | 82 |
| 83 // The context we use for OpenGL rendering. | 83 // The context we use for OpenGL rendering. |
| 84 scoped_ptr< ::gpu::GLInProcessContext> context_; | 84 std::unique_ptr<::gpu::GLInProcessContext> context_; |
| 85 // The GLES2Implementation we use for OpenGL rendering. | 85 // The GLES2Implementation we use for OpenGL rendering. |
| 86 ::gpu::gles2::GLES2Implementation* real_gl_; | 86 ::gpu::gles2::GLES2Implementation* real_gl_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace gpu_blink | 89 } // namespace gpu_blink |
| 90 | 90 |
| 91 #endif // GPU_BLINK_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_ | 91 #endif // GPU_BLINK_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_ |
| OLD | NEW |