diff options
author | neb@chromium.org <neb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 19:45:28 +0000 |
---|---|---|
committer | neb@chromium.org <neb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 19:45:28 +0000 |
commit | 5bba4dc2e195c986116bc18f7cffea1d31b9faf2 (patch) | |
tree | 94d14fb3f8ca4e7c156265da397c8baa9a77ef9c /webkit | |
parent | 14de485ed6b6be9ebee386ecc1da4d5e5472eab1 (diff) | |
download | chromium_src-5bba4dc2e195c986116bc18f7cffea1d31b9faf2.zip chromium_src-5bba4dc2e195c986116bc18f7cffea1d31b9faf2.tar.gz chromium_src-5bba4dc2e195c986116bc18f7cffea1d31b9faf2.tar.bz2 |
Pepper2 Graphics3D implementation - browser side.
BUG=46374
TEST=opengl demos work on Pepper2
Review URL: http://codereview.chromium.org/3020049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/DEPS | 1 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_graphics_3d.cc | 256 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_graphics_3d.h | 86 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_graphics_3d_gl.cc | 716 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_delegate.h | 39 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.cc | 13 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.h | 6 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_module.cc | 15 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_resource.h | 3 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.gypi | 6 |
10 files changed, 1131 insertions, 10 deletions
diff --git a/webkit/glue/DEPS b/webkit/glue/DEPS index e59afec..0a36ef7 100644 --- a/webkit/glue/DEPS +++ b/webkit/glue/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+app", + "+gpu", "+media", "+skia/ext", "+skia/include", diff --git a/webkit/glue/plugins/pepper_graphics_3d.cc b/webkit/glue/plugins/pepper_graphics_3d.cc new file mode 100644 index 0000000..d01189a --- /dev/null +++ b/webkit/glue/plugins/pepper_graphics_3d.cc @@ -0,0 +1,256 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/glue/plugins/pepper_graphics_3d.h" + +#include "gpu/command_buffer/common/command_buffer.h" +#include "base/singleton.h" +#include "base/thread_local.h" +#include "webkit/glue/plugins/pepper_plugin_instance.h" + +namespace pepper { + +namespace { + +struct CurrentContextTag {}; +typedef Singleton<base::ThreadLocalPointer<Graphics3D>, + DefaultSingletonTraits<base::ThreadLocalPointer<Graphics3D> >, + CurrentContextTag> CurrentContextKey; + +// Size of the transfer buffer. +enum { kTransferBufferSize = 512 * 1024 }; + +bool IsGraphics3D(PP_Resource resource) { + return !!Resource::GetAs<Graphics3D>(resource); +} + +bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) { + // TODO(neb): Implement me! + return false; +} + +bool ChooseConfig(const int32_t* attrib_list, int32_t* configs, + int32_t config_size, int32_t* num_config) { + // TODO(neb): Implement me! + return false; +} + +bool GetConfigAttrib(int32_t config, int32_t attribute, int32_t* value) { + // TODO(neb): Implement me! + return false; +} + +const char* QueryString(int32_t name) { + switch (name) { + case EGL_CLIENT_APIS: + return "OpenGL_ES"; + case EGL_EXTENSIONS: + return ""; + case EGL_VENDOR: + return "Google"; + case EGL_VERSION: + return "1.0 Google"; + default: + return NULL; + } +} + +PP_Resource CreateContext(PP_Instance instance_id, int32_t config, + int32_t share_context, + const int32_t* attrib_list) { + DCHECK_EQ(0, share_context); + + PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); + if (!instance) { + return 0; + } + + scoped_refptr<Graphics3D> context(new Graphics3D(instance->module())); + if (!context->Init(instance_id, config, attrib_list)) { + return 0; + } + + return context->GetReference(); +} + +void* GetProcAddress(const char* name) { + // TODO(neb): Implement me! + return NULL; +} + +bool MakeCurrent(PP_Resource graphics3d) { + if (!graphics3d) { + Graphics3D::ResetCurrent(); + return true; + } else { + scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); + return context.get() && context->MakeCurrent(); + } +} + +PP_Resource GetCurrentContext() { + Graphics3D* currentContext = Graphics3D::GetCurrent(); + return currentContext ? currentContext->GetReference() : 0; +} + +bool SwapBuffers(PP_Resource graphics3d) { + scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); + return context && context->SwapBuffers(); +} + +uint32_t GetError() { + // TODO(neb): Figure out error checking. + return PP_GRAPHICS_3D_ERROR_SUCCESS; +} + +const PPB_Graphics3D ppb_graphics3d = { + &IsGraphics3D, + &GetConfigs, + &ChooseConfig, + &GetConfigAttrib, + &QueryString, + &CreateContext, + &GetProcAddress, + &MakeCurrent, + &GetCurrentContext, + &SwapBuffers, + &GetError +}; + + +} // namespace + +Graphics3D::Graphics3D(PluginModule* module) + : Resource(module), + command_buffer_(NULL), + transfer_buffer_id_(0), + method_factory3d_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { +} + +const PPB_Graphics3D* Graphics3D::GetInterface() { + return &ppb_graphics3d; +} + +Graphics3D* Graphics3D::GetCurrent() { + return CurrentContextKey::get()->Get(); +} + +void Graphics3D::ResetCurrent() { + CurrentContextKey::get()->Set(NULL); +} + +Graphics3D::~Graphics3D() { + Destroy(); +} + +bool Graphics3D::Init(PP_Instance instance_id, int32_t config, + const int32_t* attrib_list) { + PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); + if (!instance) { + return false; + } + + // Create and initialize the objects required to issue GLES2 calls. + platform_context_.reset(instance->delegate()->CreateContext3D()); + if (!platform_context_.get()) + return false; + + if (!platform_context_->Init(instance->position(), + instance->clip())) { + platform_context_.reset(); + return false; + } + command_buffer_ = platform_context_->GetCommandBuffer(); + gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_)); + gpu::Buffer buffer = command_buffer_->GetRingBuffer(); + if (gles2_helper_->Initialize(buffer.size)) { + transfer_buffer_id_ = + command_buffer_->CreateTransferBuffer(kTransferBufferSize); + gpu::Buffer transfer_buffer = + command_buffer_->GetTransferBuffer(transfer_buffer_id_); + if (transfer_buffer.ptr) { + gles2_implementation_.reset(new gpu::gles2::GLES2Implementation( + gles2_helper_.get(), + transfer_buffer.size, + transfer_buffer.ptr, + transfer_buffer_id_, + false)); + platform_context_->SetNotifyRepaintTask( + method_factory3d_.NewRunnableMethod(&Graphics3D::HandleRepaint, + instance_id)); + return true; + } + } + + // Tear everything down if initialization failed. + Destroy(); + return false; +} + +bool Graphics3D::MakeCurrent() { + if (!command_buffer_) + return false; + + CurrentContextKey::get()->Set(this); + + // Don't request latest error status from service. Just use the locally + // cached information from the last flush. + // TODO(apatrick): I'm not sure if this should actually change the + // current context if it fails. For now it gets changed even if it fails + // becuase making GL calls with a NULL context crashes. + // TODO(neb): Figure out error checking. +// if (command_buffer_->GetCachedError() != gpu::error::kNoError) +// return false; + return true; +} + +bool Graphics3D::SwapBuffers() { + if (!command_buffer_) + return false; + + // Don't request latest error status from service. Just use the locally cached + // information from the last flush. + // TODO(neb): Figure out error checking. +// if (command_buffer_->GetCachedError() != gpu::error::kNoError) +// return false; + + gles2_implementation_->SwapBuffers(); + return true; +} + +void Graphics3D::Destroy() { + if (GetCurrent() == this) { + ResetCurrent(); + } + + method_factory3d_.RevokeAll(); + + gles2_implementation_.reset(); + + if (command_buffer_ && transfer_buffer_id_ != 0) { + command_buffer_->DestroyTransferBuffer(transfer_buffer_id_); + transfer_buffer_id_ = 0; + } + + gles2_helper_.reset(); + + // Platform context owns the command buffer. + platform_context_.reset(); + command_buffer_ = NULL; +} + +void Graphics3D::HandleRepaint(PP_Instance instance_id) { + PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); + if (instance) { + instance->Graphics3DContextLost(); + if (platform_context_.get()) { + platform_context_->SetNotifyRepaintTask( + method_factory3d_.NewRunnableMethod(&Graphics3D::HandleRepaint, + instance_id)); + } + } +} + +} // namespace pepper + diff --git a/webkit/glue/plugins/pepper_graphics_3d.h b/webkit/glue/plugins/pepper_graphics_3d.h new file mode 100644 index 0000000..97893e8 --- /dev/null +++ b/webkit/glue/plugins/pepper_graphics_3d.h @@ -0,0 +1,86 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ +#define WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ + +#include "base/scoped_ptr.h" +#include "gpu/command_buffer/client/gles2_cmd_helper.h" +#include "gpu/command_buffer/client/gles2_implementation.h" +#include "third_party/ppapi/c/ppb_graphics_3d.h" +#include "webkit/glue/plugins/pepper_plugin_delegate.h" +#include "webkit/glue/plugins/pepper_resource.h" + + +namespace gfx { +class Rect; +} // namespace gfx + +namespace gpu { +class CommandBuffer; +} // namespace gpu + +typedef struct _ppb_OpenGLES PPB_OpenGLES; + +namespace pepper { + +class Graphics3D : public Resource { + public: + explicit Graphics3D(PluginModule* module); + + virtual ~Graphics3D(); + + static const PPB_Graphics3D* GetInterface(); + + static const PPB_OpenGLES* GetOpenGLESInterface(); + + static bool Shutdown(); + + static Graphics3D* GetCurrent(); + + static void ResetCurrent(); + + // Resource override. + virtual Graphics3D* AsGraphics3D() { + return this; + } + + bool Init(PP_Instance instance_id, int32_t config, + const int32_t* attrib_list); + + bool MakeCurrent(); + + bool SwapBuffers(); + + gpu::gles2::GLES2Implementation* impl() { + return gles2_implementation_.get(); + } + + private: + void HandleRepaint(PP_Instance instance_id); + void Destroy(); + + // PluginDelegate's 3D Context. Responsible for providing the command buffer. + scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_; + + // Command buffer is owned by the platform context. + gpu::CommandBuffer* command_buffer_; + + // GLES2 Command Helper instance. + scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; + + // ID of the transfer buffer. + int32_t transfer_buffer_id_; + + // GLES2 Implementation instance. + scoped_ptr<gpu::gles2::GLES2Implementation> gles2_implementation_; + + // Runnable methods that must be cancelled when the 3D context is destroyed. + ScopedRunnableMethodFactory<Graphics3D> method_factory3d_; +}; + +} // namespace pepper + +#endif // WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_ + diff --git a/webkit/glue/plugins/pepper_graphics_3d_gl.cc b/webkit/glue/plugins/pepper_graphics_3d_gl.cc new file mode 100644 index 0000000..8b64216 --- /dev/null +++ b/webkit/glue/plugins/pepper_graphics_3d_gl.cc @@ -0,0 +1,716 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto-generated. DO NOT EDIT! + +#include "webkit/glue/plugins/pepper_graphics_3d.h" + +#include "gpu/command_buffer/client/gles2_implementation.h" +#include "third_party/ppapi/c/ppb_opengles.h" + +namespace pepper { + +namespace { + +void ActiveTexture(GLenum texture) { + Graphics3D::GetCurrent()->impl()->ActiveTexture(texture); +} +void AttachShader(GLuint program, GLuint shader) { + Graphics3D::GetCurrent()->impl()->AttachShader(program, shader); +} +void BindAttribLocation(GLuint program, GLuint index, const char* name) { + Graphics3D::GetCurrent()->impl()->BindAttribLocation(program, index, name); +} +void BindBuffer(GLenum target, GLuint buffer) { + Graphics3D::GetCurrent()->impl()->BindBuffer(target, buffer); +} +void BindFramebuffer(GLenum target, GLuint framebuffer) { + Graphics3D::GetCurrent()->impl()->BindFramebuffer(target, framebuffer); +} +void BindRenderbuffer(GLenum target, GLuint renderbuffer) { + Graphics3D::GetCurrent()->impl()->BindRenderbuffer(target, renderbuffer); +} +void BindTexture(GLenum target, GLuint texture) { + Graphics3D::GetCurrent()->impl()->BindTexture(target, texture); +} +void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + Graphics3D::GetCurrent()->impl()->BlendColor(red, green, blue, alpha); +} +void BlendEquation(GLenum mode) { + Graphics3D::GetCurrent()->impl()->BlendEquation(mode); +} +void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { + Graphics3D::GetCurrent()->impl()->BlendEquationSeparate(modeRGB, modeAlpha); +} +void BlendFunc(GLenum sfactor, GLenum dfactor) { + Graphics3D::GetCurrent()->impl()->BlendFunc(sfactor, dfactor); +} +void BlendFuncSeparate( + GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { + Graphics3D::GetCurrent()->impl()->BlendFuncSeparate( + srcRGB, dstRGB, srcAlpha, dstAlpha); +} +void BufferData( + GLenum target, GLsizeiptr size, const void* data, GLenum usage) { + Graphics3D::GetCurrent()->impl()->BufferData(target, size, data, usage); +} +void BufferSubData( + GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + Graphics3D::GetCurrent()->impl()->BufferSubData(target, offset, size, data); +} +GLenum CheckFramebufferStatus(GLenum target) { + return Graphics3D::GetCurrent()->impl()->CheckFramebufferStatus(target); +} +void Clear(GLbitfield mask) { + Graphics3D::GetCurrent()->impl()->Clear(mask); +} +void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + Graphics3D::GetCurrent()->impl()->ClearColor(red, green, blue, alpha); +} +void ClearDepthf(GLclampf depth) { + Graphics3D::GetCurrent()->impl()->ClearDepthf(depth); +} +void ClearStencil(GLint s) { + Graphics3D::GetCurrent()->impl()->ClearStencil(s); +} +void ColorMask( + GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { + Graphics3D::GetCurrent()->impl()->ColorMask(red, green, blue, alpha); +} +void CompileShader(GLuint shader) { + Graphics3D::GetCurrent()->impl()->CompileShader(shader); +} +void CompressedTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, const void* data) { + Graphics3D::GetCurrent()->impl()->CompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, data); +} +void CompressedTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, const void* data) { + Graphics3D::GetCurrent()->impl()->CompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, data); +} +void CopyTexImage2D( + GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border) { + Graphics3D::GetCurrent()->impl()->CopyTexImage2D( + target, level, internalformat, x, y, width, height, border); +} +void CopyTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, + GLsizei width, GLsizei height) { + Graphics3D::GetCurrent()->impl()->CopyTexSubImage2D( + target, level, xoffset, yoffset, x, y, width, height); +} +GLuint CreateProgram() { + return Graphics3D::GetCurrent()->impl()->CreateProgram(); +} +GLuint CreateShader(GLenum type) { + return Graphics3D::GetCurrent()->impl()->CreateShader(type); +} +void CullFace(GLenum mode) { + Graphics3D::GetCurrent()->impl()->CullFace(mode); +} +void DeleteBuffers(GLsizei n, const GLuint* buffers) { + Graphics3D::GetCurrent()->impl()->DeleteBuffers(n, buffers); +} +void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) { + Graphics3D::GetCurrent()->impl()->DeleteFramebuffers(n, framebuffers); +} +void DeleteProgram(GLuint program) { + Graphics3D::GetCurrent()->impl()->DeleteProgram(program); +} +void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) { + Graphics3D::GetCurrent()->impl()->DeleteRenderbuffers(n, renderbuffers); +} +void DeleteShader(GLuint shader) { + Graphics3D::GetCurrent()->impl()->DeleteShader(shader); +} +void DeleteTextures(GLsizei n, const GLuint* textures) { + Graphics3D::GetCurrent()->impl()->DeleteTextures(n, textures); +} +void DepthFunc(GLenum func) { + Graphics3D::GetCurrent()->impl()->DepthFunc(func); +} +void DepthMask(GLboolean flag) { + Graphics3D::GetCurrent()->impl()->DepthMask(flag); +} +void DepthRangef(GLclampf zNear, GLclampf zFar) { + Graphics3D::GetCurrent()->impl()->DepthRangef(zNear, zFar); +} +void DetachShader(GLuint program, GLuint shader) { + Graphics3D::GetCurrent()->impl()->DetachShader(program, shader); +} +void Disable(GLenum cap) { + Graphics3D::GetCurrent()->impl()->Disable(cap); +} +void DisableVertexAttribArray(GLuint index) { + Graphics3D::GetCurrent()->impl()->DisableVertexAttribArray(index); +} +void DrawArrays(GLenum mode, GLint first, GLsizei count) { + Graphics3D::GetCurrent()->impl()->DrawArrays(mode, first, count); +} +void DrawElements( + GLenum mode, GLsizei count, GLenum type, const void* indices) { + Graphics3D::GetCurrent()->impl()->DrawElements(mode, count, type, indices); +} +void Enable(GLenum cap) { + Graphics3D::GetCurrent()->impl()->Enable(cap); +} +void EnableVertexAttribArray(GLuint index) { + Graphics3D::GetCurrent()->impl()->EnableVertexAttribArray(index); +} +void Finish() { + Graphics3D::GetCurrent()->impl()->Finish(); +} +void Flush() { + Graphics3D::GetCurrent()->impl()->Flush(); +} +void FramebufferRenderbuffer( + GLenum target, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer) { + Graphics3D::GetCurrent()->impl()->FramebufferRenderbuffer( + target, attachment, renderbuffertarget, renderbuffer); +} +void FramebufferTexture2D( + GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level) { + Graphics3D::GetCurrent()->impl()->FramebufferTexture2D( + target, attachment, textarget, texture, level); +} +void FrontFace(GLenum mode) { + Graphics3D::GetCurrent()->impl()->FrontFace(mode); +} +void GenBuffers(GLsizei n, GLuint* buffers) { + Graphics3D::GetCurrent()->impl()->GenBuffers(n, buffers); +} +void GenerateMipmap(GLenum target) { + Graphics3D::GetCurrent()->impl()->GenerateMipmap(target); +} +void GenFramebuffers(GLsizei n, GLuint* framebuffers) { + Graphics3D::GetCurrent()->impl()->GenFramebuffers(n, framebuffers); +} +void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) { + Graphics3D::GetCurrent()->impl()->GenRenderbuffers(n, renderbuffers); +} +void GenTextures(GLsizei n, GLuint* textures) { + Graphics3D::GetCurrent()->impl()->GenTextures(n, textures); +} +void GetActiveAttrib( + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, + GLenum* type, char* name) { + Graphics3D::GetCurrent()->impl()->GetActiveAttrib( + program, index, bufsize, length, size, type, name); +} +void GetActiveUniform( + GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, + GLenum* type, char* name) { + Graphics3D::GetCurrent()->impl()->GetActiveUniform( + program, index, bufsize, length, size, type, name); +} +void GetAttachedShaders( + GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { + Graphics3D::GetCurrent()->impl()->GetAttachedShaders( + program, maxcount, count, shaders); +} +GLint GetAttribLocation(GLuint program, const char* name) { + return Graphics3D::GetCurrent()->impl()->GetAttribLocation(program, name); +} +void GetBooleanv(GLenum pname, GLboolean* params) { + Graphics3D::GetCurrent()->impl()->GetBooleanv(pname, params); +} +void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetBufferParameteriv( + target, pname, params); +} +GLenum GetError() { + return Graphics3D::GetCurrent()->impl()->GetError(); +} +void GetFloatv(GLenum pname, GLfloat* params) { + Graphics3D::GetCurrent()->impl()->GetFloatv(pname, params); +} +void GetFramebufferAttachmentParameteriv( + GLenum target, GLenum attachment, GLenum pname, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetFramebufferAttachmentParameteriv( + target, attachment, pname, params); +} +void GetIntegerv(GLenum pname, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetIntegerv(pname, params); +} +void GetProgramiv(GLuint program, GLenum pname, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetProgramiv(program, pname, params); +} +void GetProgramInfoLog( + GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { + Graphics3D::GetCurrent()->impl()->GetProgramInfoLog( + program, bufsize, length, infolog); +} +void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetRenderbufferParameteriv( + target, pname, params); +} +void GetShaderiv(GLuint shader, GLenum pname, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetShaderiv(shader, pname, params); +} +void GetShaderInfoLog( + GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { + Graphics3D::GetCurrent()->impl()->GetShaderInfoLog( + shader, bufsize, length, infolog); +} +void GetShaderPrecisionFormat( + GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { + Graphics3D::GetCurrent()->impl()->GetShaderPrecisionFormat( + shadertype, precisiontype, range, precision); +} +void GetShaderSource( + GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { + Graphics3D::GetCurrent()->impl()->GetShaderSource( + shader, bufsize, length, source); +} +const GLubyte* GetString(GLenum name) { + return Graphics3D::GetCurrent()->impl()->GetString(name); +} +void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) { + Graphics3D::GetCurrent()->impl()->GetTexParameterfv(target, pname, params); +} +void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetTexParameteriv(target, pname, params); +} +void GetUniformfv(GLuint program, GLint location, GLfloat* params) { + Graphics3D::GetCurrent()->impl()->GetUniformfv(program, location, params); +} +void GetUniformiv(GLuint program, GLint location, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetUniformiv(program, location, params); +} +GLint GetUniformLocation(GLuint program, const char* name) { + return Graphics3D::GetCurrent()->impl()->GetUniformLocation(program, name); +} +void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) { + Graphics3D::GetCurrent()->impl()->GetVertexAttribfv(index, pname, params); +} +void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) { + Graphics3D::GetCurrent()->impl()->GetVertexAttribiv(index, pname, params); +} +void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) { + Graphics3D::GetCurrent()->impl()->GetVertexAttribPointerv( + index, pname, pointer); +} +void Hint(GLenum target, GLenum mode) { + Graphics3D::GetCurrent()->impl()->Hint(target, mode); +} +GLboolean IsBuffer(GLuint buffer) { + return Graphics3D::GetCurrent()->impl()->IsBuffer(buffer); +} +GLboolean IsEnabled(GLenum cap) { + return Graphics3D::GetCurrent()->impl()->IsEnabled(cap); +} +GLboolean IsFramebuffer(GLuint framebuffer) { + return Graphics3D::GetCurrent()->impl()->IsFramebuffer(framebuffer); +} +GLboolean IsProgram(GLuint program) { + return Graphics3D::GetCurrent()->impl()->IsProgram(program); +} +GLboolean IsRenderbuffer(GLuint renderbuffer) { + return Graphics3D::GetCurrent()->impl()->IsRenderbuffer(renderbuffer); +} +GLboolean IsShader(GLuint shader) { + return Graphics3D::GetCurrent()->impl()->IsShader(shader); +} +GLboolean IsTexture(GLuint texture) { + return Graphics3D::GetCurrent()->impl()->IsTexture(texture); +} +void LineWidth(GLfloat width) { + Graphics3D::GetCurrent()->impl()->LineWidth(width); +} +void LinkProgram(GLuint program) { + Graphics3D::GetCurrent()->impl()->LinkProgram(program); +} +void PixelStorei(GLenum pname, GLint param) { + Graphics3D::GetCurrent()->impl()->PixelStorei(pname, param); +} +void PolygonOffset(GLfloat factor, GLfloat units) { + Graphics3D::GetCurrent()->impl()->PolygonOffset(factor, units); +} +void ReadPixels( + GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, + void* pixels) { + Graphics3D::GetCurrent()->impl()->ReadPixels( + x, y, width, height, format, type, pixels); +} +void ReleaseShaderCompiler() { + Graphics3D::GetCurrent()->impl()->ReleaseShaderCompiler(); +} +void RenderbufferStorage( + GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { + Graphics3D::GetCurrent()->impl()->RenderbufferStorage( + target, internalformat, width, height); +} +void SampleCoverage(GLclampf value, GLboolean invert) { + Graphics3D::GetCurrent()->impl()->SampleCoverage(value, invert); +} +void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { + Graphics3D::GetCurrent()->impl()->Scissor(x, y, width, height); +} +void ShaderBinary( + GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, + GLsizei length) { + Graphics3D::GetCurrent()->impl()->ShaderBinary( + n, shaders, binaryformat, binary, length); +} +void ShaderSource( + GLuint shader, GLsizei count, const char** str, const GLint* length) { + Graphics3D::GetCurrent()->impl()->ShaderSource(shader, count, str, length); +} +void StencilFunc(GLenum func, GLint ref, GLuint mask) { + Graphics3D::GetCurrent()->impl()->StencilFunc(func, ref, mask); +} +void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) { + Graphics3D::GetCurrent()->impl()->StencilFuncSeparate(face, func, ref, mask); +} +void StencilMask(GLuint mask) { + Graphics3D::GetCurrent()->impl()->StencilMask(mask); +} +void StencilMaskSeparate(GLenum face, GLuint mask) { + Graphics3D::GetCurrent()->impl()->StencilMaskSeparate(face, mask); +} +void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) { + Graphics3D::GetCurrent()->impl()->StencilOp(fail, zfail, zpass); +} +void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { + Graphics3D::GetCurrent()->impl()->StencilOpSeparate( + face, fail, zfail, zpass); +} +void TexImage2D( + GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type, + const void* pixels) { + Graphics3D::GetCurrent()->impl()->TexImage2D( + target, level, internalformat, width, height, border, format, type, + pixels); +} +void TexParameterf(GLenum target, GLenum pname, GLfloat param) { + Graphics3D::GetCurrent()->impl()->TexParameterf(target, pname, param); +} +void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) { + Graphics3D::GetCurrent()->impl()->TexParameterfv(target, pname, params); +} +void TexParameteri(GLenum target, GLenum pname, GLint param) { + Graphics3D::GetCurrent()->impl()->TexParameteri(target, pname, param); +} +void TexParameteriv(GLenum target, GLenum pname, const GLint* params) { + Graphics3D::GetCurrent()->impl()->TexParameteriv(target, pname, params); +} +void TexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type, const void* pixels) { + Graphics3D::GetCurrent()->impl()->TexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, pixels); +} +void Uniform1f(GLint location, GLfloat x) { + Graphics3D::GetCurrent()->impl()->Uniform1f(location, x); +} +void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) { + Graphics3D::GetCurrent()->impl()->Uniform1fv(location, count, v); +} +void Uniform1i(GLint location, GLint x) { + Graphics3D::GetCurrent()->impl()->Uniform1i(location, x); +} +void Uniform1iv(GLint location, GLsizei count, const GLint* v) { + Graphics3D::GetCurrent()->impl()->Uniform1iv(location, count, v); +} +void Uniform2f(GLint location, GLfloat x, GLfloat y) { + Graphics3D::GetCurrent()->impl()->Uniform2f(location, x, y); +} +void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) { + Graphics3D::GetCurrent()->impl()->Uniform2fv(location, count, v); +} +void Uniform2i(GLint location, GLint x, GLint y) { + Graphics3D::GetCurrent()->impl()->Uniform2i(location, x, y); +} +void Uniform2iv(GLint location, GLsizei count, const GLint* v) { + Graphics3D::GetCurrent()->impl()->Uniform2iv(location, count, v); +} +void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) { + Graphics3D::GetCurrent()->impl()->Uniform3f(location, x, y, z); +} +void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) { + Graphics3D::GetCurrent()->impl()->Uniform3fv(location, count, v); +} +void Uniform3i(GLint location, GLint x, GLint y, GLint z) { + Graphics3D::GetCurrent()->impl()->Uniform3i(location, x, y, z); +} +void Uniform3iv(GLint location, GLsizei count, const GLint* v) { + Graphics3D::GetCurrent()->impl()->Uniform3iv(location, count, v); +} +void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + Graphics3D::GetCurrent()->impl()->Uniform4f(location, x, y, z, w); +} +void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) { + Graphics3D::GetCurrent()->impl()->Uniform4fv(location, count, v); +} +void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) { + Graphics3D::GetCurrent()->impl()->Uniform4i(location, x, y, z, w); +} +void Uniform4iv(GLint location, GLsizei count, const GLint* v) { + Graphics3D::GetCurrent()->impl()->Uniform4iv(location, count, v); +} +void UniformMatrix2fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + Graphics3D::GetCurrent()->impl()->UniformMatrix2fv( + location, count, transpose, value); +} +void UniformMatrix3fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + Graphics3D::GetCurrent()->impl()->UniformMatrix3fv( + location, count, transpose, value); +} +void UniformMatrix4fv( + GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + Graphics3D::GetCurrent()->impl()->UniformMatrix4fv( + location, count, transpose, value); +} +void UseProgram(GLuint program) { + Graphics3D::GetCurrent()->impl()->UseProgram(program); +} +void ValidateProgram(GLuint program) { + Graphics3D::GetCurrent()->impl()->ValidateProgram(program); +} +void VertexAttrib1f(GLuint indx, GLfloat x) { + Graphics3D::GetCurrent()->impl()->VertexAttrib1f(indx, x); +} +void VertexAttrib1fv(GLuint indx, const GLfloat* values) { + Graphics3D::GetCurrent()->impl()->VertexAttrib1fv(indx, values); +} +void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) { + Graphics3D::GetCurrent()->impl()->VertexAttrib2f(indx, x, y); +} +void VertexAttrib2fv(GLuint indx, const GLfloat* values) { + Graphics3D::GetCurrent()->impl()->VertexAttrib2fv(indx, values); +} +void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) { + Graphics3D::GetCurrent()->impl()->VertexAttrib3f(indx, x, y, z); +} +void VertexAttrib3fv(GLuint indx, const GLfloat* values) { + Graphics3D::GetCurrent()->impl()->VertexAttrib3fv(indx, values); +} +void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + Graphics3D::GetCurrent()->impl()->VertexAttrib4f(indx, x, y, z, w); +} +void VertexAttrib4fv(GLuint indx, const GLfloat* values) { + Graphics3D::GetCurrent()->impl()->VertexAttrib4fv(indx, values); +} +void VertexAttribPointer( + GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, + const void* ptr) { + Graphics3D::GetCurrent()->impl()->VertexAttribPointer( + indx, size, type, normalized, stride, ptr); +} +void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { + Graphics3D::GetCurrent()->impl()->Viewport(x, y, width, height); +} +void SwapBuffers() { + Graphics3D::GetCurrent()->impl()->SwapBuffers(); +} +GLuint GetMaxValueInBuffer( + GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) { + return Graphics3D::GetCurrent()->impl()->GetMaxValueInBuffer( + buffer_id, count, type, offset); +} +void GenSharedIds( + GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) { + Graphics3D::GetCurrent()->impl()->GenSharedIds( + namespace_id, id_offset, n, ids); +} +void DeleteSharedIds(GLuint namespace_id, GLsizei n, const GLuint* ids) { + Graphics3D::GetCurrent()->impl()->DeleteSharedIds(namespace_id, n, ids); +} +void RegisterSharedIds(GLuint namespace_id, GLsizei n, const GLuint* ids) { + Graphics3D::GetCurrent()->impl()->RegisterSharedIds(namespace_id, n, ids); +} +GLboolean CommandBufferEnable(const char* feature) { + return Graphics3D::GetCurrent()->impl()->CommandBufferEnable(feature); +} +void* MapBufferSubData( + GLuint target, GLintptr offset, GLsizeiptr size, GLenum access) { + return Graphics3D::GetCurrent()->impl()->MapBufferSubData( + target, offset, size, access); +} +void UnmapBufferSubData(const void* mem) { + Graphics3D::GetCurrent()->impl()->UnmapBufferSubData(mem); +} +void* MapTexSubImage2D( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type, GLenum access) { + return Graphics3D::GetCurrent()->impl()->MapTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, access); +} +void UnmapTexSubImage2D(const void* mem) { + Graphics3D::GetCurrent()->impl()->UnmapTexSubImage2D(mem); +} + +const PPB_OpenGLES ppb_opengles = { + &ActiveTexture, + &AttachShader, + &BindAttribLocation, + &BindBuffer, + &BindFramebuffer, + &BindRenderbuffer, + &BindTexture, + &BlendColor, + &BlendEquation, + &BlendEquationSeparate, + &BlendFunc, + &BlendFuncSeparate, + &BufferData, + &BufferSubData, + &CheckFramebufferStatus, + &Clear, + &ClearColor, + &ClearDepthf, + &ClearStencil, + &ColorMask, + &CompileShader, + &CompressedTexImage2D, + &CompressedTexSubImage2D, + &CopyTexImage2D, + &CopyTexSubImage2D, + &CreateProgram, + &CreateShader, + &CullFace, + &DeleteBuffers, + &DeleteFramebuffers, + &DeleteProgram, + &DeleteRenderbuffers, + &DeleteShader, + &DeleteTextures, + &DepthFunc, + &DepthMask, + &DepthRangef, + &DetachShader, + &Disable, + &DisableVertexAttribArray, + &DrawArrays, + &DrawElements, + &Enable, + &EnableVertexAttribArray, + &Finish, + &Flush, + &FramebufferRenderbuffer, + &FramebufferTexture2D, + &FrontFace, + &GenBuffers, + &GenerateMipmap, + &GenFramebuffers, + &GenRenderbuffers, + &GenTextures, + &GetActiveAttrib, + &GetActiveUniform, + &GetAttachedShaders, + &GetAttribLocation, + &GetBooleanv, + &GetBufferParameteriv, + &GetError, + &GetFloatv, + &GetFramebufferAttachmentParameteriv, + &GetIntegerv, + &GetProgramiv, + &GetProgramInfoLog, + &GetRenderbufferParameteriv, + &GetShaderiv, + &GetShaderInfoLog, + &GetShaderPrecisionFormat, + &GetShaderSource, + &GetString, + &GetTexParameterfv, + &GetTexParameteriv, + &GetUniformfv, + &GetUniformiv, + &GetUniformLocation, + &GetVertexAttribfv, + &GetVertexAttribiv, + &GetVertexAttribPointerv, + &Hint, + &IsBuffer, + &IsEnabled, + &IsFramebuffer, + &IsProgram, + &IsRenderbuffer, + &IsShader, + &IsTexture, + &LineWidth, + &LinkProgram, + &PixelStorei, + &PolygonOffset, + &ReadPixels, + &ReleaseShaderCompiler, + &RenderbufferStorage, + &SampleCoverage, + &Scissor, + &ShaderBinary, + &ShaderSource, + &StencilFunc, + &StencilFuncSeparate, + &StencilMask, + &StencilMaskSeparate, + &StencilOp, + &StencilOpSeparate, + &TexImage2D, + &TexParameterf, + &TexParameterfv, + &TexParameteri, + &TexParameteriv, + &TexSubImage2D, + &Uniform1f, + &Uniform1fv, + &Uniform1i, + &Uniform1iv, + &Uniform2f, + &Uniform2fv, + &Uniform2i, + &Uniform2iv, + &Uniform3f, + &Uniform3fv, + &Uniform3i, + &Uniform3iv, + &Uniform4f, + &Uniform4fv, + &Uniform4i, + &Uniform4iv, + &UniformMatrix2fv, + &UniformMatrix3fv, + &UniformMatrix4fv, + &UseProgram, + &ValidateProgram, + &VertexAttrib1f, + &VertexAttrib1fv, + &VertexAttrib2f, + &VertexAttrib2fv, + &VertexAttrib3f, + &VertexAttrib3fv, + &VertexAttrib4f, + &VertexAttrib4fv, + &VertexAttribPointer, + &Viewport, + &SwapBuffers, + &GetMaxValueInBuffer, + &GenSharedIds, + &DeleteSharedIds, + &RegisterSharedIds, + &CommandBufferEnable, + &MapBufferSubData, + &UnmapBufferSubData, + &MapTexSubImage2D, + &UnmapTexSubImage2D +}; + +} // namespace + +const PPB_OpenGLES* Graphics3D::GetOpenGLESInterface() { + return &ppb_opengles; +} + +} // namespace pepper + diff --git a/webkit/glue/plugins/pepper_plugin_delegate.h b/webkit/glue/plugins/pepper_plugin_delegate.h index e80e626..5f5631083 100644 --- a/webkit/glue/plugins/pepper_plugin_delegate.h +++ b/webkit/glue/plugins/pepper_plugin_delegate.h @@ -5,10 +5,9 @@ #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_DELEGATE_H_ #define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_DELEGATE_H_ -#include <string> - #include "base/shared_memory.h" #include "base/sync_socket.h" +#include "base/task.h" #include "third_party/ppapi/c/pp_completion_callback.h" #include "third_party/ppapi/c/pp_errors.h" #include "third_party/ppapi/c/pp_stdint.h" @@ -16,6 +15,14 @@ class AudioMessageFilter; +namespace gfx { +class Rect; +} + +namespace gpu { +class CommandBuffer; +} + namespace skia { class PlatformCanvas; } @@ -48,6 +55,21 @@ class PluginDelegate { virtual intptr_t GetSharedMemoryHandle() const = 0; }; + class PlatformContext3D { + public: + virtual ~PlatformContext3D() {} + + // Initialize the context. + virtual bool Init(const gfx::Rect& position, const gfx::Rect& clip) = 0; + + // This call will return the address of the command buffer object that is + // constructed in Initialize() and is valid until this context is destroyed. + virtual gpu::CommandBuffer* GetCommandBuffer() = 0; + + // Sets the function to be called on repaint. + virtual void SetNotifyRepaintTask(Task* task) = 0; + }; + class PlatformAudio { public: class Client { @@ -98,9 +120,17 @@ class PluginDelegate { virtual PlatformImage2D* CreateImage2D(int width, int height) = 0; // The caller will own the pointer returned from this. + virtual PlatformContext3D* CreateContext3D() = 0; + + // The caller will own the pointer returned from this. virtual PlatformVideoDecoder* CreateVideoDecoder( const PP_VideoDecoderConfig& decoder_config) = 0; + // The caller will own the pointer returned from this. + virtual PlatformAudio* CreateAudio(uint32_t sample_rate, + uint32_t sample_count, + PlatformAudio::Client* client) = 0; + // Notifies that the number of find results has changed. virtual void DidChangeNumberOfFindResults(int identifier, int total, @@ -109,11 +139,6 @@ class PluginDelegate { // Notifies that the index of the currently selected item has been updated. virtual void DidChangeSelectedFindResult(int identifier, int index) = 0; - // The caller will own the pointer returned from this. - virtual PlatformAudio* CreateAudio(uint32_t sample_rate, - uint32_t sample_count, - PlatformAudio::Client* client) = 0; - // Runs a file chooser. virtual bool RunFileChooser( const WebKit::WebFileChooserParams& params, diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc index 15075ef..06ee71d 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.cc +++ b/webkit/glue/plugins/pepper_plugin_instance.cc @@ -232,7 +232,8 @@ PluginInstance::PluginInstance(PluginDelegate* delegate, num_pages_(0), pdf_output_done_(false), #endif // defined (OS_LINUX) - plugin_print_interface_(NULL) { + plugin_print_interface_(NULL), + plugin_graphics_3d_interface_(NULL) { memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); DCHECK(delegate); module_->InstanceCreated(this); @@ -599,6 +600,16 @@ void PluginInstance::PrintEnd() { #endif // defined(OS_LINUX) } +void PluginInstance::Graphics3DContextLost() { + if (!plugin_graphics_3d_interface_) { + plugin_graphics_3d_interface_ = + reinterpret_cast<const PPP_Graphics3D*>(module_->GetPluginInterface( + PPP_GRAPHICS_3D_INTERFACE)); + } + if (plugin_graphics_3d_interface_) + plugin_graphics_3d_interface_->Graphics3DContextLost(GetPPInstance()); +} + bool PluginInstance::PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas) { scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(print_output)); diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h index f3e39b5..8a09cdf 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.h +++ b/webkit/glue/plugins/pepper_plugin_instance.h @@ -17,6 +17,7 @@ #include "third_party/ppapi/c/pp_instance.h" #include "third_party/ppapi/c/pp_resource.h" #include "third_party/ppapi/c/ppp_printing.h" +#include "third_party/ppapi/c/ppp_graphics_3d.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" @@ -124,6 +125,8 @@ class PluginInstance : public base::RefCounted<PluginInstance> { bool PrintPage(int page_number, WebKit::WebCanvas* canvas); void PrintEnd(); + void Graphics3DContextLost(); + private: bool LoadFindInterface(); bool LoadZoomInterface(); @@ -200,6 +203,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> { // The plugin print interface. const PPP_Printing* plugin_print_interface_; + // The plugin 3D interface. + const PPP_Graphics3D* plugin_graphics_3d_interface_; + // Containes the cursor if it's set by the plugin. scoped_ptr<WebKit::WebCursorInfo> cursor_; diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc index a9ae150..22f0c05 100644 --- a/webkit/glue/plugins/pepper_plugin_module.cc +++ b/webkit/glue/plugins/pepper_plugin_module.cc @@ -18,10 +18,11 @@ #include "third_party/ppapi/c/ppb_file_io.h" #include "third_party/ppapi/c/ppb_file_io_trusted.h" #include "third_party/ppapi/c/ppb_file_system.h" -#include "third_party/ppapi/c/ppb_image_data.h" -#include "third_party/ppapi/c/ppb_instance.h" #include "third_party/ppapi/c/ppb_find.h" #include "third_party/ppapi/c/ppb_font.h" +#include "third_party/ppapi/c/ppb_image_data.h" +#include "third_party/ppapi/c/ppb_instance.h" +#include "third_party/ppapi/c/ppb_opengles.h" #include "third_party/ppapi/c/ppb_scrollbar.h" #include "third_party/ppapi/c/ppb_testing.h" #include "third_party/ppapi/c/ppb_url_loader.h" @@ -59,6 +60,10 @@ #include "webkit/glue/plugins/pepper_widget.h" #include "webkit/glue/plugins/ppb_private.h" +#ifdef ENABLE_GPU +#include "webkit/glue/plugins/pepper_graphics_3d.h" +#endif // ENABLE_GPU + namespace pepper { namespace { @@ -170,6 +175,12 @@ const void* GetInterface(const char* name) { return Audio::GetTrustedInterface(); if (strcmp(name, PPB_DEVICECONTEXT2D_INTERFACE) == 0) return DeviceContext2D::GetInterface(); +#ifdef ENABLE_GPU + if (strcmp(name, PPB_GRAPHICS_3D_INTERFACE) == 0) + return Graphics3D::GetInterface(); + if (strcmp(name, PPB_OPENGLES_INTERFACE) == 0) + return Graphics3D::GetOpenGLESInterface(); +#endif // ENABLE_GPU if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0) return URLLoader::GetInterface(); if (strcmp(name, PPB_URLREQUESTINFO_INTERFACE) == 0) diff --git a/webkit/glue/plugins/pepper_resource.h b/webkit/glue/plugins/pepper_resource.h index 568f02b..b53b3ff 100644 --- a/webkit/glue/plugins/pepper_resource.h +++ b/webkit/glue/plugins/pepper_resource.h @@ -22,6 +22,7 @@ class FileChooser; class FileIO; class FileRef; class Font; +class Graphics3D; class ImageData; class PluginModule; class PrivateFontFile; @@ -85,6 +86,7 @@ class Resource : public base::RefCountedThreadSafe<Resource> { virtual FileIO* AsFileIO() { return NULL; } virtual FileRef* AsFileRef() { return NULL; } virtual Font* AsFont() { return NULL; } + virtual Graphics3D* AsGraphics3D() { return NULL; } virtual ImageData* AsImageData() { return NULL; } virtual PrivateFontFile* AsPrivateFontFile() { return NULL; } virtual Scrollbar* AsScrollbar() { return NULL; } @@ -132,6 +134,7 @@ DEFINE_RESOURCE_CAST(FileChooser) DEFINE_RESOURCE_CAST(FileIO) DEFINE_RESOURCE_CAST(FileRef) DEFINE_RESOURCE_CAST(Font) +DEFINE_RESOURCE_CAST(Graphics3D) DEFINE_RESOURCE_CAST(ImageData) DEFINE_RESOURCE_CAST(PrivateFontFile) DEFINE_RESOURCE_CAST(Scrollbar) diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 0975e96..035ed6d 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -111,6 +111,7 @@ 'dependencies': [ '<(DEPTH)/app/app.gyp:app_base', '<(DEPTH)/base/base.gyp:base_i18n', + '<(DEPTH)/gpu/gpu.gyp:gles2_implementation', '<(DEPTH)/net/net.gyp:net', '<(DEPTH)/printing/printing.gyp:printing', '<(DEPTH)/skia/skia.gyp:skia', @@ -384,6 +385,11 @@ }, }], ['enable_gpu==1 and inside_chromium_build==1', { + 'sources': [ + 'plugins/pepper_graphics_3d_gl.cc', + 'plugins/pepper_graphics_3d.cc', + 'plugins/pepper_graphics_3d.h', + ], 'dependencies': [ '<(DEPTH)/gpu/gpu.gyp:gpu_plugin', ], |