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
3 // found in the LICENSE file.
5 #ifndef WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_
6 #define WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "gpu/command_buffer/client/gl_in_process_context.h"
13 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
14 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "ui/gfx/native_widget_types.h"
16 #include "webkit/common/gpu/webgraphicscontext3d_impl.h"
17 #include "webkit/common/gpu/webkit_gpu_export.h"
24 class GLES2Implementation;
25 struct ContextCreationAttribHelper;
30 class GLInProcessContext;
36 class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
37 : public WebGraphicsContext3DImpl {
39 static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
41 const blink::WebGraphicsContext3D::Attributes& attributes,
42 bool lose_context_when_out_of_memory,
43 gfx::AcceleratedWidget window);
45 static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
46 CreateOffscreenContext(
47 const blink::WebGraphicsContext3D::Attributes& attributes,
48 bool lose_context_when_out_of_memory);
50 static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
52 scoped_ptr< ::gpu::GLInProcessContext> context,
53 const blink::WebGraphicsContext3D::Attributes& attributes);
55 virtual ~WebGraphicsContext3DInProcessCommandBufferImpl();
57 //----------------------------------------------------------------------
58 // WebGraphicsContext3D methods
59 virtual bool makeContextCurrent();
61 virtual bool isContextLost();
63 virtual WGC3Denum getGraphicsResetStatusARB();
65 ::gpu::ContextSupport* GetContextSupport();
67 ::gpu::gles2::GLES2Implementation* GetImplementation() {
72 WebGraphicsContext3DInProcessCommandBufferImpl(
73 scoped_ptr< ::gpu::GLInProcessContext> context,
74 const blink::WebGraphicsContext3D::Attributes& attributes,
75 bool lose_context_when_out_of_memory,
77 gfx::AcceleratedWidget window);
81 bool MaybeInitializeGL();
83 // Used to try to find bugs in code that calls gl directly through the gl api
84 // instead of going through WebGraphicsContext3D.
87 ::gpu::gles2::ContextCreationAttribHelper attribs_;
88 bool share_resources_;
92 // Only used when not offscreen.
93 gfx::AcceleratedWidget window_;
95 // The context we use for OpenGL rendering.
96 scoped_ptr< ::gpu::GLInProcessContext> context_;
97 // The GLES2Implementation we use for OpenGL rendering.
98 ::gpu::gles2::GLES2Implementation* real_gl_;
102 } // namespace webkit
104 #endif // WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_