summaryrefslogtreecommitdiffstats
path: root/webkit/gpu
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-26 03:23:48 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-26 03:23:48 +0000
commit1fb9e7ebc8d70d2cccd621f88c1653c8d66d0e2c (patch)
tree0ec4a91b44f2761aba60c04bc5c30c249d358c20 /webkit/gpu
parent51f5a060ee080c0154652c8c4ae541665789bbaa (diff)
downloadchromium_src-1fb9e7ebc8d70d2cccd621f88c1653c8d66d0e2c.zip
chromium_src-1fb9e7ebc8d70d2cccd621f88c1653c8d66d0e2c.tar.gz
chromium_src-1fb9e7ebc8d70d2cccd621f88c1653c8d66d0e2c.tar.bz2
Move webkit/gpu into webkit/common/gpu
The code in webkit/gpu is needed everywhere the compositor is used, which means both renderer and browser processes. This is a bit of a bummer but hard to fix immediately since the compositor uses WebKit::WebGraphicsContext3D. webkit/gpu itself only depends on the context type (which is just a vtable) and a couple exported functions from WebString, so it's not the end of the world to have it linked into every process. This moves the code into webkit/common/ to make this clearer. R=piman, joth BUG=237267 Review URL: https://chromiumcodereview.appspot.com/16046003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202341 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/gpu')
-rw-r--r--webkit/gpu/OWNERS3
-rw-r--r--webkit/gpu/context_provider_in_process.cc134
-rw-r--r--webkit/gpu/context_provider_in_process.h64
-rw-r--r--webkit/gpu/gl_bindings_skia_cmd_buffer.cc128
-rw-r--r--webkit/gpu/gl_bindings_skia_cmd_buffer.h22
-rw-r--r--webkit/gpu/grcontext_for_webgraphicscontext3d.cc70
-rw-r--r--webkit/gpu/grcontext_for_webgraphicscontext3d.h40
-rw-r--r--webkit/gpu/test_context_provider_factory.cc46
-rw-r--r--webkit/gpu/test_context_provider_factory.h41
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc2012
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h610
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_impl.cc1813
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_impl.h577
-rw-r--r--webkit/gpu/webgraphicscontext3d_provider_impl.cc27
-rw-r--r--webkit/gpu/webgraphicscontext3d_provider_impl.h36
-rw-r--r--webkit/gpu/webkit_gpu.gyp56
-rw-r--r--webkit/gpu/webkit_gpu_export.h29
17 files changed, 0 insertions, 5708 deletions
diff --git a/webkit/gpu/OWNERS b/webkit/gpu/OWNERS
deleted file mode 100644
index 461a3b1..0000000
--- a/webkit/gpu/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-kbr@chromium.org
-apatrick@chromium.org
-gman@chromium.org
diff --git a/webkit/gpu/context_provider_in_process.cc b/webkit/gpu/context_provider_in_process.cc
deleted file mode 100644
index a8855ab..0000000
--- a/webkit/gpu/context_provider_in_process.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) 2013 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/gpu/context_provider_in_process.h"
-
-#include "webkit/gpu/grcontext_for_webgraphicscontext3d.h"
-
-namespace webkit {
-namespace gpu {
-
-class ContextProviderInProcess::LostContextCallbackProxy
- : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
- public:
- explicit LostContextCallbackProxy(ContextProviderInProcess* provider)
- : provider_(provider) {
- provider_->context3d_->setContextLostCallback(this);
- }
-
- virtual void onContextLost() {
- provider_->OnLostContextInternal();
- }
-
- private:
- ContextProviderInProcess* provider_;
-};
-
-class ContextProviderInProcess::MemoryAllocationCallbackProxy
- : public WebKit::WebGraphicsContext3D::
- WebGraphicsMemoryAllocationChangedCallbackCHROMIUM {
- public:
- explicit MemoryAllocationCallbackProxy(ContextProviderInProcess* provider)
- : provider_(provider) {
- provider_->context3d_->setMemoryAllocationChangedCallbackCHROMIUM(this);
- }
-
- virtual void onMemoryAllocationChanged(
- WebKit::WebGraphicsMemoryAllocation alloc) {
- provider_->OnMemoryAllocationChanged(!!alloc.gpuResourceSizeInBytes);
- }
-
- private:
- ContextProviderInProcess* provider_;
-};
-
-ContextProviderInProcess::ContextProviderInProcess()
- : destroyed_(false) {
-}
-
-ContextProviderInProcess::~ContextProviderInProcess() {}
-
-bool ContextProviderInProcess::InitializeOnMainThread() {
- DCHECK(!context3d_);
-
- WebKit::WebGraphicsContext3D::Attributes attributes;
- attributes.depth = false;
- attributes.stencil = true;
- attributes.antialias = false;
- attributes.shareResources = true;
- attributes.noAutomaticFlushes = true;
-
- using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
- context3d_.reset(
- WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- attributes));
-
- return context3d_;
-}
-
-bool ContextProviderInProcess::BindToCurrentThread() {
- DCHECK(context3d_);
-
- if (lost_context_callback_proxy_)
- return true;
-
- if (!context3d_->makeContextCurrent())
- return false;
-
- lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this));
- return true;
-}
-
-WebKit::WebGraphicsContext3D* ContextProviderInProcess::Context3d() {
- DCHECK(context3d_);
- DCHECK(lost_context_callback_proxy_); // Is bound to thread.
-
- return context3d_.get();
-}
-
-class GrContext* ContextProviderInProcess::GrContext() {
- DCHECK(context3d_);
- DCHECK(lost_context_callback_proxy_); // Is bound to thread.
-
- if (gr_context_)
- return gr_context_->get();
-
- gr_context_.reset(
- new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get()));
- memory_allocation_callback_proxy_.reset(
- new MemoryAllocationCallbackProxy(this));
- return gr_context_->get();
-}
-
-void ContextProviderInProcess::VerifyContexts() {
- DCHECK(context3d_);
- DCHECK(lost_context_callback_proxy_); // Is bound to thread.
-
- if (context3d_->isContextLost())
- OnLostContextInternal();
-}
-
-void ContextProviderInProcess::OnLostContextInternal() {
- {
- base::AutoLock lock(destroyed_lock_);
- if (destroyed_)
- return;
- destroyed_ = true;
- }
- OnLostContext();
-}
-
-bool ContextProviderInProcess::DestroyedOnMainThread() {
- base::AutoLock lock(destroyed_lock_);
- return destroyed_;
-}
-
-void ContextProviderInProcess::OnMemoryAllocationChanged(
- bool nonzero_allocation) {
- if (gr_context_)
- gr_context_->SetMemoryLimit(nonzero_allocation);
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/webkit/gpu/context_provider_in_process.h b/webkit/gpu/context_provider_in_process.h
deleted file mode 100644
index fd9c5f0..0000000
--- a/webkit/gpu/context_provider_in_process.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2013 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_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_
-#define WEBKIT_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_
-
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/synchronization/lock.h"
-#include "cc/output/context_provider.h"
-#include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
-#include "webkit/gpu/webkit_gpu_export.h"
-
-namespace webkit {
-namespace gpu {
-class GrContextForWebGraphicsContext3D;
-
-class WEBKIT_GPU_EXPORT ContextProviderInProcess
- : NON_EXPORTED_BASE(public cc::ContextProvider) {
- public:
- static scoped_refptr<ContextProviderInProcess> Create() {
- scoped_refptr<ContextProviderInProcess> provider =
- new ContextProviderInProcess;
- if (!provider->InitializeOnMainThread())
- return NULL;
- return provider;
- }
-
- virtual bool BindToCurrentThread() OVERRIDE;
- virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE;
- virtual class GrContext* GrContext() OVERRIDE;
- virtual void VerifyContexts() OVERRIDE;
- virtual bool DestroyedOnMainThread() OVERRIDE;
-
- protected:
- ContextProviderInProcess();
- virtual ~ContextProviderInProcess();
-
- bool InitializeOnMainThread();
-
- void OnLostContextInternal();
- virtual void OnLostContext() {}
- virtual void OnMemoryAllocationChanged(bool nonzero_allocation);
-
- private:
- scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
- context3d_;
- scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_;
-
- base::Lock destroyed_lock_;
- bool destroyed_;
-
- class LostContextCallbackProxy;
- scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_;
-
- class MemoryAllocationCallbackProxy;
- scoped_ptr<MemoryAllocationCallbackProxy> memory_allocation_callback_proxy_;
-};
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // WEBKIT_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_
diff --git a/webkit/gpu/gl_bindings_skia_cmd_buffer.cc b/webkit/gpu/gl_bindings_skia_cmd_buffer.cc
deleted file mode 100644
index 53e98f1..0000000
--- a/webkit/gpu/gl_bindings_skia_cmd_buffer.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (c) 2011 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/gpu/gl_bindings_skia_cmd_buffer.h"
-
-#ifndef GL_GLEXT_PROTOTYPES
-#define GL_GLEXT_PROTOTYPES
-#endif
-#include "gpu/GLES2/gl2extchromium.h"
-#include "third_party/khronos/GLES2/gl2.h"
-#include "third_party/khronos/GLES2/gl2ext.h"
-#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
-
-namespace webkit {
-namespace gpu {
-
-GrGLInterface* CreateCommandBufferSkiaGLBinding() {
- GrGLInterface* interface = new GrGLInterface;
- interface->fBindingsExported = kES2_GrGLBinding;
- interface->fActiveTexture = glActiveTexture;
- interface->fAttachShader = glAttachShader;
- interface->fBindAttribLocation = glBindAttribLocation;
- interface->fBindBuffer = glBindBuffer;
- interface->fBindTexture = glBindTexture;
- interface->fBindVertexArray = glBindVertexArrayOES;
- interface->fBlendColor = glBlendColor;
- interface->fBlendFunc = glBlendFunc;
- interface->fBufferData = glBufferData;
- interface->fBufferSubData = glBufferSubData;
- interface->fClear = glClear;
- interface->fClearColor = glClearColor;
- interface->fClearStencil = glClearStencil;
- interface->fColorMask = glColorMask;
- interface->fCompileShader = glCompileShader;
- interface->fCompressedTexImage2D = glCompressedTexImage2D;
- interface->fCopyTexSubImage2D = glCopyTexSubImage2D;
- interface->fCreateProgram = glCreateProgram;
- interface->fCreateShader = glCreateShader;
- interface->fCullFace = glCullFace;
- interface->fDeleteBuffers = glDeleteBuffers;
- interface->fDeleteProgram = glDeleteProgram;
- interface->fDeleteShader = glDeleteShader;
- interface->fDeleteTextures = glDeleteTextures;
- interface->fDeleteVertexArrays = glDeleteVertexArraysOES;
- interface->fDepthMask = glDepthMask;
- interface->fDisable = glDisable;
- interface->fDisableVertexAttribArray = glDisableVertexAttribArray;
- interface->fDrawArrays = glDrawArrays;
- interface->fDrawElements = glDrawElements;
- interface->fEnable = glEnable;
- interface->fEnableVertexAttribArray = glEnableVertexAttribArray;
- interface->fFinish = glFinish;
- interface->fFlush = glFlush;
- interface->fFrontFace = glFrontFace;
- interface->fGenBuffers = glGenBuffers;
- interface->fGenTextures = glGenTextures;
- interface->fGenVertexArrays = glGenVertexArraysOES;
- interface->fGetBufferParameteriv = glGetBufferParameteriv;
- interface->fGetError = glGetError;
- interface->fGetIntegerv = glGetIntegerv;
- interface->fGetProgramInfoLog = glGetProgramInfoLog;
- interface->fGetProgramiv = glGetProgramiv;
- interface->fGetShaderInfoLog = glGetShaderInfoLog;
- interface->fGetShaderiv = glGetShaderiv;
- interface->fGetString = glGetString;
- interface->fGetUniformLocation = glGetUniformLocation;
- interface->fLineWidth = glLineWidth;
- interface->fLinkProgram = glLinkProgram;
- interface->fPixelStorei = glPixelStorei;
- interface->fReadPixels = glReadPixels;
- interface->fScissor = glScissor;
- interface->fShaderSource = glShaderSource;
- interface->fStencilFunc = glStencilFunc;
- interface->fStencilFuncSeparate = glStencilFuncSeparate;
- interface->fStencilMask = glStencilMask;
- interface->fStencilMaskSeparate = glStencilMaskSeparate;
- interface->fStencilOp = glStencilOp;
- interface->fStencilOpSeparate = glStencilOpSeparate;
- interface->fTexImage2D = glTexImage2D;
- interface->fTexParameteri = glTexParameteri;
- interface->fTexParameteriv = glTexParameteriv;
- interface->fTexStorage2D = glTexStorage2DEXT;
- interface->fTexSubImage2D = glTexSubImage2D;
- interface->fUniform1f = glUniform1f;
- interface->fUniform1i = glUniform1i;
- interface->fUniform1fv = glUniform1fv;
- interface->fUniform1iv = glUniform1iv;
- interface->fUniform2f = glUniform2f;
- interface->fUniform2i = glUniform2i;
- interface->fUniform2fv = glUniform2fv;
- interface->fUniform2iv = glUniform2iv;
- interface->fUniform3f = glUniform3f;
- interface->fUniform3i = glUniform3i;
- interface->fUniform3fv = glUniform3fv;
- interface->fUniform3iv = glUniform3iv;
- interface->fUniform4f = glUniform4f;
- interface->fUniform4i = glUniform4i;
- interface->fUniform4fv = glUniform4fv;
- interface->fUniform4iv = glUniform4iv;
- interface->fUniformMatrix2fv = glUniformMatrix2fv;
- interface->fUniformMatrix3fv = glUniformMatrix3fv;
- interface->fUniformMatrix4fv = glUniformMatrix4fv;
- interface->fUseProgram = glUseProgram;
- interface->fVertexAttrib4fv = glVertexAttrib4fv;
- interface->fVertexAttribPointer = glVertexAttribPointer;
- interface->fViewport = glViewport;
- interface->fBindFramebuffer = glBindFramebuffer;
- interface->fBindRenderbuffer = glBindRenderbuffer;
- interface->fCheckFramebufferStatus = glCheckFramebufferStatus;
- interface->fDeleteFramebuffers = glDeleteFramebuffers;
- interface->fDeleteRenderbuffers = glDeleteRenderbuffers;
- interface->fFramebufferRenderbuffer = glFramebufferRenderbuffer;
- interface->fFramebufferTexture2D = glFramebufferTexture2D;
- interface->fGenFramebuffers = glGenFramebuffers;
- interface->fGenRenderbuffers = glGenRenderbuffers;
- interface->fGetFramebufferAttachmentParameteriv =
- glGetFramebufferAttachmentParameteriv;
- interface->fGetRenderbufferParameteriv = glGetRenderbufferParameteriv;
- interface->fRenderbufferStorage = glRenderbufferStorage;
- interface->fRenderbufferStorageMultisample =
- glRenderbufferStorageMultisampleEXT;
- interface->fBlitFramebuffer = glBlitFramebufferEXT;
- return interface;
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/webkit/gpu/gl_bindings_skia_cmd_buffer.h b/webkit/gpu/gl_bindings_skia_cmd_buffer.h
deleted file mode 100644
index 9ace2c1..0000000
--- a/webkit/gpu/gl_bindings_skia_cmd_buffer.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2011 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_GPU_GL_BINDINGS_SKIA_CMD_BUFFER_H_
-#define WEBKIT_GPU_GL_BINDINGS_SKIA_CMD_BUFFER_H_
-
-#include "webkit/gpu/webkit_gpu_export.h"
-
-struct GrGLInterface;
-
-namespace webkit {
-namespace gpu {
-
-// The GPU back-end for skia requires pointers to GL functions. This function
-// returns a binding for skia-gpu to the cmd buffers GL.
-WEBKIT_GPU_EXPORT GrGLInterface* CreateCommandBufferSkiaGLBinding();
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // WEBKIT_GLUE_GL_BINDINGS_SKIA_CMD_BUFFER_H_
diff --git a/webkit/gpu/grcontext_for_webgraphicscontext3d.cc b/webkit/gpu/grcontext_for_webgraphicscontext3d.cc
deleted file mode 100644
index a1d3abd..0000000
--- a/webkit/gpu/grcontext_for_webgraphicscontext3d.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2013 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/gpu/grcontext_for_webgraphicscontext3d.h"
-
-#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
-#include "third_party/skia/include/gpu/GrContext.h"
-#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
-
-namespace webkit {
-namespace gpu {
-
-static void BindWebGraphicsContext3DGLContextCallback(
- const GrGLInterface* interface) {
- reinterpret_cast<WebKit::WebGraphicsContext3D*>(
- interface->fCallbackData)->makeContextCurrent();
-}
-
-GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D(
- WebKit::WebGraphicsContext3D* context3d) {
- if (!context3d)
- return;
-
- skia::RefPtr<GrGLInterface> interface = skia::AdoptRef(
- context3d->createGrGLInterface());
- if (!interface)
- return;
-
- interface->fCallback = BindWebGraphicsContext3DGLContextCallback;
- interface->fCallbackData =
- reinterpret_cast<GrGLInterfaceCallbackData>(context3d);
-
- gr_context_ = skia::AdoptRef(GrContext::Create(
- kOpenGL_GrBackend,
- reinterpret_cast<GrBackendContext>(interface.get())));
- if (!gr_context_)
- return;
-
- bool nonzero_allocation = true;
- SetMemoryLimit(nonzero_allocation);
-}
-
-GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() {
- if (gr_context_)
- gr_context_->contextDestroyed();
-}
-
-void GrContextForWebGraphicsContext3D::SetMemoryLimit(bool nonzero_allocation) {
- if (!gr_context_)
- return;
-
- if (nonzero_allocation) {
- // The limit of the number of textures we hold in the GrContext's
- // bitmap->texture cache.
- static const int kMaxGaneshTextureCacheCount = 2048;
- // The limit of the bytes allocated toward textures in the GrContext's
- // bitmap->texture cache.
- static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024;
-
- gr_context_->setTextureCacheLimits(
- kMaxGaneshTextureCacheCount, kMaxGaneshTextureCacheBytes);
- } else {
- gr_context_->freeGpuResources();
- gr_context_->setTextureCacheLimits(0, 0);
- }
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/webkit/gpu/grcontext_for_webgraphicscontext3d.h b/webkit/gpu/grcontext_for_webgraphicscontext3d.h
deleted file mode 100644
index 6b7feed..0000000
--- a/webkit/gpu/grcontext_for_webgraphicscontext3d.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2013 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_GPU_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_
-#define WEBKIT_GPU_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_
-
-#include "base/basictypes.h"
-#include "skia/ext/refptr.h"
-#include "webkit/gpu/webkit_gpu_export.h"
-
-class GrContext;
-namespace WebKit { class WebGraphicsContext3D; }
-
-namespace webkit {
-namespace gpu {
-
-// This class binds an offscreen GrContext to an offscreen context3d. The
-// context3d is used by the GrContext so must be valid as long as this class
-// is alive.
-class WEBKIT_GPU_EXPORT GrContextForWebGraphicsContext3D {
- public:
- explicit GrContextForWebGraphicsContext3D(
- WebKit::WebGraphicsContext3D* context3d);
- virtual ~GrContextForWebGraphicsContext3D();
-
- GrContext* get() { return gr_context_.get(); }
-
- void SetMemoryLimit(bool nonzero_allocation);
-
- private:
- skia::RefPtr<class GrContext> gr_context_;
-
- DISALLOW_COPY_AND_ASSIGN(GrContextForWebGraphicsContext3D);
-};
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // WEBKIT_GPU_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_
diff --git a/webkit/gpu/test_context_provider_factory.cc b/webkit/gpu/test_context_provider_factory.cc
deleted file mode 100644
index a8ac73b..0000000
--- a/webkit/gpu/test_context_provider_factory.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2013 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/gpu/test_context_provider_factory.h"
-
-#include "base/logging.h"
-#include "cc/output/context_provider.h"
-#include "webkit/gpu/context_provider_in_process.h"
-
-namespace webkit {
-namespace gpu {
-
-static TestContextProviderFactory* context_provider_instance = NULL;
-
-// static
-TestContextProviderFactory* TestContextProviderFactory::GetInstance() {
- if (!context_provider_instance)
- context_provider_instance = new TestContextProviderFactory();
- return context_provider_instance;
-}
-
-TestContextProviderFactory::TestContextProviderFactory() {}
-
-TestContextProviderFactory::~TestContextProviderFactory() {}
-
-scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
- OffscreenContextProviderForMainThread() {
- if (!main_thread_ || main_thread_->DestroyedOnMainThread()) {
- main_thread_ = ContextProviderInProcess::Create();
- if (main_thread_ && !main_thread_->BindToCurrentThread())
- main_thread_ = NULL;
- }
- return main_thread_;
-}
-
-scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
- OffscreenContextProviderForCompositorThread() {
- if (!compositor_thread_ ||
- compositor_thread_->DestroyedOnMainThread())
- compositor_thread_ = ContextProviderInProcess::Create();
- return compositor_thread_;
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/webkit/gpu/test_context_provider_factory.h b/webkit/gpu/test_context_provider_factory.h
deleted file mode 100644
index b173daf..0000000
--- a/webkit/gpu/test_context_provider_factory.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2013 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_GPU_TEST_CONTEXT_PROVIDER_FACTORY_H_
-#define WEBKIT_GPU_TEST_CONTEXT_PROVIDER_FACTORY_H_
-
-#include "base/memory/ref_counted.h"
-#include "webkit/gpu/webkit_gpu_export.h"
-
-namespace cc {
-class ContextProvider;
-}
-
-namespace webkit {
-namespace gpu {
-class ContextProviderInProcess;
-
-class WEBKIT_GPU_EXPORT TestContextProviderFactory {
- public:
- // The returned pointer is static and should not be deleted by the caller.
- static TestContextProviderFactory* GetInstance();
-
- scoped_refptr<cc::ContextProvider> OffscreenContextProviderForMainThread();
- scoped_refptr<cc::ContextProvider>
- OffscreenContextProviderForCompositorThread();
-
- private:
- TestContextProviderFactory();
- ~TestContextProviderFactory();
-
- scoped_refptr<webkit::gpu::ContextProviderInProcess> main_thread_;
- scoped_refptr<webkit::gpu::ContextProviderInProcess> compositor_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(TestContextProviderFactory);
-};
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // WEBKIT_GPU_TEST_WEBKIT_CONTEXT_PROVIDER_FACTORY_H_
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
deleted file mode 100644
index 5235e22..0000000
--- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ /dev/null
@@ -1,2012 +0,0 @@
-// Copyright (c) 2012 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/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
-
-#include <GLES2/gl2.h>
-#ifndef GL_GLEXT_PROTOTYPES
-#define GL_GLEXT_PROTOTYPES 1
-#endif
-#include <GLES2/gl2ext.h>
-#include <GLES2/gl2extchromium.h>
-
-#include <algorithm>
-#include <set>
-#include <string>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/command_line.h"
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-#include "base/message_loop.h"
-#include "base/metrics/histogram.h"
-#include "base/synchronization/lock.h"
-#include "gpu/command_buffer/client/gles2_implementation.h"
-#include "gpu/command_buffer/client/gles2_lib.h"
-#include "gpu/command_buffer/client/image_factory.h"
-#include "gpu/command_buffer/client/transfer_buffer.h"
-#include "gpu/command_buffer/common/constants.h"
-#include "gpu/command_buffer/service/command_buffer_service.h"
-#include "gpu/command_buffer/service/context_group.h"
-#include "gpu/command_buffer/service/gl_context_virtual.h"
-#include "gpu/command_buffer/service/gpu_scheduler.h"
-#include "gpu/command_buffer/service/image_manager.h"
-#include "gpu/command_buffer/service/transfer_buffer_manager.h"
-#include "ui/gl/gl_context.h"
-#include "ui/gl/gl_image.h"
-#include "ui/gl/gl_share_group.h"
-#include "ui/gl/gl_surface.h"
-#include "webkit/gpu/gl_bindings_skia_cmd_buffer.h"
-
-using gpu::Buffer;
-using gpu::CommandBuffer;
-using gpu::CommandBufferService;
-using gpu::gles2::GLES2CmdHelper;
-using gpu::gles2::GLES2Implementation;
-using gpu::gles2::ImageFactory;
-using gpu::gles2::ImageManager;
-using gpu::GpuMemoryBuffer;
-using gpu::GpuScheduler;
-using gpu::TransferBuffer;
-using gpu::TransferBufferManager;
-using gpu::TransferBufferManagerInterface;
-
-namespace webkit {
-namespace gpu {
-namespace {
-class ImageFactoryInProcess;
-}
-
-class GLInProcessContext {
- public:
- // These are the same error codes as used by EGL.
- enum Error {
- SUCCESS = 0x3000,
- NOT_INITIALIZED = 0x3001,
- BAD_ATTRIBUTE = 0x3004,
- BAD_GLContext = 0x3006,
- CONTEXT_LOST = 0x300E
- };
-
- // GLInProcessContext configuration attributes. These are the same as used by
- // EGL. Attributes are matched using a closest fit algorithm.
- enum Attribute {
- ALPHA_SIZE = 0x3021,
- BLUE_SIZE = 0x3022,
- GREEN_SIZE = 0x3023,
- RED_SIZE = 0x3024,
- DEPTH_SIZE = 0x3025,
- STENCIL_SIZE = 0x3026,
- SAMPLES = 0x3031,
- SAMPLE_BUFFERS = 0x3032,
- NONE = 0x3038 // Attrib list = terminator
- };
-
- // Initialize the library. This must have completed before any other
- // functions are invoked.
- static bool Initialize();
-
- // Terminate the library. This must be called after any other functions
- // have completed.
- static bool Terminate();
-
- ~GLInProcessContext();
-
- void PumpCommands();
- bool GetBufferChanged(int32 transfer_buffer_id);
-
- // Create a GLInProcessContext, if |is_offscreen| is true, renders to an
- // offscreen context. |attrib_list| must be NULL or a NONE-terminated list
- // of attribute/value pairs.
- static GLInProcessContext* CreateContext(
- bool is_offscreen,
- gfx::AcceleratedWidget window,
- const gfx::Size& size,
- bool share_resources,
- const char* allowed_extensions,
- const int32* attrib_list,
- gfx::GpuPreference gpu_preference);
-
- // For an offscreen frame buffer GLInProcessContext, return the texture ID
- // with respect to the parent GLInProcessContext. Returns zero if
- // GLInProcessContext does not have a parent.
- uint32 GetParentTextureId();
-
- // Create a new texture in the parent's GLInProcessContext. Returns zero if
- // GLInProcessContext does not have a parent.
- uint32 CreateParentTexture(const gfx::Size& size);
-
- // Deletes a texture in the parent's GLInProcessContext.
- void DeleteParentTexture(uint32 texture);
-
- void SetContextLostCallback(const base::Closure& callback);
-
- // Set the current GLInProcessContext for the calling thread.
- static bool MakeCurrent(GLInProcessContext* context);
-
- // For a view GLInProcessContext, display everything that has been rendered
- // since the last call. For an offscreen GLInProcessContext, resolve
- // everything that has been rendered since the last call to a copy that can be
- // accessed by the parent GLInProcessContext.
- bool SwapBuffers();
-
- // TODO(gman): Remove this
- void DisableShaderTranslation();
-
- // Allows direct access to the GLES2 implementation so a GLInProcessContext
- // can be used without making it current.
- GLES2Implementation* GetImplementation();
-
- // Return the current error.
- Error GetError();
-
- // Return true if GPU process reported GLInProcessContext lost or there was a
- // problem communicating with the GPU process.
- bool IsCommandBufferContextLost();
-
- void LoseContext(uint32 current, uint32 other);
-
- void SetSignalSyncPointCallback(
- scoped_ptr<
- WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback> callback);
-
- CommandBufferService* GetCommandBufferService();
-
- ::gpu::gles2::GLES2Decoder* GetDecoder();
-
- void OnResizeView(gfx::Size size, float scale_factor);
-
- private:
- explicit GLInProcessContext(bool share_resources);
-
- bool Initialize(bool is_offscreen,
- gfx::AcceleratedWidget window,
- const gfx::Size& size,
- const char* allowed_extensions,
- const int32* attrib_list,
- gfx::GpuPreference gpu_preference);
- void Destroy();
-
- void OnContextLost();
-
- ::gpu::gles2::ImageManager* GetImageManager();
-
- scoped_refptr<ImageFactoryInProcess> GetImageFactory();
-
- base::Closure context_lost_callback_;
- scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
- scoped_ptr<CommandBufferService> command_buffer_;
- scoped_ptr< ::gpu::GpuScheduler> gpu_scheduler_;
- scoped_ptr< ::gpu::gles2::GLES2Decoder> decoder_;
- scoped_refptr<gfx::GLContext> context_;
- scoped_refptr<gfx::GLSurface> surface_;
- scoped_ptr<GLES2CmdHelper> gles2_helper_;
- scoped_ptr<TransferBuffer> transfer_buffer_;
- scoped_ptr<GLES2Implementation> gles2_implementation_;
- scoped_refptr<ImageFactoryInProcess> image_factory_;
- scoped_ptr<WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback>
- signal_sync_point_callback_;
- Error last_error_;
- bool share_resources_;
- bool context_lost_;
-
- DISALLOW_COPY_AND_ASSIGN(GLInProcessContext);
-};
-
-namespace {
-
-const int32 kCommandBufferSize = 1024 * 1024;
-// TODO(kbr): make the transfer buffer size configurable via context
-// creation attributes.
-const size_t kStartTransferBufferSize = 4 * 1024 * 1024;
-const size_t kMinTransferBufferSize = 1 * 256 * 1024;
-const size_t kMaxTransferBufferSize = 16 * 1024 * 1024;
-
-// Singleton used to initialize and terminate the gles2 library.
-class GLES2Initializer {
- public:
- GLES2Initializer() {
- gles2::Initialize();
- }
-
- ~GLES2Initializer() {
- gles2::Terminate();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
-static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
- LAZY_INSTANCE_INITIALIZER;
-
-} // namespace anonymous
-
-GLInProcessContext::~GLInProcessContext() {
- Destroy();
-}
-
-GLInProcessContext* GLInProcessContext::CreateContext(
- bool is_offscreen,
- gfx::AcceleratedWidget window,
- const gfx::Size& size,
- bool share_resources,
- const char* allowed_extensions,
- const int32* attrib_list,
- gfx::GpuPreference gpu_preference) {
- scoped_ptr<GLInProcessContext> context(
- new GLInProcessContext(share_resources));
- if (!context->Initialize(
- is_offscreen,
- window,
- size,
- allowed_extensions,
- attrib_list,
- gpu_preference))
- return NULL;
-
- return context.release();
-}
-
-// In the normal command buffer implementation, all commands are passed over IPC
-// to the gpu process where they are fed to the GLES2Decoder from a single
-// thread. In layout tests, any thread could call this function. GLES2Decoder,
-// and in particular the GL implementations behind it, are not generally
-// threadsafe, so we guard entry points with a mutex.
-static base::LazyInstance<base::Lock> g_decoder_lock =
- LAZY_INSTANCE_INITIALIZER;
-
-static base::LazyInstance<
- std::set<GLInProcessContext*> >
- g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER;
-
-static bool g_use_virtualized_gl_context = false;
-
-namespace {
-
-// Also calls DetachFromThread on all GLES2Decoders before the lock is released
-// to maintain the invariant that all decoders are unbounded while the lock is
-// not held. This is to workaround DumpRenderTree uses WGC3DIPCBI with shared
-// resources on different threads.
-class AutoLockAndDecoderDetachThread {
- public:
- AutoLockAndDecoderDetachThread(base::Lock& lock,
- const std::set<GLInProcessContext*>& contexts);
- ~AutoLockAndDecoderDetachThread();
-
- private:
- base::AutoLock auto_lock_;
- const std::set<GLInProcessContext*>& contexts_;
-};
-
-AutoLockAndDecoderDetachThread::AutoLockAndDecoderDetachThread(
- base::Lock& lock,
- const std::set<GLInProcessContext*>& contexts)
- : auto_lock_(lock),
- contexts_(contexts) {
-}
-
-void DetachThread(GLInProcessContext* context) {
- if (context->GetDecoder())
- context->GetDecoder()->DetachFromThread();
-}
-
-AutoLockAndDecoderDetachThread::~AutoLockAndDecoderDetachThread() {
- std::for_each(contexts_.begin(),
- contexts_.end(),
- &DetachThread);
-}
-
-static WebGraphicsContext3DInProcessCommandBufferImpl::GpuMemoryBufferCreator*
- g_gpu_memory_buffer_creator = NULL;
-
-class ImageFactoryInProcess
- : public ImageFactory,
- public base::RefCountedThreadSafe<ImageFactoryInProcess> {
- public:
- explicit ImageFactoryInProcess(ImageManager* image_manager);
-
- // methods from ImageFactory
- virtual scoped_ptr<GpuMemoryBuffer> CreateGpuMemoryBuffer(
- int width, int height, GLenum internalformat,
- unsigned* image_id) OVERRIDE;
- virtual void DeleteGpuMemoryBuffer(unsigned image_id) OVERRIDE;
- private:
- friend class base::RefCountedThreadSafe<ImageFactoryInProcess>;
- virtual ~ImageFactoryInProcess();
-
- // ImageManager is referred by the ContextGroup and the
- // ContextGroup outlives the client.
- ImageManager* image_manager_;
- unsigned next_id_;
-
- DISALLOW_COPY_AND_ASSIGN(ImageFactoryInProcess);
-};
-
-ImageFactoryInProcess::ImageFactoryInProcess(
- ImageManager* image_manager) : image_manager_(image_manager),
- next_id_(0) {
-}
-
-ImageFactoryInProcess::~ImageFactoryInProcess() {
-}
-
-scoped_ptr<GpuMemoryBuffer> ImageFactoryInProcess::CreateGpuMemoryBuffer(
- int width, int height, GLenum internalformat, unsigned int* image_id) {
- // We're taking the lock here because we're accessing the ContextGroup's
- // shared ImageManager and next_id_.
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- // For Android WebView we assume the |internalformat| will always be
- // GL_RGBA8_OES.
- DCHECK_EQ(GL_RGBA8_OES, internalformat);
- scoped_ptr<GpuMemoryBuffer> buffer =
- g_gpu_memory_buffer_creator(width, height);
-
- if (buffer.get() == NULL)
- return buffer.Pass();
-
- scoped_refptr<gfx::GLImage> gl_image =
- gfx::GLImage::CreateGLImageForGpuMemoryBuffer(buffer->GetNativeBuffer(),
- gfx::Size(width, height));
- *image_id = ++next_id_; // Valid image_ids start from 1.
- image_manager_->AddImage(gl_image, *image_id);
- return buffer.Pass();
-}
-
-void ImageFactoryInProcess::DeleteGpuMemoryBuffer(unsigned int image_id) {
- // We're taking the lock here because we're accessing the ContextGroup's
- // shared ImageManager.
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- image_manager_->RemoveImage(image_id);
-}
-
-} // namespace
-
-static void CallAndDestroy(
- scoped_ptr<
- WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback> callback) {
- callback->onSyncPointReached();
-}
-
-void GLInProcessContext::PumpCommands() {
- if (!context_lost_) {
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- decoder_->MakeCurrent();
- gpu_scheduler_->PutChanged();
- ::gpu::CommandBuffer::State state = command_buffer_->GetState();
- if (::gpu::error::IsError(state.error))
- context_lost_ = true;
- }
-
- if (!context_lost_ && signal_sync_point_callback_) {
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&CallAndDestroy,
- base::Passed(&signal_sync_point_callback_)));
- }
-}
-
-bool GLInProcessContext::GetBufferChanged(int32 transfer_buffer_id) {
- return gpu_scheduler_->SetGetBuffer(transfer_buffer_id);
-}
-
-uint32 GLInProcessContext::GetParentTextureId() {
- return 0;
-}
-
-uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) {
- uint32 texture = 0;
- gles2_implementation_->GenTextures(1, &texture);
- gles2_implementation_->Flush();
- return texture;
-}
-
-void GLInProcessContext::DeleteParentTexture(uint32 texture) {
- gles2_implementation_->DeleteTextures(1, &texture);
-}
-
-void GLInProcessContext::SetContextLostCallback(const base::Closure& callback) {
- context_lost_callback_ = callback;
-}
-
-bool GLInProcessContext::MakeCurrent(GLInProcessContext* context) {
- if (context) {
- gles2::SetGLContext(context->gles2_implementation_.get());
-
- // 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
- // because making GL calls with a NULL context crashes.
- if (context->command_buffer_->GetState().error != ::gpu::error::kNoError)
- return false;
- } else {
- gles2::SetGLContext(NULL);
- }
-
- return true;
-}
-
-bool GLInProcessContext::SwapBuffers() {
- // Don't request latest error status from service. Just use the locally cached
- // information from the last flush.
- if (command_buffer_->GetState().error != ::gpu::error::kNoError)
- return false;
-
- gles2_implementation_->SwapBuffers();
- gles2_implementation_->Finish();
- return true;
-}
-
-GLInProcessContext::Error GLInProcessContext::GetError() {
- CommandBuffer::State state = command_buffer_->GetState();
- if (state.error == ::gpu::error::kNoError) {
- // TODO(gman): Figure out and document what this logic is for.
- Error old_error = last_error_;
- last_error_ = SUCCESS;
- return old_error;
- } else {
- // All command buffer errors are unrecoverable. The error is treated as a
- // lost context: destroy the context and create another one.
- return CONTEXT_LOST;
- }
-}
-
-bool GLInProcessContext::IsCommandBufferContextLost() {
- if (context_lost_ || !command_buffer_) {
- return true;
- }
- CommandBuffer::State state = command_buffer_->GetState();
- return ::gpu::error::IsError(state.error);
-}
-
-void GLInProcessContext::LoseContext(uint32 current, uint32 other) {
- gles2_implementation_->LoseContextCHROMIUM(current, other);
- gles2_implementation_->Finish();
- DCHECK(IsCommandBufferContextLost());
-}
-
-void GLInProcessContext::SetSignalSyncPointCallback(
- scoped_ptr<
- WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback> callback) {
- signal_sync_point_callback_ = callback.Pass();
-}
-
-CommandBufferService* GLInProcessContext::GetCommandBufferService() {
- return command_buffer_.get();
-}
-
-::gpu::gles2::GLES2Decoder* GLInProcessContext::GetDecoder() {
- return decoder_.get();
-}
-
-void GLInProcessContext::OnResizeView(gfx::Size size, float scale_factor) {
- DCHECK(!surface_->IsOffscreen());
- surface_->Resize(size);
-}
-
-// TODO(gman): Remove This
-void GLInProcessContext::DisableShaderTranslation() {
- NOTREACHED();
-}
-
-GLES2Implementation* GLInProcessContext::GetImplementation() {
- return gles2_implementation_.get();
-}
-
-::gpu::gles2::ImageManager* GLInProcessContext::GetImageManager() {
- return decoder_->GetContextGroup()->image_manager();
-}
-
-scoped_refptr<ImageFactoryInProcess> GLInProcessContext::GetImageFactory() {
- return image_factory_;
-}
-
-GLInProcessContext::GLInProcessContext(bool share_resources)
- : last_error_(SUCCESS),
- share_resources_(share_resources),
- context_lost_(false) {
-}
-
-bool GLInProcessContext::Initialize(
- bool is_offscreen,
- gfx::AcceleratedWidget window,
- const gfx::Size& size,
- const char* allowed_extensions,
- const int32* attrib_list,
- gfx::GpuPreference gpu_preference) {
- // Use one share group for all contexts.
- CR_DEFINE_STATIC_LOCAL(scoped_refptr<gfx::GLShareGroup>, share_group,
- (new gfx::GLShareGroup));
-
- DCHECK(size.width() >= 0 && size.height() >= 0);
-
- // Ensure the gles2 library is initialized first in a thread safe way.
- g_gles2_initializer.Get();
-
- std::vector<int32> attribs;
- while (attrib_list) {
- int32 attrib = *attrib_list++;
- switch (attrib) {
- // Known attributes
- case ALPHA_SIZE:
- case BLUE_SIZE:
- case GREEN_SIZE:
- case RED_SIZE:
- case DEPTH_SIZE:
- case STENCIL_SIZE:
- case SAMPLES:
- case SAMPLE_BUFFERS:
- attribs.push_back(attrib);
- attribs.push_back(*attrib_list++);
- break;
- case NONE:
- attribs.push_back(attrib);
- attrib_list = NULL;
- break;
- default:
- last_error_ = BAD_ATTRIBUTE;
- attribs.push_back(NONE);
- attrib_list = NULL;
- break;
- }
- }
-
- {
- TransferBufferManager* manager = new TransferBufferManager();
- transfer_buffer_manager_.reset(manager);
- manager->Initialize();
- }
-
- command_buffer_.reset(
- new CommandBufferService(transfer_buffer_manager_.get()));
- if (!command_buffer_->Initialize()) {
- LOG(ERROR) << "Could not initialize command buffer.";
- Destroy();
- return false;
- }
-
- GLInProcessContext* context_group = NULL;
-
- {
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- if (share_resources_ && !g_all_shared_contexts.Get().empty()) {
- for (std::set<GLInProcessContext*>::iterator it =
- g_all_shared_contexts.Get().begin();
- it != g_all_shared_contexts.Get().end();
- ++it) {
- if (!(*it)->IsCommandBufferContextLost()) {
- context_group = *it;
- break;
- }
- }
- if (!context_group)
- share_group = new gfx::GLShareGroup;
- }
-
- // TODO(gman): This needs to be true if this is Pepper.
- bool bind_generates_resource = false;
- decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group ?
- context_group->decoder_->GetContextGroup() :
- new ::gpu::gles2::ContextGroup(
- NULL, NULL, NULL, bind_generates_resource)));
-
- gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(),
- decoder_.get(),
- decoder_.get()));
-
- decoder_->set_engine(gpu_scheduler_.get());
-
- if (is_offscreen)
- surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, size);
- else
- surface_ = gfx::GLSurface::CreateViewGLSurface(false, window);
-
- if (!surface_) {
- LOG(ERROR) << "Could not create GLSurface.";
- Destroy();
- return false;
- }
-
- if (g_use_virtualized_gl_context) {
- context_ = share_group->GetSharedContext();
- if (!context_) {
- context_ = gfx::GLContext::CreateGLContext(share_group.get(),
- surface_.get(),
- gpu_preference);
- share_group->SetSharedContext(context_);
- }
-
- context_ = new ::gpu::GLContextVirtual(share_group.get(),
- context_,
- decoder_->AsWeakPtr());
- if (context_->Initialize(surface_, gpu_preference)) {
- VLOG(1) << "Created virtual GL context.";
- } else {
- context_ = NULL;
- }
- } else {
- context_ = gfx::GLContext::CreateGLContext(share_group.get(),
- surface_.get(),
- gpu_preference);
- }
-
- if (!context_) {
- LOG(ERROR) << "Could not create GLContext.";
- Destroy();
- return false;
- }
-
- if (!context_->MakeCurrent(surface_)) {
- LOG(ERROR) << "Could not make context current.";
- Destroy();
- return false;
- }
-
- ::gpu::gles2::DisallowedFeatures disallowed_features;
- disallowed_features.swap_buffer_complete_callback = true;
- disallowed_features.gpu_memory_manager = true;
- if (!decoder_->Initialize(surface_,
- context_,
- is_offscreen,
- size,
- disallowed_features,
- allowed_extensions,
- attribs)) {
- LOG(ERROR) << "Could not initialize decoder.";
- Destroy();
- return false;
- }
-
- if (!is_offscreen) {
- decoder_->SetResizeCallback(base::Bind(&GLInProcessContext::OnResizeView,
- base::Unretained(this)));
- }
- }
-
- command_buffer_->SetPutOffsetChangeCallback(
- base::Bind(&GLInProcessContext::PumpCommands, base::Unretained(this)));
- command_buffer_->SetGetBufferChangeCallback(
- base::Bind(
- &GLInProcessContext::GetBufferChanged, base::Unretained(this)));
- command_buffer_->SetParseErrorCallback(
- base::Bind(&GLInProcessContext::OnContextLost, base::Unretained(this)));
-
- // Create the GLES2 helper, which writes the command buffer protocol.
- gles2_helper_.reset(new GLES2CmdHelper(command_buffer_.get()));
- if (!gles2_helper_->Initialize(kCommandBufferSize)) {
- Destroy();
- return false;
- }
-
- // Create a transfer buffer.
- transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get()));
-
- if (share_resources_) {
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- if (g_all_shared_contexts.Get().empty()) {
- // Create the image factory for the first context.
- image_factory_ = new ImageFactoryInProcess(GetImageManager());
- } else {
- // Share the image factory created by the first context.
- GLInProcessContext* first_context = *g_all_shared_contexts.Get().begin();
- image_factory_ = first_context->GetImageFactory();
- }
- } else {
- // Create the image factory, this object retains its ownership.
- image_factory_ = new ImageFactoryInProcess(GetImageManager());
- }
-
- // Create the object exposing the OpenGL API.
- gles2_implementation_.reset(new GLES2Implementation(
- gles2_helper_.get(),
- context_group ? context_group->GetImplementation()->share_group() : NULL,
- transfer_buffer_.get(),
- true,
- false,
- image_factory_));
-
- if (!gles2_implementation_->Initialize(
- kStartTransferBufferSize,
- kMinTransferBufferSize,
- kMaxTransferBufferSize)) {
- return false;
- }
-
- if (share_resources_) {
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- g_all_shared_contexts.Pointer()->insert(this);
- }
-
- return true;
-}
-
-void GLInProcessContext::Destroy() {
- bool context_lost = IsCommandBufferContextLost();
-
- if (gles2_implementation_) {
- // First flush the context to ensure that any pending frees of resources
- // are completed. Otherwise, if this context is part of a share group,
- // those resources might leak. Also, any remaining side effects of commands
- // issued on this context might not be visible to other contexts in the
- // share group.
- gles2_implementation_->Flush();
-
- gles2_implementation_.reset();
- }
-
- transfer_buffer_.reset();
- gles2_helper_.reset();
- command_buffer_.reset();
-
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- if (decoder_) {
- decoder_->Destroy(!context_lost);
- }
-
- g_all_shared_contexts.Pointer()->erase(this);
-}
-
-void GLInProcessContext::OnContextLost() {
- if (!context_lost_callback_.is_null())
- context_lost_callback_.Run();
-
- context_lost_ = true;
- if (share_resources_) {
- for (std::set<GLInProcessContext*>::iterator it =
- g_all_shared_contexts.Get().begin();
- it != g_all_shared_contexts.Get().end();
- ++it)
- (*it)->context_lost_ = true;
- }
-}
-
-// static
-void
-WebGraphicsContext3DInProcessCommandBufferImpl::EnableVirtualizedContext() {
-#if !defined(NDEBUG)
- {
- AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(),
- g_all_shared_contexts.Get());
- DCHECK(g_all_shared_contexts.Get().empty());
- }
-#endif // !defined(NDEBUG)
- g_use_virtualized_gl_context = true;
-}
-
-// static
-WebGraphicsContext3DInProcessCommandBufferImpl*
-WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
- const WebKit::WebGraphicsContext3D::Attributes& attributes,
- gfx::AcceleratedWidget window) {
- if (!gfx::GLSurface::InitializeOneOff())
- return NULL;
- return new WebGraphicsContext3DInProcessCommandBufferImpl(
- attributes, false, window);
-}
-
-// static
-WebGraphicsContext3DInProcessCommandBufferImpl*
-WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- const WebKit::WebGraphicsContext3D::Attributes& attributes) {
- return new WebGraphicsContext3DInProcessCommandBufferImpl(
- attributes, true, gfx::kNullAcceleratedWidget);
-}
-
-WebGraphicsContext3DInProcessCommandBufferImpl::
- WebGraphicsContext3DInProcessCommandBufferImpl(
- const WebKit::WebGraphicsContext3D::Attributes& attributes,
- bool is_offscreen,
- gfx::AcceleratedWidget window)
- : is_offscreen_(is_offscreen),
- window_(window),
- initialized_(false),
- initialize_failed_(false),
- context_(NULL),
- gl_(NULL),
- context_lost_callback_(NULL),
- context_lost_reason_(GL_NO_ERROR),
- attributes_(attributes),
- cached_width_(0),
- cached_height_(0),
- bound_fbo_(0) {
-}
-
-WebGraphicsContext3DInProcessCommandBufferImpl::
- ~WebGraphicsContext3DInProcessCommandBufferImpl() {
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
- if (initialized_)
- return true;
-
- if (initialize_failed_)
- return false;
-
- // Convert WebGL context creation attributes into GLInProcessContext / EGL
- // size requests.
- const int alpha_size = attributes_.alpha ? 8 : 0;
- const int depth_size = attributes_.depth ? 24 : 0;
- const int stencil_size = attributes_.stencil ? 8 : 0;
- const int samples = attributes_.antialias ? 4 : 0;
- const int sample_buffers = attributes_.antialias ? 1 : 0;
- const int32 attribs[] = {
- GLInProcessContext::ALPHA_SIZE, alpha_size,
- GLInProcessContext::DEPTH_SIZE, depth_size,
- GLInProcessContext::STENCIL_SIZE, stencil_size,
- GLInProcessContext::SAMPLES, samples,
- GLInProcessContext::SAMPLE_BUFFERS, sample_buffers,
- GLInProcessContext::NONE,
- };
-
- const char* preferred_extensions = "*";
-
- // TODO(kbr): More work will be needed in this implementation to
- // properly support GPU switching. Like in the out-of-process
- // command buffer implementation, all previously created contexts
- // will need to be lost either when the first context requesting the
- // discrete GPU is created, or the last one is destroyed.
- gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
-
- context_ = GLInProcessContext::CreateContext(
- is_offscreen_,
- window_,
- gfx::Size(1, 1),
- attributes_.shareResources,
- preferred_extensions,
- attribs,
- gpu_preference);
-
- if (!context_) {
- initialize_failed_ = true;
- return false;
- }
-
- gl_ = context_->GetImplementation();
-
- if (gl_ && attributes_.noExtensions)
- gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation");
-
- context_->SetContextLostCallback(
- base::Bind(
- &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost,
- base::Unretained(this)));
-
- // Set attributes_ from created offscreen context.
- {
- GLint alpha_bits = 0;
- getIntegerv(GL_ALPHA_BITS, &alpha_bits);
- attributes_.alpha = alpha_bits > 0;
- GLint depth_bits = 0;
- getIntegerv(GL_DEPTH_BITS, &depth_bits);
- attributes_.depth = depth_bits > 0;
- GLint stencil_bits = 0;
- getIntegerv(GL_STENCIL_BITS, &stencil_bits);
- attributes_.stencil = stencil_bits > 0;
- GLint sample_buffers = 0;
- getIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers);
- attributes_.antialias = sample_buffers > 0;
- }
-
- initialized_ = true;
- return true;
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() {
- if (!MaybeInitializeGL())
- return false;
-
- return GLInProcessContext::MakeCurrent(context_);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() {
- // NOTE: Comment in the line below to check for code that is not calling
- // eglMakeCurrent where appropriate. The issue is code using
- // WebGraphicsContext3D does not need to call makeContextCurrent. Code using
- // direct OpenGL bindings needs to call the appropriate form of
- // eglMakeCurrent. If it doesn't it will be issuing commands on the wrong
- // context. Uncommenting the line below clears the current context so that
- // any code not calling eglMakeCurrent in the appropriate place should crash.
- // This is not a perfect test but generally code that used the direct OpenGL
- // bindings should not be mixed with code that uses WebGraphicsContext3D.
- //
- // GLInProcessContext::MakeCurrent(NULL);
-}
-
-int WebGraphicsContext3DInProcessCommandBufferImpl::width() {
- return cached_width_;
-}
-
-int WebGraphicsContext3DInProcessCommandBufferImpl::height() {
- return cached_height_;
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::isGLES2Compliant() {
- return true;
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::setParentContext(
- WebGraphicsContext3D* parent_context) {
- return false;
-}
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::getPlatformTextureId() {
- DCHECK(context_);
- return context_->GetParentTextureId();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::prepareTexture() {
- // Copies the contents of the off-screen render target into the texture
- // used by the compositor.
- context_->SwapBuffers();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::postSubBufferCHROMIUM(
- int x, int y, int width, int height) {
- gl_->PostSubBufferCHROMIUM(x, y, width, height);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::reshape(
- int width, int height) {
- reshapeWithScaleFactor(width, height, 1.0f);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::reshapeWithScaleFactor(
- int width, int height, float scale_factor) {
- cached_width_ = width;
- cached_height_ = height;
-
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
-
- gl_->ResizeCHROMIUM(width, height, scale_factor);
-}
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createCompositorTexture(
- WGC3Dsizei width, WGC3Dsizei height) {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- return context_->CreateParentTexture(gfx::Size(width, height));
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteCompositorTexture(
- WebGLId parent_texture) {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- context_->DeleteParentTexture(parent_texture);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::FlipVertically(
- uint8* framebuffer,
- unsigned int width,
- unsigned int height) {
- if (width == 0)
- return;
- scanline_.resize(width * 4);
- uint8* scanline = &scanline_[0];
- unsigned int row_bytes = width * 4;
- unsigned int count = height / 2;
- for (unsigned int i = 0; i < count; i++) {
- uint8* row_a = framebuffer + i * row_bytes;
- uint8* row_b = framebuffer + (height - i - 1) * row_bytes;
- // TODO(kbr): this is where the multiplication of the alpha
- // channel into the color buffer will need to occur if the
- // user specifies the "premultiplyAlpha" flag in the context
- // creation attributes.
- memcpy(scanline, row_b, row_bytes);
- memcpy(row_b, row_a, row_bytes);
- memcpy(row_a, scanline, row_bytes);
- }
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::readBackFramebuffer(
- unsigned char* pixels,
- size_t buffer_size,
- WebGLId framebuffer,
- int width,
- int height) {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- if (buffer_size != static_cast<size_t>(4 * width * height)) {
- return false;
- }
-
- // Earlier versions of this code used the GPU to flip the
- // framebuffer vertically before reading it back for compositing
- // via software. This code was quite complicated, used a lot of
- // GPU memory, and didn't provide an obvious speedup. Since this
- // vertical flip is only a temporary solution anyway until Chrome
- // is fully GPU composited, it wasn't worth the complexity.
-
- bool mustRestoreFBO = (bound_fbo_ != framebuffer);
- if (mustRestoreFBO) {
- gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer);
- }
- gl_->ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
- // Swizzle red and blue channels
- // TODO(kbr): expose GL_BGRA as extension
- for (size_t i = 0; i < buffer_size; i += 4) {
- std::swap(pixels[i], pixels[i + 2]);
- }
-
- if (mustRestoreFBO) {
- gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_);
- }
-
- if (pixels) {
- FlipVertically(pixels, width, height);
- }
-
- return true;
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::readBackFramebuffer(
- unsigned char* pixels,
- size_t buffer_size) {
- return readBackFramebuffer(pixels, buffer_size, 0, width(), height());
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::synthesizeGLError(
- WGC3Denum error) {
- if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) ==
- synthetic_errors_.end()) {
- synthetic_errors_.push_back(error);
- }
-}
-
-void* WebGraphicsContext3DInProcessCommandBufferImpl::mapBufferSubDataCHROMIUM(
- WGC3Denum target,
- WGC3Dintptr offset,
- WGC3Dsizeiptr size,
- WGC3Denum access) {
- ClearContext();
- return gl_->MapBufferSubDataCHROMIUM(target, offset, size, access);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::unmapBufferSubDataCHROMIUM(
- const void* mem) {
- ClearContext();
- return gl_->UnmapBufferSubDataCHROMIUM(mem);
-}
-
-void* WebGraphicsContext3DInProcessCommandBufferImpl::mapTexSubImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- WGC3Denum access) {
- ClearContext();
- return gl_->MapTexSubImage2DCHROMIUM(
- target, level, xoffset, yoffset, width, height, format, type, access);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::unmapTexSubImage2DCHROMIUM(
- const void* mem) {
- ClearContext();
- gl_->UnmapTexSubImage2DCHROMIUM(mem);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::setVisibilityCHROMIUM(
- bool visible) {
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- setMemoryAllocationChangedCallbackCHROMIUM(
- WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) {
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::discardFramebufferEXT(
- WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) {
- gl_->DiscardFramebufferEXT(target, numAttachments, attachments);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- discardBackbufferCHROMIUM() {
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- ensureBackbufferCHROMIUM() {
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- copyTextureToParentTextureCHROMIUM(WebGLId texture, WebGLId parentTexture) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- rateLimitOffscreenContextCHROMIUM() {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- gl_->RateLimitOffscreenContextCHROMIUM();
-}
-
-WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getRequestableExtensionsCHROMIUM() {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- return WebKit::WebString::fromUTF8(
- gl_->GetRequestableExtensionsCHROMIUM());
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::requestExtensionCHROMIUM(
- const char* extension) {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- gl_->RequestExtensionCHROMIUM(extension);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::blitFramebufferCHROMIUM(
- WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
- WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
- WGC3Dbitfield mask, WGC3Denum filter) {
- ClearContext();
- gl_->BlitFramebufferEXT(
- srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1,
- mask, filter);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- renderbufferStorageMultisampleCHROMIUM(
- WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
- WGC3Dsizei width, WGC3Dsizei height) {
- ClearContext();
- gl_->RenderbufferStorageMultisampleEXT(
- target, samples, internalformat, width, height);
-}
-
-// Helper macros to reduce the amount of code.
-
-#define DELEGATE_TO_GL(name, glname) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name() { \
- ClearContext(); \
- gl_->glname(); \
-}
-
-#define DELEGATE_TO_GL_1(name, glname, t1) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \
- ClearContext(); \
- gl_->glname(a1); \
-}
-
-#define DELEGATE_TO_GL_1R(name, glname, t1, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \
- ClearContext(); \
- return gl_->glname(a1); \
-}
-
-#define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \
- ClearContext(); \
- return gl_->glname(a1) ? true : false; \
-}
-
-#define DELEGATE_TO_GL_2(name, glname, t1, t2) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2) { \
- ClearContext(); \
- gl_->glname(a1, a2); \
-}
-
-#define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1, t2 a2) { \
- ClearContext(); \
- return gl_->glname(a1, a2); \
-}
-
-#define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3); \
-}
-
-#define DELEGATE_TO_GL_3R(name, glname, t1, t2, t3, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3) { \
- ClearContext(); \
- return gl_->glname(a1, a2, a3); \
-}
-
-#define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4); \
-}
-
-#define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5); \
-}
-
-#define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5, a6); \
-}
-
-#define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5, a6, a7); \
-}
-
-#define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \
-}
-
-#define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
-}
-
-DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum)
-
-DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId)
-
-DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId,
- WGC3Duint, const WGC3Dchar*)
-
-DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::bindFramebuffer(
- WGC3Denum target,
- WebGLId framebuffer) {
- ClearContext();
- gl_->BindFramebuffer(target, framebuffer);
- bound_fbo_ = framebuffer;
-}
-
-DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId)
-
-DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId)
-
-DELEGATE_TO_GL_4(blendColor, BlendColor,
- WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
-
-DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum)
-
-DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate,
- WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate,
- WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(bufferData, BufferData,
- WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum)
-
-DELEGATE_TO_GL_4(bufferSubData, BufferSubData,
- WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*)
-
-DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatus,
- WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield)
-
-DELEGATE_TO_GL_4(clearColor, ClearColor,
- WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
-
-DELEGATE_TO_GL_1(clearDepth, ClearDepthf, WGC3Dclampf)
-
-DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint)
-
-DELEGATE_TO_GL_4(colorMask, ColorMask,
- WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean)
-
-DELEGATE_TO_GL_1(compileShader, CompileShader, WebGLId)
-
-DELEGATE_TO_GL_8(compressedTexImage2D, CompressedTexImage2D,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
- WGC3Dsizei, WGC3Dsizei, const void*)
-
-DELEGATE_TO_GL_9(compressedTexSubImage2D, CompressedTexSubImage2D,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
- WGC3Denum, WGC3Dsizei, const void*)
-
-DELEGATE_TO_GL_8(copyTexImage2D, CopyTexImage2D,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
- WGC3Dsizei, WGC3Dsizei, WGC3Dint)
-
-DELEGATE_TO_GL_8(copyTexSubImage2D, CopyTexSubImage2D,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
- WGC3Dsizei, WGC3Dsizei)
-
-DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum)
-
-DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum)
-
-DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean)
-
-DELEGATE_TO_GL_2(depthRange, DepthRangef, WGC3Dclampf, WGC3Dclampf)
-
-DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId)
-
-DELEGATE_TO_GL_1(disable, Disable, WGC3Denum)
-
-DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray,
- WGC3Duint)
-
-DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::drawElements(
- WGC3Denum mode,
- WGC3Dsizei count,
- WGC3Denum type,
- WGC3Dintptr offset) {
- ClearContext();
- gl_->DrawElements(
- mode, count, type,
- reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
-}
-
-DELEGATE_TO_GL_1(enable, Enable, WGC3Denum)
-
-DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray,
- WGC3Duint)
-
-DELEGATE_TO_GL(finish, Finish)
-
-DELEGATE_TO_GL(flush, Flush)
-
-DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer,
- WGC3Denum, WGC3Denum, WGC3Denum, WebGLId)
-
-DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D,
- WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint)
-
-DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum)
-
-DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum)
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::getActiveAttrib(
- WebGLId program, WGC3Duint index, ActiveInfo& info) {
- ClearContext();
- if (!program) {
- synthesizeGLError(GL_INVALID_VALUE);
- return false;
- }
- GLint max_name_length = -1;
- gl_->GetProgramiv(
- program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
- if (max_name_length < 0)
- return false;
- scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
- if (!name) {
- synthesizeGLError(GL_OUT_OF_MEMORY);
- return false;
- }
- GLsizei length = 0;
- GLint size = -1;
- GLenum type = 0;
- gl_->GetActiveAttrib(
- program, index, max_name_length, &length, &size, &type, name.get());
- if (size < 0) {
- return false;
- }
- info.name = WebKit::WebString::fromUTF8(name.get(), length);
- info.type = type;
- info.size = size;
- return true;
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::getActiveUniform(
- WebGLId program, WGC3Duint index, ActiveInfo& info) {
- ClearContext();
- GLint max_name_length = -1;
- gl_->GetProgramiv(
- program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
- if (max_name_length < 0)
- return false;
- scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
- if (!name) {
- synthesizeGLError(GL_OUT_OF_MEMORY);
- return false;
- }
- GLsizei length = 0;
- GLint size = -1;
- GLenum type = 0;
- gl_->GetActiveUniform(
- program, index, max_name_length, &length, &size, &type, name.get());
- if (size < 0) {
- return false;
- }
- info.name = WebKit::WebString::fromUTF8(name.get(), length);
- info.type = type;
- info.size = size;
- return true;
-}
-
-DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders,
- WebGLId, WGC3Dsizei, WGC3Dsizei*, WebGLId*)
-
-DELEGATE_TO_GL_2R(getAttribLocation, GetAttribLocation,
- WebGLId, const WGC3Dchar*, WGC3Dint)
-
-DELEGATE_TO_GL_2(getBooleanv, GetBooleanv, WGC3Denum, WGC3Dboolean*)
-
-DELEGATE_TO_GL_3(getBufferParameteriv, GetBufferParameteriv,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-WebKit::WebGraphicsContext3D::Attributes
-WebGraphicsContext3DInProcessCommandBufferImpl::getContextAttributes() {
- return attributes_;
-}
-
-WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl::getError() {
- ClearContext();
- if (!synthetic_errors_.empty()) {
- std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin();
- WGC3Denum err = *iter;
- synthetic_errors_.erase(iter);
- return err;
- }
-
- return gl_->GetError();
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() {
- return context_->IsCommandBufferContextLost();
-}
-
-DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv,
- GetFramebufferAttachmentParameteriv,
- WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*)
-
-WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getProgramInfoLog(WebGLId program) {
- ClearContext();
- GLint logLength = 0;
- gl_->GetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
- if (!logLength)
- return WebKit::WebString();
- scoped_ptr<GLchar[]> log(new GLchar[logLength]);
- if (!log)
- return WebKit::WebString();
- GLsizei returnedLogLength = 0;
- gl_->GetProgramInfoLog(
- program, logLength, &returnedLogLength, log.get());
- DCHECK_EQ(logLength, returnedLogLength + 1);
- WebKit::WebString res =
- WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
- return res;
-}
-
-DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*)
-
-WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getShaderInfoLog(WebGLId shader) {
- ClearContext();
- GLint logLength = 0;
- gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
- if (!logLength)
- return WebKit::WebString();
- scoped_ptr<GLchar[]> log(new GLchar[logLength]);
- if (!log)
- return WebKit::WebString();
- GLsizei returnedLogLength = 0;
- gl_->GetShaderInfoLog(
- shader, logLength, &returnedLogLength, log.get());
- DCHECK_EQ(logLength, returnedLogLength + 1);
- WebKit::WebString res =
- WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
- return res;
-}
-
-DELEGATE_TO_GL_4(getShaderPrecisionFormat, GetShaderPrecisionFormat,
- WGC3Denum, WGC3Denum, WGC3Dint*, WGC3Dint*)
-
-WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getShaderSource(WebGLId shader) {
- ClearContext();
- GLint logLength = 0;
- gl_->GetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength);
- if (!logLength)
- return WebKit::WebString();
- scoped_ptr<GLchar[]> log(new GLchar[logLength]);
- if (!log)
- return WebKit::WebString();
- GLsizei returnedLogLength = 0;
- gl_->GetShaderSource(
- shader, logLength, &returnedLogLength, log.get());
- if (!returnedLogLength)
- return WebKit::WebString();
- DCHECK_EQ(logLength, returnedLogLength + 1);
- WebKit::WebString res =
- WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
- return res;
-}
-
-WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getTranslatedShaderSourceANGLE(WebGLId shader) {
- ClearContext();
- GLint logLength = 0;
- gl_->GetShaderiv(
- shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &logLength);
- if (!logLength)
- return WebKit::WebString();
- scoped_ptr<GLchar[]> log(new GLchar[logLength]);
- if (!log)
- return WebKit::WebString();
- GLsizei returnedLogLength = 0;
- gl_->GetTranslatedShaderSourceANGLE(
- shader, logLength, &returnedLogLength, log.get());
- if (!returnedLogLength)
- return WebKit::WebString();
- DCHECK_EQ(logLength, returnedLogLength + 1);
- WebKit::WebString res =
- WebKit::WebString::fromUTF8(log.get(), returnedLogLength);
- return res;
-}
-
-WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl::getString(
- WGC3Denum name) {
- ClearContext();
- return WebKit::WebString::fromUTF8(
- reinterpret_cast<const char*>(gl_->GetString(name)));
-}
-
-DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv,
- WGC3Denum, WGC3Denum, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*)
-
-DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation,
- WebGLId, const WGC3Dchar*, WGC3Dint)
-
-DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv,
- WGC3Duint, WGC3Denum, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv,
- WGC3Duint, WGC3Denum, WGC3Dint*)
-
-WGC3Dsizeiptr WebGraphicsContext3DInProcessCommandBufferImpl::
- getVertexAttribOffset(WGC3Duint index, WGC3Denum pname) {
- ClearContext();
- GLvoid* value = NULL;
- // NOTE: If pname is ever a value that returns more then 1 element
- // this will corrupt memory.
- gl_->GetVertexAttribPointerv(index, pname, &value);
- return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value));
-}
-
-DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isProgram, IsProgram, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isRenderbuffer, IsRenderbuffer, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isShader, IsShader, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isTexture, IsTexture, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1(lineWidth, LineWidth, WGC3Dfloat)
-
-DELEGATE_TO_GL_1(linkProgram, LinkProgram, WebGLId)
-
-DELEGATE_TO_GL_2(pixelStorei, PixelStorei, WGC3Denum, WGC3Dint)
-
-DELEGATE_TO_GL_2(polygonOffset, PolygonOffset, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_7(readPixels, ReadPixels,
- WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, WGC3Denum,
- WGC3Denum, void*)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::releaseShaderCompiler() {
- ClearContext();
-}
-
-DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage,
- WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei)
-
-DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean)
-
-DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::shaderSource(
- WebGLId shader, const WGC3Dchar* string) {
- ClearContext();
- GLint length = strlen(string);
- gl_->ShaderSource(shader, 1, &string, &length);
-}
-
-DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint)
-
-DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate,
- WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint)
-
-DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint)
-
-DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate,
- WGC3Denum, WGC3Duint)
-
-DELEGATE_TO_GL_3(stencilOp, StencilOp,
- WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate,
- WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_9(texImage2D, TexImage2D,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei,
- WGC3Dint, WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_3(texParameterf, TexParameterf,
- WGC3Denum, WGC3Denum, WGC3Dfloat);
-
-static const unsigned int kTextureWrapR = 0x8072;
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::texParameteri(
- WGC3Denum target, WGC3Denum pname, WGC3Dint param) {
- ClearContext();
- // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in
- // GraphicsContext3D.cpp is strictly necessary to avoid seams at the
- // edge of cube maps, and, if it is, push it into the GLES2 service
- // side code.
- if (pname == kTextureWrapR) {
- return;
- }
- gl_->TexParameteri(target, pname, param);
-}
-
-DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
- WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_2(uniform1i, Uniform1i, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform1iv, Uniform1iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_3(uniform2f, Uniform2f, WGC3Dint, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform2fv, Uniform2fv, WGC3Dint, WGC3Dsizei,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(uniform2i, Uniform2i, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform2iv, Uniform2iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_4(uniform3f, Uniform3f, WGC3Dint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform3fv, Uniform3fv, WGC3Dint, WGC3Dsizei,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniform3i, Uniform3i, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform3iv, Uniform3iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_5(uniform4f, Uniform4f, WGC3Dint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform4fv, Uniform4fv, WGC3Dint, WGC3Dsizei,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_5(uniform4i, Uniform4i, WGC3Dint,
- WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform4iv, Uniform4iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_4(uniformMatrix2fv, UniformMatrix2fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniformMatrix3fv, UniformMatrix3fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniformMatrix4fv, UniformMatrix4fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_1(useProgram, UseProgram, WebGLId)
-
-DELEGATE_TO_GL_1(validateProgram, ValidateProgram, WebGLId)
-
-DELEGATE_TO_GL_2(vertexAttrib1f, VertexAttrib1f, WGC3Duint, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib1fv, VertexAttrib1fv, WGC3Duint,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(vertexAttrib2f, VertexAttrib2f, WGC3Duint,
- WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib2fv, VertexAttrib2fv, WGC3Duint,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(vertexAttrib3f, VertexAttrib3f, WGC3Duint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib3fv, VertexAttrib3fv, WGC3Duint,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint,
- const WGC3Dfloat*)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::vertexAttribPointer(
- WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized,
- WGC3Dsizei stride, WGC3Dintptr offset) {
- ClearContext();
- gl_->VertexAttribPointer(
- index, size, type, normalized, stride,
- reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
-}
-
-DELEGATE_TO_GL_4(viewport, Viewport,
- WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createBuffer() {
- ClearContext();
- GLuint o;
- gl_->GenBuffers(1, &o);
- return o;
-}
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createFramebuffer() {
- ClearContext();
- GLuint o = 0;
- gl_->GenFramebuffers(1, &o);
- return o;
-}
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createProgram() {
- ClearContext();
- return gl_->CreateProgram();
-}
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createRenderbuffer() {
- ClearContext();
- GLuint o;
- gl_->GenRenderbuffers(1, &o);
- return o;
-}
-
-DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId);
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createTexture() {
- ClearContext();
- GLuint o;
- gl_->GenTextures(1, &o);
- return o;
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteBuffer(
- WebGLId buffer) {
- ClearContext();
- gl_->DeleteBuffers(1, &buffer);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteFramebuffer(
- WebGLId framebuffer) {
- ClearContext();
- gl_->DeleteFramebuffers(1, &framebuffer);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteProgram(
- WebGLId program) {
- ClearContext();
- gl_->DeleteProgram(program);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteRenderbuffer(
- WebGLId renderbuffer) {
- ClearContext();
- gl_->DeleteRenderbuffers(1, &renderbuffer);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteShader(
- WebGLId shader) {
- ClearContext();
- gl_->DeleteShader(shader);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteTexture(
- WebGLId texture) {
- ClearContext();
- gl_->DeleteTextures(1, &texture);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::copyTextureToCompositor(
- WebGLId texture, WebGLId parentTexture) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::OnSwapBuffersComplete() {
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::setContextLostCallback(
- WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) {
- context_lost_callback_ = cb;
-}
-
-WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl::
- getGraphicsResetStatusARB() {
- return context_lost_reason_;
-}
-
-DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint)
-
-DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT,
- WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint)
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createQueryEXT() {
- GLuint o;
- gl_->GenQueriesEXT(1, &o);
- return o;
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- deleteQueryEXT(WebGLId query) {
- gl_->DeleteQueriesEXT(1, &query);
-}
-
-DELEGATE_TO_GL_1R(isQueryEXT, IsQueryEXT, WebGLId, WGC3Dboolean)
-DELEGATE_TO_GL_2(beginQueryEXT, BeginQueryEXT, WGC3Denum, WebGLId)
-DELEGATE_TO_GL_1(endQueryEXT, EndQueryEXT, WGC3Denum)
-DELEGATE_TO_GL_3(getQueryivEXT, GetQueryivEXT, WGC3Denum, WGC3Denum, WGC3Dint*)
-DELEGATE_TO_GL_3(getQueryObjectuivEXT, GetQueryObjectuivEXT,
- WebGLId, WGC3Denum, WGC3Duint*)
-
-DELEGATE_TO_GL_6(copyTextureCHROMIUM, CopyTextureCHROMIUM, WGC3Denum, WGC3Duint,
- WGC3Duint, WGC3Dint, WGC3Denum, WGC3Denum)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::insertEventMarkerEXT(
- const WGC3Dchar* marker) {
- gl_->InsertEventMarkerEXT(0, marker);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::pushGroupMarkerEXT(
- const WGC3Dchar* marker) {
- gl_->PushGroupMarkerEXT(0, marker);
-}
-
-DELEGATE_TO_GL(popGroupMarkerEXT, PopGroupMarkerEXT);
-
-DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM, BindTexImage2DCHROMIUM,
- WGC3Denum, WGC3Dint)
-DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM, ReleaseTexImage2DCHROMIUM,
- WGC3Denum, WGC3Dint)
-
-void* WebGraphicsContext3DInProcessCommandBufferImpl::mapBufferCHROMIUM(
- WGC3Denum target, WGC3Denum access) {
- ClearContext();
- return gl_->MapBufferCHROMIUM(target, access);
-}
-
-WGC3Dboolean WebGraphicsContext3DInProcessCommandBufferImpl::
- unmapBufferCHROMIUM(WGC3Denum target) {
- ClearContext();
- return gl_->UnmapBufferCHROMIUM(target);
-}
-
-GrGLInterface* WebGraphicsContext3DInProcessCommandBufferImpl::
- onCreateGrGLInterface() {
- return CreateCommandBufferSkiaGLBinding();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
- // TODO(kbr): improve the precision here.
- context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB;
- if (context_lost_callback_) {
- context_lost_callback_->onContextLost();
- }
-}
-
-DELEGATE_TO_GL_3R(createImageCHROMIUM, CreateImageCHROMIUM,
- WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Duint);
-
-DELEGATE_TO_GL_1(destroyImageCHROMIUM, DestroyImageCHROMIUM, WGC3Duint);
-
-DELEGATE_TO_GL_3(getImageParameterivCHROMIUM, GetImageParameterivCHROMIUM,
- WGC3Duint, WGC3Denum, GLint*);
-
-DELEGATE_TO_GL_2R(mapImageCHROMIUM, MapImageCHROMIUM,
- WGC3Duint, WGC3Denum, void*);
-
-DELEGATE_TO_GL_1(unmapImageCHROMIUM, UnmapImageCHROMIUM, WGC3Duint);
-
-DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM,
- WebGLId, WGC3Dint, const WGC3Dchar*)
-
-DELEGATE_TO_GL(shallowFlushCHROMIUM, ShallowFlushCHROMIUM)
-
-DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*)
-DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM,
- WGC3Denum, const WGC3Dbyte*)
-DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM,
- WGC3Denum, const WGC3Dbyte*)
-
-DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT,
- WGC3Dsizei, const WGC3Denum*)
-
-unsigned WebGraphicsContext3DInProcessCommandBufferImpl::insertSyncPoint() {
- shallowFlushCHROMIUM();
- return 0;
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::signalSyncPoint(
- unsigned sync_point,
- WebGraphicsSyncPointCallback* callback) {
- // Take ownership of the callback.
- context_->SetSignalSyncPointCallback(make_scoped_ptr(callback));
- // Stick something in the command buffer.
- shallowFlushCHROMIUM();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::loseContextCHROMIUM(
- WGC3Denum current, WGC3Denum other) {
- context_->LoseContext(current, other);
-}
-
-DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM, AsyncTexImage2DCHROMIUM,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dint,
- WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei,
- WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM,
- WGC3Denum)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::SetGpuMemoryBufferCreator(
- GpuMemoryBufferCreator* creator) {
- g_gpu_memory_buffer_creator = creator;
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
deleted file mode 100644
index cf06e8e..0000000
--- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
+++ /dev/null
@@ -1,610 +0,0 @@
-// Copyright (c) 2012 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_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_
-#define WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_
-
-#if defined(ENABLE_GPU)
-
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "gpu/command_buffer/client/gpu_memory_buffer.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
-#include "ui/gfx/native_widget_types.h"
-#include "webkit/gpu/webkit_gpu_export.h"
-
-namespace gpu {
-namespace gles2 {
-class GLES2Implementation;
-}
-}
-
-using WebKit::WebGLId;
-
-using WebKit::WGC3Dbyte;
-using WebKit::WGC3Dchar;
-using WebKit::WGC3Denum;
-using WebKit::WGC3Dboolean;
-using WebKit::WGC3Dbitfield;
-using WebKit::WGC3Dint;
-using WebKit::WGC3Dsizei;
-using WebKit::WGC3Duint;
-using WebKit::WGC3Dfloat;
-using WebKit::WGC3Dclampf;
-using WebKit::WGC3Dintptr;
-using WebKit::WGC3Dsizeiptr;
-
-namespace webkit {
-namespace gpu {
-
-class GLInProcessContext;
-
-class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
- : public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) {
- public:
- typedef scoped_ptr< ::gpu::GpuMemoryBuffer> GpuMemoryBufferCreator(
- int width, int height);
-
- // Must be called before any WebGraphicsContext3DInProcessCommandBufferImpl
- // instances are created. Default value is false.
- static void EnableVirtualizedContext();
-
- static WebGraphicsContext3DInProcessCommandBufferImpl*
- CreateViewContext(
- const WebKit::WebGraphicsContext3D::Attributes& attributes,
- gfx::AcceleratedWidget window);
-
- static WebGraphicsContext3DInProcessCommandBufferImpl*
- CreateOffscreenContext(
- const WebKit::WebGraphicsContext3D::Attributes& attributes);
-
- static void SetGpuMemoryBufferCreator(GpuMemoryBufferCreator* creator);
-
- virtual ~WebGraphicsContext3DInProcessCommandBufferImpl();
-
- //----------------------------------------------------------------------
- // WebGraphicsContext3D methods
- virtual bool makeContextCurrent();
-
- virtual int width();
- virtual int height();
-
- virtual bool isGLES2Compliant();
-
- virtual bool setParentContext(WebGraphicsContext3D* parent_context);
-
- virtual void reshape(int width, int height);
- virtual void reshapeWithScaleFactor(int width, int height, float scaleFactor);
-
- virtual bool readBackFramebuffer(unsigned char* pixels, size_t buffer_size);
- virtual bool readBackFramebuffer(unsigned char* pixels, size_t buffer_size,
- WebGLId framebuffer, int width, int height);
-
- virtual WebGLId getPlatformTextureId();
- virtual void prepareTexture();
- virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
-
- virtual void activeTexture(WGC3Denum texture);
- virtual void attachShader(WebGLId program, WebGLId shader);
- virtual void bindAttribLocation(WebGLId program, WGC3Duint index,
- const WGC3Dchar* name);
- virtual void bindBuffer(WGC3Denum target, WebGLId buffer);
- virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer);
- virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer);
- virtual void bindTexture(WGC3Denum target, WebGLId texture);
- virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green,
- WGC3Dclampf blue, WGC3Dclampf alpha);
- virtual void blendEquation(WGC3Denum mode);
- virtual void blendEquationSeparate(WGC3Denum modeRGB,
- WGC3Denum modeAlpha);
- virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor);
- virtual void blendFuncSeparate(WGC3Denum srcRGB,
- WGC3Denum dstRGB,
- WGC3Denum srcAlpha,
- WGC3Denum dstAlpha);
-
- virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size,
- const void* data, WGC3Denum usage);
- virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset,
- WGC3Dsizeiptr size, const void* data);
-
- virtual WGC3Denum checkFramebufferStatus(WGC3Denum target);
- virtual void clear(WGC3Dbitfield mask);
- virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green,
- WGC3Dclampf blue, WGC3Dclampf alpha);
- virtual void clearDepth(WGC3Dclampf depth);
- virtual void clearStencil(WGC3Dint s);
- virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green,
- WGC3Dboolean blue, WGC3Dboolean alpha);
- virtual void compileShader(WebGLId shader);
-
- virtual void compressedTexImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border,
- WGC3Dsizei imageSize,
- const void* data);
- virtual void compressedTexSubImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Dsizei imageSize,
- const void* data);
- virtual void copyTexImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dint x,
- WGC3Dint y,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border);
- virtual void copyTexSubImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dint x,
- WGC3Dint y,
- WGC3Dsizei width,
- WGC3Dsizei height);
- virtual void cullFace(WGC3Denum mode);
- virtual void depthFunc(WGC3Denum func);
- virtual void depthMask(WGC3Dboolean flag);
- virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar);
- virtual void detachShader(WebGLId program, WebGLId shader);
- virtual void disable(WGC3Denum cap);
- virtual void disableVertexAttribArray(WGC3Duint index);
- virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count);
- virtual void drawElements(WGC3Denum mode,
- WGC3Dsizei count,
- WGC3Denum type,
- WGC3Dintptr offset);
-
- virtual void enable(WGC3Denum cap);
- virtual void enableVertexAttribArray(WGC3Duint index);
- virtual void finish();
- virtual void flush();
- virtual void framebufferRenderbuffer(WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum renderbuffertarget,
- WebGLId renderbuffer);
- virtual void framebufferTexture2D(WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum textarget,
- WebGLId texture,
- WGC3Dint level);
- virtual void frontFace(WGC3Denum mode);
- virtual void generateMipmap(WGC3Denum target);
-
- virtual bool getActiveAttrib(WebGLId program,
- WGC3Duint index,
- ActiveInfo&);
- virtual bool getActiveUniform(WebGLId program,
- WGC3Duint index,
- ActiveInfo&);
-
- virtual void getAttachedShaders(WebGLId program,
- WGC3Dsizei maxCount,
- WGC3Dsizei* count,
- WebGLId* shaders);
-
- virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name);
-
- virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value);
-
- virtual void getBufferParameteriv(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual Attributes getContextAttributes();
-
- virtual WGC3Denum getError();
-
- virtual bool isContextLost();
-
- virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value);
-
- virtual void getFramebufferAttachmentParameteriv(WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value);
-
- virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value);
-
- virtual WebKit::WebString getProgramInfoLog(WebGLId program);
-
- virtual void getRenderbufferParameteriv(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value);
-
- virtual WebKit::WebString getShaderInfoLog(WebGLId shader);
-
- virtual void getShaderPrecisionFormat(WGC3Denum shadertype,
- WGC3Denum precisiontype,
- WGC3Dint* range,
- WGC3Dint* precision);
-
- virtual WebKit::WebString getShaderSource(WebGLId shader);
- virtual WebKit::WebString getString(WGC3Denum name);
-
- virtual void getTexParameterfv(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dfloat* value);
- virtual void getTexParameteriv(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual void getUniformfv(WebGLId program,
- WGC3Dint location,
- WGC3Dfloat* value);
- virtual void getUniformiv(WebGLId program,
- WGC3Dint location,
- WGC3Dint* value);
-
- virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name);
-
- virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname,
- WGC3Dfloat* value);
- virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname,
- WGC3Dint* value);
-
- virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname);
-
- virtual void hint(WGC3Denum target, WGC3Denum mode);
- virtual WGC3Dboolean isBuffer(WebGLId buffer);
- virtual WGC3Dboolean isEnabled(WGC3Denum cap);
- virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer);
- virtual WGC3Dboolean isProgram(WebGLId program);
- virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer);
- virtual WGC3Dboolean isShader(WebGLId shader);
- virtual WGC3Dboolean isTexture(WebGLId texture);
- virtual void lineWidth(WGC3Dfloat);
- virtual void linkProgram(WebGLId program);
- virtual void pixelStorei(WGC3Denum pname, WGC3Dint param);
- virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units);
-
- virtual void readPixels(WGC3Dint x,
- WGC3Dint y,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- void* pixels);
-
- virtual void releaseShaderCompiler();
- virtual void renderbufferStorage(WGC3Denum target,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height);
- virtual void sampleCoverage(WGC3Dfloat value, WGC3Dboolean invert);
- virtual void scissor(WGC3Dint x, WGC3Dint y,
- WGC3Dsizei width, WGC3Dsizei height);
- virtual void shaderSource(WebGLId shader, const WGC3Dchar* string);
- virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask);
- virtual void stencilFuncSeparate(WGC3Denum face,
- WGC3Denum func,
- WGC3Dint ref,
- WGC3Duint mask);
- virtual void stencilMask(WGC3Duint mask);
- virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask);
- virtual void stencilOp(WGC3Denum fail,
- WGC3Denum zfail,
- WGC3Denum zpass);
- virtual void stencilOpSeparate(WGC3Denum face,
- WGC3Denum fail,
- WGC3Denum zfail,
- WGC3Denum zpass);
-
- virtual void texImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
-
- virtual void texParameterf(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dfloat param);
- virtual void texParameteri(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dint param);
-
- virtual void texSubImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
-
- virtual void uniform1f(WGC3Dint location, WGC3Dfloat x);
- virtual void uniform1fv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dfloat* v);
- virtual void uniform1i(WGC3Dint location, WGC3Dint x);
- virtual void uniform1iv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dint* v);
- virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y);
- virtual void uniform2fv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dfloat* v);
- virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y);
- virtual void uniform2iv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dint* v);
- virtual void uniform3f(WGC3Dint location,
- WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
- virtual void uniform3fv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dfloat* v);
- virtual void uniform3i(WGC3Dint location,
- WGC3Dint x, WGC3Dint y, WGC3Dint z);
- virtual void uniform3iv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dint* v);
- virtual void uniform4f(WGC3Dint location,
- WGC3Dfloat x, WGC3Dfloat y,
- WGC3Dfloat z, WGC3Dfloat w);
- virtual void uniform4fv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dfloat* v);
- virtual void uniform4i(WGC3Dint location,
- WGC3Dint x, WGC3Dint y, WGC3Dint z, WGC3Dint w);
- virtual void uniform4iv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dint* v);
- virtual void uniformMatrix2fv(WGC3Dint location,
- WGC3Dsizei count,
- WGC3Dboolean transpose,
- const WGC3Dfloat* value);
- virtual void uniformMatrix3fv(WGC3Dint location,
- WGC3Dsizei count,
- WGC3Dboolean transpose,
- const WGC3Dfloat* value);
- virtual void uniformMatrix4fv(WGC3Dint location,
- WGC3Dsizei count,
- WGC3Dboolean transpose,
- const WGC3Dfloat* value);
-
- virtual void useProgram(WebGLId program);
- virtual void validateProgram(WebGLId program);
-
- virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x);
- virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y);
- virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib3f(WGC3Duint index,
- WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
- virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib4f(WGC3Duint index,
- WGC3Dfloat x, WGC3Dfloat y,
- WGC3Dfloat z, WGC3Dfloat w);
- virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttribPointer(WGC3Duint index,
- WGC3Dint size,
- WGC3Denum type,
- WGC3Dboolean normalized,
- WGC3Dsizei stride,
- WGC3Dintptr offset);
-
- virtual void viewport(WGC3Dint x, WGC3Dint y,
- WGC3Dsizei width, WGC3Dsizei height);
-
- // Support for buffer creation and deletion
- virtual WebGLId createBuffer();
- virtual WebGLId createFramebuffer();
- virtual WebGLId createProgram();
- virtual WebGLId createRenderbuffer();
- virtual WebGLId createShader(WGC3Denum);
- virtual WebGLId createTexture();
-
- virtual void deleteBuffer(WebGLId);
- virtual void deleteFramebuffer(WebGLId);
- virtual void deleteProgram(WebGLId);
- virtual void deleteRenderbuffer(WebGLId);
- virtual void deleteShader(WebGLId);
- virtual void deleteTexture(WebGLId);
-
- virtual void synthesizeGLError(WGC3Denum);
-
- virtual void* mapBufferSubDataCHROMIUM(
- WGC3Denum target, WGC3Dintptr offset,
- WGC3Dsizeiptr size, WGC3Denum access);
- virtual void unmapBufferSubDataCHROMIUM(const void*);
- virtual void* mapTexSubImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- WGC3Denum access);
- virtual void unmapTexSubImage2DCHROMIUM(const void*);
-
- virtual void setVisibilityCHROMIUM(bool visible);
-
- virtual void setMemoryAllocationChangedCallbackCHROMIUM(
- WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback);
-
- virtual void discardFramebufferEXT(WGC3Denum target,
- WGC3Dsizei numAttachments,
- const WGC3Denum* attachments);
- virtual void discardBackbufferCHROMIUM();
- virtual void ensureBackbufferCHROMIUM();
-
- virtual void copyTextureToParentTextureCHROMIUM(
- WebGLId texture, WebGLId parentTexture);
-
- virtual void rateLimitOffscreenContextCHROMIUM();
-
- virtual WebKit::WebString getRequestableExtensionsCHROMIUM();
- virtual void requestExtensionCHROMIUM(const char*);
-
- virtual void blitFramebufferCHROMIUM(
- WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
- WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
- WGC3Dbitfield mask, WGC3Denum filter);
- virtual void renderbufferStorageMultisampleCHROMIUM(
- WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
- WGC3Dsizei width, WGC3Dsizei height);
-
- virtual WebKit::WebString getTranslatedShaderSourceANGLE(WebGLId shader);
-
- virtual WebGLId createCompositorTexture(WGC3Dsizei width, WGC3Dsizei height);
- virtual void deleteCompositorTexture(WebGLId parent_texture);
- virtual void copyTextureToCompositor(WebGLId texture,
- WebGLId parent_texture);
-
- virtual void setContextLostCallback(
- WebGraphicsContext3D::WebGraphicsContextLostCallback* callback);
- virtual WGC3Denum getGraphicsResetStatusARB();
-
- virtual void texImageIOSurface2DCHROMIUM(
- WGC3Denum target, WGC3Dint width, WGC3Dint height,
- WGC3Duint ioSurfaceId, WGC3Duint plane);
-
- virtual void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId);
- virtual void releaseTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId);
-
- virtual void texStorage2DEXT(
- WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
- WGC3Dint width, WGC3Dint height);
- virtual WGC3Duint createImageCHROMIUM(
- WGC3Dsizei width, WGC3Dsizei height, WGC3Denum internalformat);
- virtual void destroyImageCHROMIUM(WGC3Duint image_id);
- virtual void getImageParameterivCHROMIUM(
- WGC3Duint image_id, WGC3Denum pname, WGC3Dint* params);
- virtual void* mapImageCHROMIUM(WGC3Duint image_id, WGC3Denum access);
- virtual void unmapImageCHROMIUM(WGC3Duint image_id);
- virtual WebGLId createQueryEXT();
- virtual void deleteQueryEXT(WebGLId query);
- virtual WGC3Dboolean isQueryEXT(WebGLId query);
- virtual void beginQueryEXT(WGC3Denum target, WebGLId query);
- virtual void endQueryEXT(WGC3Denum target);
- virtual void getQueryivEXT(
- WGC3Denum target, WGC3Denum pname, WGC3Dint* params);
- virtual void getQueryObjectuivEXT(
- WebGLId query, WGC3Denum pname, WGC3Duint* params);
-
- virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint source_id,
- WGC3Duint dest_id, WGC3Dint level,
- WGC3Denum internal_format,
- WGC3Denum dest_type);
-
- virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location,
- const WGC3Dchar* uniform);
-
- virtual void shallowFlushCHROMIUM();
-
- virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox);
- virtual void produceTextureCHROMIUM(WGC3Denum target,
- const WGC3Dbyte* mailbox);
- virtual void consumeTextureCHROMIUM(WGC3Denum target,
- const WGC3Dbyte* mailbox);
-
- virtual void insertEventMarkerEXT(const WGC3Dchar* marker);
- virtual void pushGroupMarkerEXT(const WGC3Dchar* marker);
- virtual void popGroupMarkerEXT();
-
- virtual void* mapBufferCHROMIUM(WGC3Denum target, WGC3Denum access);
- virtual WGC3Dboolean unmapBufferCHROMIUM(WGC3Denum target);
-
- // Async pixel transfer functions.
- virtual void asyncTexImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
- virtual void asyncTexSubImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
- virtual void waitAsyncTexImage2DCHROMIUM(WGC3Denum target);
-
- virtual void drawBuffersEXT(WGC3Dsizei n, const WGC3Denum* bufs);
-
- virtual unsigned insertSyncPoint();
- virtual void signalSyncPoint(unsigned sync_point,
- WebGraphicsSyncPointCallback* callback);
-
- virtual void loseContextCHROMIUM(WGC3Denum current, WGC3Denum other);
-
- protected:
- virtual GrGLInterface* onCreateGrGLInterface();
-
- private:
- WebGraphicsContext3DInProcessCommandBufferImpl(
- const WebKit::WebGraphicsContext3D::Attributes& attributes,
- bool is_offscreen,
- gfx::AcceleratedWidget window);
-
- // SwapBuffers callback.
- void OnSwapBuffersComplete();
- virtual void OnContextLost();
-
- bool MaybeInitializeGL();
-
- // Used to try to find bugs in code that calls gl directly through the gl api
- // instead of going through WebGraphicsContext3D.
- void ClearContext();
-
-
- bool is_offscreen_;
- // Only used when not offscreen.
- gfx::AcceleratedWidget window_;
-
- bool initialized_;
- bool initialize_failed_;
-
- // The context we use for OpenGL rendering.
- GLInProcessContext* context_;
- // The GLES2Implementation we use for OpenGL rendering.
- ::gpu::gles2::GLES2Implementation* gl_;
-
- WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
- WGC3Denum context_lost_reason_;
-
- WebKit::WebGraphicsContext3D::Attributes attributes_;
- int cached_width_, cached_height_;
-
- // For tracking which FBO is bound.
- WebGLId bound_fbo_;
-
- // Errors raised by synthesizeGLError().
- std::vector<WGC3Denum> synthetic_errors_;
-
- std::vector<uint8> scanline_;
-
- void FlipVertically(uint8* framebuffer,
- unsigned int width,
- unsigned int height);
-};
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // defined(ENABLE_GPU)
-#endif // WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_COMMAND_BUFFER_IMPL_H_
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
deleted file mode 100644
index b5ef5ca..0000000
--- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
+++ /dev/null
@@ -1,1813 +0,0 @@
-// Copyright (c) 2012 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/gpu/webgraphicscontext3d_in_process_impl.h"
-
-#include <string.h>
-
-#include <algorithm>
-#include <string>
-#include <vector>
-
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string_split.h"
-#include "base/synchronization/lock.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
-#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_bindings_skia_in_process.h"
-#include "ui/gl/gl_context.h"
-#include "ui/gl/gl_implementation.h"
-#include "ui/gl/gl_surface.h"
-
-namespace webkit {
-namespace gpu {
-
-enum {
- MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
- MAX_VARYING_VECTORS = 0x8DFC,
- MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD
-};
-
-struct WebGraphicsContext3DInProcessImpl::ShaderSourceEntry {
- explicit ShaderSourceEntry(WGC3Denum shader_type)
- : type(shader_type),
- is_valid(false) {
- }
-
- WGC3Denum type;
- scoped_ptr<char[]> source;
- scoped_ptr<char[]> log;
- scoped_ptr<char[]> translated_source;
- bool is_valid;
-};
-
-WebGraphicsContext3DInProcessImpl::WebGraphicsContext3DInProcessImpl(
- gfx::GLSurface* surface,
- gfx::GLContext* context,
- bool render_directly_to_web_view)
- : initialized_(false),
- render_directly_to_web_view_(render_directly_to_web_view),
- is_gles2_(false),
- have_ext_framebuffer_object_(false),
- have_ext_framebuffer_multisample_(false),
- have_angle_framebuffer_multisample_(false),
- have_ext_oes_standard_derivatives_(false),
- have_ext_oes_egl_image_external_(false),
- texture_(0),
- fbo_(0),
- depth_stencil_buffer_(0),
- cached_width_(0),
- cached_height_(0),
- multisample_fbo_(0),
- multisample_depth_stencil_buffer_(0),
- multisample_color_buffer_(0),
- bound_fbo_(0),
- bound_texture_(0),
- scanline_(0),
- gl_context_(context),
- gl_surface_(surface),
- fragment_compiler_(0),
- vertex_compiler_(0) {
-}
-
-// All instances in a process that share resources are in the same share group.
-static base::LazyInstance<
- std::set<WebGraphicsContext3DInProcessImpl*> >
- g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER;
-static base::LazyInstance<base::Lock>::Leaky
- g_all_shared_contexts_lock = LAZY_INSTANCE_INITIALIZER;
-
-WebGraphicsContext3DInProcessImpl::~WebGraphicsContext3DInProcessImpl() {
- base::AutoLock a(g_all_shared_contexts_lock.Get());
- g_all_shared_contexts.Pointer()->erase(this);
-
- if (!initialized_)
- return;
-
- makeContextCurrent();
-
- if (attributes_.antialias) {
- glDeleteRenderbuffersEXT(1, &multisample_color_buffer_);
- if (attributes_.depth || attributes_.stencil)
- glDeleteRenderbuffersEXT(1, &multisample_depth_stencil_buffer_);
- glDeleteFramebuffersEXT(1, &multisample_fbo_);
- } else {
- if (attributes_.depth || attributes_.stencil)
- glDeleteRenderbuffersEXT(1, &depth_stencil_buffer_);
- }
- glDeleteTextures(1, &texture_);
- if (scanline_)
- delete[] scanline_;
- glDeleteFramebuffersEXT(1, &fbo_);
-
- gl_context_->ReleaseCurrent(gl_surface_.get());
- gl_context_->Destroy();
- gl_surface_->Destroy();
-
- for (ShaderSourceMap::iterator ii = shader_source_map_.begin();
- ii != shader_source_map_.end(); ++ii) {
- if (ii->second)
- delete ii->second;
- }
- AngleDestroyCompilers();
-}
-
-WebGraphicsContext3DInProcessImpl*
-WebGraphicsContext3DInProcessImpl::CreateForWindow(
- WebGraphicsContext3D::Attributes attributes,
- gfx::AcceleratedWidget window,
- gfx::GLShareGroup* share_group) {
- if (!gfx::GLSurface::InitializeOneOff())
- return NULL;
-
- scoped_refptr<gfx::GLSurface> gl_surface =
- gfx::GLSurface::CreateViewGLSurface(false, window);
- if (!gl_surface)
- return NULL;
-
- gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
-
- scoped_refptr<gfx::GLContext> gl_context = gfx::GLContext::CreateGLContext(
- share_group,
- gl_surface.get(),
- gpu_preference);
- if (!gl_context)
- return NULL;
- scoped_ptr<WebGraphicsContext3DInProcessImpl> context(
- new WebGraphicsContext3DInProcessImpl(
- gl_surface.get(), gl_context.get(), true));
- if (!context->Initialize(attributes))
- return NULL;
- return context.release();
-}
-
-bool WebGraphicsContext3DInProcessImpl::Initialize(
- WebGraphicsContext3D::Attributes attributes) {
- is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2;
-
-
- attributes_ = attributes;
-
- // FIXME: for the moment we disable multisampling for the compositor.
- // It actually works in this implementation, but there are a few
- // considerations. First, we likely want to reduce the fuzziness in
- // these tests as much as possible because we want to run pixel tests.
- // Second, Mesa's multisampling doesn't seem to antialias straight
- // edges in some CSS 3D samples. Third, we don't have multisampling
- // support for the compositor in the normal case at the time of this
- // writing.
- if (render_directly_to_web_view_)
- attributes_.antialias = false;
-
- if (!gl_context_->MakeCurrent(gl_surface_)) {
- gl_context_ = NULL;
- return false;
- }
-
- const char* extensions =
- reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
- DCHECK(extensions);
- have_ext_framebuffer_object_ =
- strstr(extensions, "GL_EXT_framebuffer_object") != NULL;
- have_ext_framebuffer_multisample_ =
- strstr(extensions, "GL_EXT_framebuffer_multisample") != NULL;
-#if !defined(OS_ANDROID)
- // Some Android Qualcomm drivers falsely report this ANGLE extension string.
- // See http://crbug.com/165736
- have_angle_framebuffer_multisample_ =
- strstr(extensions, "GL_ANGLE_framebuffer_multisample") != NULL;
-#endif
- have_ext_oes_standard_derivatives_ =
- strstr(extensions, "GL_OES_standard_derivatives") != NULL;
- have_ext_oes_egl_image_external_ =
- strstr(extensions, "GL_OES_EGL_image_external") != NULL;
-
- ValidateAttributes();
-
- if (!is_gles2_) {
- glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
- glEnable(GL_POINT_SPRITE);
- }
-
- if (!AngleCreateCompilers()) {
- AngleDestroyCompilers();
- return false;
- }
-
- initialized_ = true;
- gl_context_->ReleaseCurrent(gl_surface_.get());
-
- if (attributes_.shareResources)
- g_all_shared_contexts.Pointer()->insert(this);
-
- return true;
-}
-
-void WebGraphicsContext3DInProcessImpl::ValidateAttributes() {
- const char* extensions =
- reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
-
- if (attributes_.stencil) {
- if (strstr(extensions, "GL_OES_packed_depth_stencil") ||
- strstr(extensions, "GL_EXT_packed_depth_stencil")) {
- if (!attributes_.depth) {
- attributes_.depth = true;
- }
- } else {
- attributes_.stencil = false;
- }
- }
- if (attributes_.antialias) {
- bool isValidVendor = true;
-#if defined(OS_MACOSX)
- // Currently in Mac we only turn on antialias if vendor is NVIDIA.
- const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
- if (!strstr(vendor, "NVIDIA"))
- isValidVendor = false;
-#endif
- if (!(isValidVendor &&
- (have_ext_framebuffer_multisample_ ||
- (have_angle_framebuffer_multisample_ &&
- strstr(extensions, "GL_OES_rgb8_rgba8")))))
- attributes_.antialias = false;
-
- // Don't antialias when using Mesa to ensure more reliable testing and
- // because it doesn't appear to multisample straight lines correctly.
- const char* renderer =
- reinterpret_cast<const char*>(glGetString(GL_RENDERER));
- if (!strncmp(renderer, "Mesa", 4)) {
- attributes_.antialias = false;
- }
- }
-}
-
-void WebGraphicsContext3DInProcessImpl::ResolveMultisampledFramebuffer(
- WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) {
- if (attributes_.antialias) {
- glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, multisample_fbo_);
- glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo_);
- if (have_ext_framebuffer_multisample_) {
- glBlitFramebufferEXT(x, y,
- x + width, y + height,
- x, y,
- x + width, y + height,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- } else {
- DCHECK(have_angle_framebuffer_multisample_);
- glBlitFramebufferANGLE(x, y,
- x + width, y + height,
- x, y,
- x + width, y + height,
- GL_COLOR_BUFFER_BIT, GL_NEAREST);
- }
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
- }
-}
-
-bool WebGraphicsContext3DInProcessImpl::makeContextCurrent() {
- return gl_context_->MakeCurrent(gl_surface_.get());
-}
-
-int WebGraphicsContext3DInProcessImpl::width() {
- return cached_width_;
-}
-
-int WebGraphicsContext3DInProcessImpl::height() {
- return cached_height_;
-}
-
-bool WebGraphicsContext3DInProcessImpl::isGLES2Compliant() {
- return is_gles2_;
-}
-
-bool WebGraphicsContext3DInProcessImpl::setParentContext(
- WebGraphicsContext3D* parent_context) {
- return false;
-}
-
-WebGLId WebGraphicsContext3DInProcessImpl::getPlatformTextureId() {
- return texture_;
-}
-
-void WebGraphicsContext3DInProcessImpl::prepareTexture() {
- if (!gl_surface_->IsOffscreen()) {
- gl_surface_->SwapBuffers();
- } else if (!render_directly_to_web_view_) {
- // We need to prepare our rendering results for the compositor.
- makeContextCurrent();
- ResolveMultisampledFramebuffer(0, 0, cached_width_, cached_height_);
- }
-}
-
-void WebGraphicsContext3DInProcessImpl::postSubBufferCHROMIUM(
- int x, int y, int width, int height) {
- DCHECK(gl_surface_->HasExtension("GL_CHROMIUM_post_sub_buffer"));
- gl_surface_->PostSubBuffer(x, y, width, height);
-}
-
-namespace {
-
-int CreateTextureObject(GLenum target) {
- GLuint texture = 0;
- glGenTextures(1, &texture);
- glBindTexture(target, texture);
- glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- return texture;
-}
-
-} // anonymous namespace
-
-void WebGraphicsContext3DInProcessImpl::reshape(int width, int height) {
- cached_width_ = width;
- cached_height_ = height;
- makeContextCurrent();
-
- bool must_restore_fbo = false;
- if (gl_surface_->IsOffscreen())
- must_restore_fbo = AllocateOffscreenFrameBuffer(width, height);
-
- gl_surface_->Resize(gfx::Size(width, height));
- ClearRenderTarget();
-
- if (must_restore_fbo)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
-
- if (scanline_) {
- delete[] scanline_;
- scanline_ = 0;
- }
- scanline_ = new unsigned char[width * 4];
-}
-
-void WebGraphicsContext3DInProcessImpl::reshapeWithScaleFactor(
- int width, int height, float scaleFactor) {
- reshape(width, height);
-}
-
-bool WebGraphicsContext3DInProcessImpl::AllocateOffscreenFrameBuffer(
- int width, int height) {
- GLenum target = GL_TEXTURE_2D;
-
- if (!texture_) {
- // Generate the texture object
- texture_ = CreateTextureObject(target);
- // Generate the framebuffer object
- glGenFramebuffersEXT(1, &fbo_);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_);
- bound_fbo_ = fbo_;
- if (attributes_.depth || attributes_.stencil)
- glGenRenderbuffersEXT(1, &depth_stencil_buffer_);
- // Generate the multisample framebuffer object
- if (attributes_.antialias) {
- glGenFramebuffersEXT(1, &multisample_fbo_);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, multisample_fbo_);
- bound_fbo_ = multisample_fbo_;
- glGenRenderbuffersEXT(1, &multisample_color_buffer_);
- if (attributes_.depth || attributes_.stencil)
- glGenRenderbuffersEXT(1, &multisample_depth_stencil_buffer_);
- }
- }
-
- GLint internal_multisampled_color_format = 0;
- GLint internal_color_format = 0;
- GLint color_format = 0;
- GLint internal_depth_stencil_format = 0;
- if (attributes_.alpha) {
- // GL_RGBA8_OES == GL_RGBA8
- internal_multisampled_color_format = GL_RGBA8;
- internal_color_format = is_gles2_ ? GL_RGBA : GL_RGBA8;
- color_format = GL_RGBA;
- } else {
- // GL_RGB8_OES == GL_RGB8
- internal_multisampled_color_format = GL_RGB8;
- internal_color_format = is_gles2_ ? GL_RGB : GL_RGB8;
- color_format = GL_RGB;
- }
- if (attributes_.stencil || attributes_.depth) {
- // We don't allow the logic where stencil is required and depth is not.
- // See GraphicsContext3DInternal constructor.
- if (attributes_.stencil && attributes_.depth) {
- internal_depth_stencil_format = GL_DEPTH24_STENCIL8_EXT;
- } else {
- if (is_gles2_)
- internal_depth_stencil_format = GL_DEPTH_COMPONENT16;
- else
- internal_depth_stencil_format = GL_DEPTH_COMPONENT;
- }
- }
-
- bool must_restore_fbo = false;
-
- // Resize multisampling FBO
- if (attributes_.antialias) {
- GLint max_sample_count;
- glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count);
- GLint sample_count = std::min(8, max_sample_count);
- if (bound_fbo_ != multisample_fbo_) {
- must_restore_fbo = true;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, multisample_fbo_);
- }
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, multisample_color_buffer_);
- if (have_ext_framebuffer_multisample_) {
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT,
- sample_count,
- internal_multisampled_color_format,
- width,
- height);
- } else {
- DCHECK(have_angle_framebuffer_multisample_);
- glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER_EXT,
- sample_count,
- internal_multisampled_color_format,
- width,
- height);
- }
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_RENDERBUFFER_EXT,
- multisample_color_buffer_);
- if (attributes_.stencil || attributes_.depth) {
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,
- multisample_depth_stencil_buffer_);
- if (have_ext_framebuffer_multisample_) {
- glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT,
- sample_count,
- internal_depth_stencil_format,
- width,
- height);
- } else {
- DCHECK(have_angle_framebuffer_multisample_);
- glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER_EXT,
- sample_count,
- internal_depth_stencil_format,
- width,
- height);
- }
- if (attributes_.stencil)
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
- GL_STENCIL_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT,
- multisample_depth_stencil_buffer_);
- if (attributes_.depth)
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
- GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT,
- multisample_depth_stencil_buffer_);
- }
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- LOG(ERROR) << "Multisampling framebuffer was incomplete";
-
- // FIXME: cleanup.
- NOTIMPLEMENTED();
- }
- }
-
- // Resize regular FBO
- if (bound_fbo_ != fbo_) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_);
- must_restore_fbo = true;
- }
- glBindTexture(target, texture_);
- glTexImage2D(target, 0, internal_color_format,
- width, height,
- 0, color_format, GL_UNSIGNED_BYTE, 0);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- target,
- texture_,
- 0);
- glBindTexture(target, 0);
- if (!attributes_.antialias && (attributes_.stencil || attributes_.depth)) {
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_stencil_buffer_);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
- internal_depth_stencil_format,
- width, height);
- if (attributes_.stencil)
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
- GL_STENCIL_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT,
- depth_stencil_buffer_);
- if (attributes_.depth)
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
- GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT,
- depth_stencil_buffer_);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
- }
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- LOG(ERROR) << "Framebuffer was incomplete";
-
- // FIXME: cleanup.
- NOTIMPLEMENTED();
- }
-
- if (attributes_.antialias) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, multisample_fbo_);
- if (bound_fbo_ == multisample_fbo_)
- must_restore_fbo = false;
- }
- return must_restore_fbo;
-}
-
-void WebGraphicsContext3DInProcessImpl::ClearRenderTarget() {
- // Initialize renderbuffers to 0.
- GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0;
- GLint clearStencil = 0;
- GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE};
- GLboolean depthMask = GL_TRUE;
- GLuint stencilMask = 0xffffffff;
- GLboolean isScissorEnabled = GL_FALSE;
- GLboolean isDitherEnabled = GL_FALSE;
- GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
- glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
- glClearColor(0, 0, 0, 0);
- glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- if (attributes_.depth) {
- glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth);
- glClearDepth(1);
- glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
- glDepthMask(GL_TRUE);
- clearMask |= GL_DEPTH_BUFFER_BIT;
- }
- if (attributes_.stencil) {
- glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil);
- glClearStencil(0);
- glGetIntegerv(GL_STENCIL_WRITEMASK,
- reinterpret_cast<GLint*>(&stencilMask));
- glStencilMaskSeparate(GL_FRONT, 0xffffffff);
- clearMask |= GL_STENCIL_BUFFER_BIT;
- }
- isScissorEnabled = glIsEnabled(GL_SCISSOR_TEST);
- glDisable(GL_SCISSOR_TEST);
- isDitherEnabled = glIsEnabled(GL_DITHER);
- glDisable(GL_DITHER);
-
- glClear(clearMask);
-
- glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
- glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
- if (attributes_.depth) {
- glClearDepth(clearDepth);
- glDepthMask(depthMask);
- }
- if (attributes_.stencil) {
- glClearStencil(clearStencil);
- glStencilMaskSeparate(GL_FRONT, stencilMask);
- }
- if (isScissorEnabled)
- glEnable(GL_SCISSOR_TEST);
- else
- glDisable(GL_SCISSOR_TEST);
- if (isDitherEnabled)
- glEnable(GL_DITHER);
- else
- glDisable(GL_DITHER);
-}
-
-void WebGraphicsContext3DInProcessImpl::FlipVertically(
- unsigned char* framebuffer, unsigned int width, unsigned int height) {
- unsigned char* scanline = scanline_;
- if (!scanline)
- return;
- unsigned int row_bytes = width * 4;
- unsigned int count = height / 2;
- for (unsigned int i = 0; i < count; i++) {
- unsigned char* row_a = framebuffer + i * row_bytes;
- unsigned char* row_b = framebuffer + (height - i - 1) * row_bytes;
- // FIXME: this is where the multiplication of the alpha
- // channel into the color buffer will need to occur if the
- // user specifies the "premultiplyAlpha" flag in the context
- // creation attributes.
- memcpy(scanline, row_b, row_bytes);
- memcpy(row_b, row_a, row_bytes);
- memcpy(row_a, scanline, row_bytes);
- }
-}
-
-bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
- unsigned char* pixels, size_t bufferSize, WebGLId framebuffer,
- int width, int height) {
- if (bufferSize != static_cast<size_t>(4 * width * height))
- return false;
-
- makeContextCurrent();
-
- // Earlier versions of this code used the GPU to flip the
- // framebuffer vertically before reading it back for compositing
- // via software. This code was quite complicated, used a lot of
- // GPU memory, and didn't provide an obvious speedup. Since this
- // vertical flip is only a temporary solution anyway until Chrome
- // is fully GPU composited, it wasn't worth the complexity.
-
- // In this implementation fbo_, not 0, is the drawing buffer, so
- // special-case that.
- if (framebuffer == 0)
- framebuffer = fbo_;
-
- if (framebuffer == fbo_)
- ResolveMultisampledFramebuffer(0, 0, width, height);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
-
- GLint pack_alignment = 4;
- bool must_restore_pack_alignment = false;
- glGetIntegerv(GL_PACK_ALIGNMENT, &pack_alignment);
- if (pack_alignment > 4) {
- glPixelStorei(GL_PACK_ALIGNMENT, 4);
- must_restore_pack_alignment = true;
- }
-
- if (is_gles2_) {
- // FIXME: consider testing for presence of GL_OES_read_format
- // and GL_EXT_read_format_bgra, and using GL_BGRA_EXT here
- // directly.
- glReadPixels(0, 0, width, height,
- GL_RGBA, GL_UNSIGNED_BYTE, pixels);
- for (size_t i = 0; i < bufferSize; i += 4) {
- std::swap(pixels[i], pixels[i + 2]);
- }
- } else {
- glReadPixels(0, 0, width, height,
- GL_BGRA, GL_UNSIGNED_BYTE, pixels);
- }
-
- if (must_restore_pack_alignment)
- glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
-
- if (pixels)
- FlipVertically(pixels, width, height);
-
- return true;
-}
-
-bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
- unsigned char* pixels, size_t bufferSize) {
- return readBackFramebuffer(pixels, bufferSize, fbo_, width(), height());
-}
-
-void WebGraphicsContext3DInProcessImpl::synthesizeGLError(WGC3Denum error) {
- if (synthetic_errors_set_.find(error) == synthetic_errors_set_.end()) {
- synthetic_errors_set_.insert(error);
- synthetic_errors_list_.push_back(error);
- }
-}
-
-void* WebGraphicsContext3DInProcessImpl::mapBufferSubDataCHROMIUM(
- WGC3Denum target, WGC3Dintptr offset,
- WGC3Dsizeiptr size, WGC3Denum access) {
- return 0;
-}
-
-void WebGraphicsContext3DInProcessImpl::unmapBufferSubDataCHROMIUM(
- const void* mem) {
-}
-
-void* WebGraphicsContext3DInProcessImpl::mapTexSubImage2DCHROMIUM(
- WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset,
- WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Denum type,
- WGC3Denum access) {
- return 0;
-}
-
-void WebGraphicsContext3DInProcessImpl::unmapTexSubImage2DCHROMIUM(
- const void* mem) {
-}
-
-void WebGraphicsContext3DInProcessImpl::setVisibilityCHROMIUM(bool visible) {
-}
-
-void WebGraphicsContext3DInProcessImpl::
- setMemoryAllocationChangedCallbackCHROMIUM(
- WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) {
-}
-
-void WebGraphicsContext3DInProcessImpl::discardFramebufferEXT(
- WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) {
-}
-
-void WebGraphicsContext3DInProcessImpl::discardBackbufferCHROMIUM() {
-}
-
-void WebGraphicsContext3DInProcessImpl::ensureBackbufferCHROMIUM() {
-}
-
-void WebGraphicsContext3DInProcessImpl::copyTextureToParentTextureCHROMIUM(
- WebGLId id, WebGLId id2) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessImpl::bindUniformLocationCHROMIUM(
- WebGLId program, WGC3Dint location, const WGC3Dchar* uniform) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessImpl::genMailboxCHROMIUM(
- WGC3Dbyte* mailbox) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessImpl::produceTextureCHROMIUM(
- WGC3Denum target, const WGC3Dbyte* mailbox) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessImpl::consumeTextureCHROMIUM(
- WGC3Denum target, const WGC3Dbyte* mailbox) {
- NOTIMPLEMENTED();
-}
-
-WebString WebGraphicsContext3DInProcessImpl::
- getRequestableExtensionsCHROMIUM() {
- return WebString();
-}
-
-void WebGraphicsContext3DInProcessImpl::requestExtensionCHROMIUM(const char*) {
-}
-
-void WebGraphicsContext3DInProcessImpl::blitFramebufferCHROMIUM(
- WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
- WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
- WGC3Dbitfield mask, WGC3Denum filter) {
-}
-
-void WebGraphicsContext3DInProcessImpl::renderbufferStorageMultisampleCHROMIUM(
- WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
- WGC3Dsizei width, WGC3Dsizei height) {
-}
-
-// Helper macros to reduce the amount of code.
-
-#define DELEGATE_TO_GL(name, glname) \
-void WebGraphicsContext3DInProcessImpl::name() { \
- makeContextCurrent(); \
- gl##glname(); \
-}
-
-#define DELEGATE_TO_GL_1(name, glname, t1) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1) { \
- makeContextCurrent(); \
- gl##glname(a1); \
-}
-
-#define DELEGATE_TO_GL_1R(name, glname, t1, rt) \
-rt WebGraphicsContext3DInProcessImpl::name(t1 a1) { \
- makeContextCurrent(); \
- return gl##glname(a1); \
-}
-
-#define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \
-rt WebGraphicsContext3DInProcessImpl::name(t1 a1) { \
- makeContextCurrent(); \
- return gl##glname(a1) ? true : false; \
-}
-
-#define DELEGATE_TO_GL_2(name, glname, t1, t2) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2) { \
- makeContextCurrent(); \
- gl##glname(a1, a2); \
-}
-
-#define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \
-rt WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2) { \
- makeContextCurrent(); \
- return gl##glname(a1, a2); \
-}
-
-#define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2, t3 a3) { \
- makeContextCurrent(); \
- gl##glname(a1, a2, a3); \
-}
-
-#define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
- makeContextCurrent(); \
- gl##glname(a1, a2, a3, a4); \
-}
-
-#define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, \
- t5 a5) { \
- makeContextCurrent(); \
- gl##glname(a1, a2, a3, a4, a5); \
-}
-
-#define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, \
- t5 a5, t6 a6) { \
- makeContextCurrent(); \
- gl##glname(a1, a2, a3, a4, a5, a6); \
-}
-
-#define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, \
- t5 a5, t6 a6, t7 a7) { \
- makeContextCurrent(); \
- gl##glname(a1, a2, a3, a4, a5, a6, a7); \
-}
-
-#define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, \
- t5 a5, t6 a6, t7 a7, t8 a8) { \
- makeContextCurrent(); \
- gl##glname(a1, a2, a3, a4, a5, a6, a7, a8); \
-}
-
-#define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
-void WebGraphicsContext3DInProcessImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, \
- t5 a5, t6 a6, t7 a7, t8 a8, \
- t9 a9) { \
- makeContextCurrent(); \
- gl##glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
-}
-
-void WebGraphicsContext3DInProcessImpl::activeTexture(WGC3Denum texture) {
- // FIXME: query number of textures available.
- if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0+32)
- // FIXME: raise exception.
- return;
-
- makeContextCurrent();
- glActiveTexture(texture);
-}
-
-DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId)
-
-DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation,
- WebGLId, WGC3Duint, const WGC3Dchar*)
-
-DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId);
-
-void WebGraphicsContext3DInProcessImpl::bindFramebuffer(
- WGC3Denum target, WebGLId framebuffer) {
- makeContextCurrent();
- if (!framebuffer)
- framebuffer = (attributes_.antialias ? multisample_fbo_ : fbo_);
- if (framebuffer != bound_fbo_) {
- glBindFramebufferEXT(target, framebuffer);
- bound_fbo_ = framebuffer;
- }
-}
-
-DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbufferEXT, WGC3Denum, WebGLId)
-
-void WebGraphicsContext3DInProcessImpl::bindTexture(
- WGC3Denum target, WebGLId texture) {
- makeContextCurrent();
- glBindTexture(target, texture);
- bound_texture_ = texture;
-}
-
-DELEGATE_TO_GL_4(blendColor, BlendColor,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum)
-
-DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate,
- WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate,
- WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(bufferData, BufferData,
- WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum)
-
-DELEGATE_TO_GL_4(bufferSubData, BufferSubData,
- WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*)
-
-DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatusEXT,
- WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield)
-
-DELEGATE_TO_GL_4(clearColor, ClearColor,
- WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
-
-DELEGATE_TO_GL_1(clearDepth, ClearDepth, WGC3Dclampf)
-
-DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint)
-
-DELEGATE_TO_GL_4(colorMask, ColorMask,
- WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean)
-
-void WebGraphicsContext3DInProcessImpl::compileShader(WebGLId shader) {
- makeContextCurrent();
-
- ShaderSourceMap::iterator result = shader_source_map_.find(shader);
- if (result == shader_source_map_.end()) {
- // Passing down to gl driver to generate the correct error; or the case
- // where the shader deletion is delayed when it's attached to a program.
- glCompileShader(shader);
- return;
- }
- ShaderSourceEntry* entry = result->second;
- DCHECK(entry);
-
- if (!AngleValidateShaderSource(entry)) {
- // Shader didn't validate; don't move forward with compiling
- // translated source.
- return;
- }
-
- const char* translated_source = entry->translated_source.get();
- int shader_length = translated_source ? strlen(translated_source) : 0;
- glShaderSource(
- shader, 1, const_cast<const char**>(&translated_source), &shader_length);
- glCompileShader(shader);
-
-#ifndef NDEBUG
- int compileStatus;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
- // DCHECK that ANGLE generated GLSL will be accepted by OpenGL
- DCHECK(compileStatus == GL_TRUE);
-#endif
-}
-
-DELEGATE_TO_GL_8(compressedTexImage2D, CompressedTexImage2D,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
- WGC3Dsizei, WGC3Dsizei, const void*)
-
-DELEGATE_TO_GL_9(compressedTexSubImage2D, CompressedTexSubImage2D,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
- WGC3Denum, WGC3Dsizei, const void*)
-
-void WebGraphicsContext3DInProcessImpl::copyTexImage2D(
- WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dint x,
- WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border) {
- makeContextCurrent();
-
- bool needsResolve = (attributes_.antialias && bound_fbo_ == multisample_fbo_);
- if (needsResolve) {
- ResolveMultisampledFramebuffer(x, y, width, height);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_);
- }
-
- glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
-
- if (needsResolve)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
-}
-
-void WebGraphicsContext3DInProcessImpl::copyTexSubImage2D(
- WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset,
- WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) {
- makeContextCurrent();
-
- bool needsResolve = (attributes_.antialias && bound_fbo_ == multisample_fbo_);
- if (needsResolve) {
- ResolveMultisampledFramebuffer(x, y, width, height);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_);
- }
-
- glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-
- if (needsResolve)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
-}
-
-DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum)
-
-DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum)
-
-DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean)
-
-DELEGATE_TO_GL_2(depthRange, DepthRange, WGC3Dclampf, WGC3Dclampf)
-
-DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId)
-
-DELEGATE_TO_GL_1(disable, Disable, WGC3Denum)
-
-DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray, WGC3Duint)
-
-DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei)
-
-void WebGraphicsContext3DInProcessImpl::drawElements(
- WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset) {
- makeContextCurrent();
- glDrawElements(mode, count, type,
- reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
-}
-
-DELEGATE_TO_GL_1(enable, Enable, WGC3Denum)
-
-DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, WGC3Duint)
-
-DELEGATE_TO_GL(finish, Finish)
-
-DELEGATE_TO_GL(flush, Flush)
-
-DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbufferEXT,
- WGC3Denum, WGC3Denum, WGC3Denum, WebGLId)
-
-DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2DEXT,
- WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint)
-
-DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum)
-
-void WebGraphicsContext3DInProcessImpl::generateMipmap(WGC3Denum target) {
- makeContextCurrent();
- if (is_gles2_ || have_ext_framebuffer_object_)
- glGenerateMipmapEXT(target);
- // FIXME: provide alternative code path? This will be unpleasant
- // to implement if glGenerateMipmapEXT is not available -- it will
- // require a texture readback and re-upload.
-}
-
-bool WebGraphicsContext3DInProcessImpl::getActiveAttrib(
- WebGLId program, WGC3Duint index, ActiveInfo& info) {
- makeContextCurrent();
- if (!program) {
- synthesizeGLError(GL_INVALID_VALUE);
- return false;
- }
- GLint max_name_length = -1;
- glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
- if (max_name_length < 0)
- return false;
- scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
- GLsizei length = 0;
- GLint size = -1;
- GLenum type = 0;
- glGetActiveAttrib(program, index, max_name_length,
- &length, &size, &type, name.get());
- if (size < 0) {
- return false;
- }
- info.name = WebString::fromUTF8(name.get(), length);
- info.type = type;
- info.size = size;
- return true;
-}
-
-bool WebGraphicsContext3DInProcessImpl::getActiveUniform(
- WebGLId program, WGC3Duint index, ActiveInfo& info) {
- makeContextCurrent();
- GLint max_name_length = -1;
- glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
- if (max_name_length < 0)
- return false;
- scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
- GLsizei length = 0;
- GLint size = -1;
- GLenum type = 0;
- glGetActiveUniform(program, index, max_name_length,
- &length, &size, &type, name.get());
- if (size < 0) {
- return false;
- }
- info.name = WebString::fromUTF8(name.get(), length);
- info.type = type;
- info.size = size;
- return true;
-}
-
-DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders,
- WebGLId, WGC3Dsizei, WGC3Dsizei*, WebGLId*)
-
-DELEGATE_TO_GL_2R(getAttribLocation, GetAttribLocation,
- WebGLId, const WGC3Dchar*, WGC3Dint)
-
-DELEGATE_TO_GL_2(getBooleanv, GetBooleanv,
- WGC3Denum, WGC3Dboolean*)
-
-DELEGATE_TO_GL_3(getBufferParameteriv, GetBufferParameteriv,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-WebGraphicsContext3D::Attributes WebGraphicsContext3DInProcessImpl::
- getContextAttributes() {
- return attributes_;
-}
-
-WGC3Denum WebGraphicsContext3DInProcessImpl::getError() {
- DCHECK(synthetic_errors_list_.size() == synthetic_errors_set_.size());
- if (!synthetic_errors_set_.empty()) {
- WGC3Denum error = synthetic_errors_list_.front();
- synthetic_errors_list_.pop_front();
- synthetic_errors_set_.erase(error);
- return error;
- }
-
- makeContextCurrent();
- return glGetError();
-}
-
-bool WebGraphicsContext3DInProcessImpl::isContextLost() {
- return false;
-}
-
-DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*)
-
-void WebGraphicsContext3DInProcessImpl::getFramebufferAttachmentParameteriv(
- WGC3Denum target, WGC3Denum attachment,
- WGC3Denum pname, WGC3Dint* value) {
- makeContextCurrent();
- if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
- attachment = GL_DEPTH_ATTACHMENT; // Or GL_STENCIL_ATTACHMENT;
- // either works.
- glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value);
-}
-
-void WebGraphicsContext3DInProcessImpl::getIntegerv(
- WGC3Denum pname, WGC3Dint* value) {
- makeContextCurrent();
- if (is_gles2_) {
- glGetIntegerv(pname, value);
- return;
- }
- // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and
- // MAX_VARYING_VECTORS because desktop GL's corresponding queries
- // return the number of components whereas GLES2 return the number
- // of vectors (each vector has 4 components). Therefore, the value
- // returned by desktop GL needs to be divided by 4.
- switch (pname) {
- case MAX_FRAGMENT_UNIFORM_VECTORS:
- glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value);
- *value /= 4;
- break;
- case MAX_VERTEX_UNIFORM_VECTORS:
- glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value);
- *value /= 4;
- break;
- case MAX_VARYING_VECTORS:
- glGetIntegerv(GL_MAX_VARYING_FLOATS, value);
- *value /= 4;
- break;
- default:
- glGetIntegerv(pname, value);
- }
-}
-
-DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*)
-
-WebString WebGraphicsContext3DInProcessImpl::getProgramInfoLog(
- WebGLId program) {
- makeContextCurrent();
- GLint log_length;
- glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
- if (!log_length)
- return WebString();
- scoped_ptr<GLchar[]> log(new GLchar[log_length]);
- GLsizei returned_log_length;
- glGetProgramInfoLog(program, log_length, &returned_log_length, log.get());
- DCHECK(log_length == returned_log_length + 1);
- WebString res = WebString::fromUTF8(log.get(), returned_log_length);
- return res;
-}
-
-DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameterivEXT,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-void WebGraphicsContext3DInProcessImpl::getShaderiv(
- WebGLId shader, WGC3Denum pname, WGC3Dint* value) {
- makeContextCurrent();
-
- ShaderSourceMap::iterator result = shader_source_map_.find(shader);
- if (result != shader_source_map_.end()) {
- ShaderSourceEntry* entry = result->second;
- DCHECK(entry);
- switch (pname) {
- case GL_COMPILE_STATUS:
- if (!entry->is_valid) {
- *value = 0;
- return;
- }
- break;
- case GL_INFO_LOG_LENGTH:
- if (!entry->is_valid) {
- *value = entry->log.get() ? strlen(entry->log.get()) : 0;
- if (*value)
- (*value)++;
- return;
- }
- break;
- case GL_SHADER_SOURCE_LENGTH:
- *value = entry->source.get() ? strlen(entry->source.get()) : 0;
- if (*value)
- (*value)++;
- return;
- }
- }
-
- glGetShaderiv(shader, pname, value);
-}
-
-void WebGraphicsContext3DInProcessImpl::getShaderPrecisionFormat(
- WGC3Denum shadertype, WGC3Denum precisiontype,
- WGC3Dint* range, WGC3Dint* precision) {
- switch (precisiontype) {
- case GL_LOW_INT:
- case GL_MEDIUM_INT:
- case GL_HIGH_INT:
- // These values are for a 32-bit twos-complement integer format.
- range[0] = 31;
- range[1] = 30;
- *precision = 0;
- break;
- case GL_LOW_FLOAT:
- case GL_MEDIUM_FLOAT:
- case GL_HIGH_FLOAT:
- // These values are for an IEEE single-precision floating-point format.
- range[0] = 127;
- range[1] = 127;
- *precision = 23;
- break;
- default:
- NOTREACHED();
- break;
- }
-
- if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
- gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn) {
- // This function is sometimes defined even though it's really just
- // a stub, so we need to set range and precision as if it weren't
- // defined before calling it.
- // On Mac OS with some GPUs, calling this generates a
- // GL_INVALID_OPERATION error. Avoid calling it on non-GLES2
- // platforms.
- glGetShaderPrecisionFormat(shadertype, precisiontype,
- range, precision);
- }
-}
-
-WebString WebGraphicsContext3DInProcessImpl::getShaderInfoLog(WebGLId shader) {
- makeContextCurrent();
-
- ShaderSourceMap::iterator result = shader_source_map_.find(shader);
- if (result != shader_source_map_.end()) {
- ShaderSourceEntry* entry = result->second;
- DCHECK(entry);
- if (!entry->is_valid) {
- if (!entry->log)
- return WebString();
- WebString res = WebString::fromUTF8(
- entry->log.get(), strlen(entry->log.get()));
- return res;
- }
- }
-
- GLint log_length = 0;
- glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
- if (log_length <= 1)
- return WebString();
- scoped_ptr<GLchar[]> log(new GLchar[log_length]);
- GLsizei returned_log_length;
- glGetShaderInfoLog(shader, log_length, &returned_log_length, log.get());
- DCHECK(log_length == returned_log_length + 1);
- WebString res = WebString::fromUTF8(log.get(), returned_log_length);
- return res;
-}
-
-WebString WebGraphicsContext3DInProcessImpl::getShaderSource(WebGLId shader) {
- makeContextCurrent();
-
- ShaderSourceMap::iterator result = shader_source_map_.find(shader);
- if (result != shader_source_map_.end()) {
- ShaderSourceEntry* entry = result->second;
- DCHECK(entry);
- if (!entry->source)
- return WebString();
- WebString res = WebString::fromUTF8(
- entry->source.get(), strlen(entry->source.get()));
- return res;
- }
-
- GLint log_length = 0;
- glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &log_length);
- if (log_length <= 1)
- return WebString();
- scoped_ptr<GLchar[]> log(new GLchar[log_length]);
- GLsizei returned_log_length;
- glGetShaderSource(shader, log_length, &returned_log_length, log.get());
- DCHECK(log_length == returned_log_length + 1);
- WebString res = WebString::fromUTF8(log.get(), returned_log_length);
- return res;
-}
-
-WebString WebGraphicsContext3DInProcessImpl::getString(WGC3Denum name) {
- makeContextCurrent();
- std::string result;
- if (name == GL_EXTENSIONS) {
- result = gl_context_->GetExtensions();
- if (!is_gles2_) {
- std::vector<std::string> split;
- base::SplitString(result, ' ', &split);
- if (std::find(split.begin(), split.end(), "GL_EXT_bgra") != split.end()) {
- // If we support GL_EXT_bgra, pretend we support a couple of GLES2
- // extension that are a subset of it.
- result += " GL_EXT_texture_format_BGRA8888 GL_EXT_read_format_bgra";
- }
- }
- std::string surface_extensions = gl_surface_->GetExtensions();
- if (!surface_extensions.empty())
- result += " " + surface_extensions;
- } else {
- result = reinterpret_cast<const char*>(glGetString(name));
- }
- return WebString::fromUTF8(result.c_str());
-}
-
-DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv,
- WGC3Denum, WGC3Denum, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*)
-
-DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation,
- WebGLId, const WGC3Dchar*, WGC3Dint)
-
-DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv,
- WGC3Duint, WGC3Denum, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv,
- WGC3Duint, WGC3Denum, WGC3Dint*)
-
-WGC3Dsizeiptr WebGraphicsContext3DInProcessImpl::getVertexAttribOffset(
- WGC3Duint index, WGC3Denum pname) {
- makeContextCurrent();
- void* pointer;
- glGetVertexAttribPointerv(index, pname, &pointer);
- return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(pointer));
-}
-
-DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebufferEXT, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isProgram, IsProgram, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isRenderbuffer, IsRenderbufferEXT, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isShader, IsShader, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isTexture, IsTexture, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1(lineWidth, LineWidth, WGC3Dfloat)
-
-DELEGATE_TO_GL_1(linkProgram, LinkProgram, WebGLId)
-
-DELEGATE_TO_GL_2(pixelStorei, PixelStorei, WGC3Denum, WGC3Dint)
-
-DELEGATE_TO_GL_2(polygonOffset, PolygonOffset, WGC3Dfloat, WGC3Dfloat)
-
-void WebGraphicsContext3DInProcessImpl::readPixels(
- WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height,
- WGC3Denum format, WGC3Denum type, void* pixels) {
- makeContextCurrent();
- // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
- // all previous rendering calls should be done before reading pixels.
- glFlush();
- bool needs_resolve =
- (attributes_.antialias && bound_fbo_ == multisample_fbo_);
- if (needs_resolve) {
- ResolveMultisampledFramebuffer(x, y, width, height);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_);
- glFlush();
- }
-
- glReadPixels(x, y, width, height, format, type, pixels);
-
- if (needs_resolve)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
-}
-
-void WebGraphicsContext3DInProcessImpl::releaseShaderCompiler() {
-}
-
-void WebGraphicsContext3DInProcessImpl::renderbufferStorage(
- WGC3Denum target,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height) {
- makeContextCurrent();
- if (!is_gles2_) {
- switch (internalformat) {
- case GL_DEPTH_STENCIL:
- internalformat = GL_DEPTH24_STENCIL8_EXT;
- break;
- case GL_DEPTH_COMPONENT16:
- internalformat = GL_DEPTH_COMPONENT;
- break;
- case GL_RGBA4:
- case GL_RGB5_A1:
- internalformat = GL_RGBA;
- break;
- case 0x8D62: // GL_RGB565
- internalformat = GL_RGB;
- break;
- }
- }
- glRenderbufferStorageEXT(target, internalformat, width, height);
-}
-
-DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dclampf, WGC3Dboolean)
-
-DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
-
-void WebGraphicsContext3DInProcessImpl::texImage2D(
- WGC3Denum target, WGC3Dint level, WGC3Denum internalFormat,
- WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border,
- WGC3Denum format, WGC3Denum type, const void* pixels) {
- makeContextCurrent();
- if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
- if (format == GL_BGRA_EXT && internalFormat == GL_BGRA_EXT) {
- internalFormat = GL_RGBA;
- } else if (type == GL_FLOAT) {
- if (format == GL_RGBA) {
- internalFormat = GL_RGBA32F_ARB;
- } else if (format == GL_RGB) {
- internalFormat = GL_RGB32F_ARB;
- }
- }
- }
- glTexImage2D(target, level, internalFormat,
- width, height, border, format, type, pixels);
-}
-
-void WebGraphicsContext3DInProcessImpl::shaderSource(
- WebGLId shader, const WGC3Dchar* source) {
- makeContextCurrent();
- GLint length = source ? strlen(source) : 0;
- ShaderSourceMap::iterator result = shader_source_map_.find(shader);
- if (result != shader_source_map_.end()) {
- ShaderSourceEntry* entry = result->second;
- DCHECK(entry);
- entry->source.reset(new char[length + 1]);
- if (source)
- memcpy(entry->source.get(), source, (length + 1) * sizeof(char));
- else
- entry->source[0] = '\0';
- } else {
- glShaderSource(shader, 1, &source, &length);
- }
-}
-
-DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint)
-
-DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate,
- WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint)
-
-DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint)
-
-DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate,
- WGC3Denum, WGC3Duint)
-
-DELEGATE_TO_GL_3(stencilOp, StencilOp,
- WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate,
- WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_3(texParameterf, TexParameterf, WGC3Denum, WGC3Denum, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(texParameteri, TexParameteri, WGC3Denum, WGC3Denum, WGC3Dint)
-
-DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
- WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform1fv, Uniform1fv,
- WGC3Dint, WGC3Dsizei, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_2(uniform1i, Uniform1i, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform1iv, Uniform1iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_3(uniform2f, Uniform2f, WGC3Dint, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform2fv, Uniform2fv,
- WGC3Dint, WGC3Dsizei, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(uniform2i, Uniform2i, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform2iv, Uniform2iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_4(uniform3f, Uniform3f,
- WGC3Dint, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform3fv, Uniform3fv,
- WGC3Dint, WGC3Dsizei, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniform3i, Uniform3i, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform3iv, Uniform3iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_5(uniform4f, Uniform4f, WGC3Dint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform4fv, Uniform4fv,
- WGC3Dint, WGC3Dsizei, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_5(uniform4i, Uniform4i, WGC3Dint,
- WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform4iv, Uniform4iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_4(uniformMatrix2fv, UniformMatrix2fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniformMatrix3fv, UniformMatrix3fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniformMatrix4fv, UniformMatrix4fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_1(useProgram, UseProgram, WebGLId)
-
-DELEGATE_TO_GL_1(validateProgram, ValidateProgram, WebGLId)
-
-DELEGATE_TO_GL_2(vertexAttrib1f, VertexAttrib1f, WGC3Duint, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib1fv, VertexAttrib1fv, WGC3Duint, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(vertexAttrib2f, VertexAttrib2f,
- WGC3Duint, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib2fv, VertexAttrib2fv, WGC3Duint, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(vertexAttrib3f, VertexAttrib3f,
- WGC3Duint, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib3fv, VertexAttrib3fv, WGC3Duint, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f,
- WGC3Duint, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint, const WGC3Dfloat*)
-
-void WebGraphicsContext3DInProcessImpl::vertexAttribPointer(
- WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized,
- WGC3Dsizei stride, WGC3Dintptr offset) {
- makeContextCurrent();
- glVertexAttribPointer(index, size, type, normalized, stride,
- reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
-}
-
-DELEGATE_TO_GL_4(viewport, Viewport, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
-
-WebGLId WebGraphicsContext3DInProcessImpl::createBuffer() {
- makeContextCurrent();
- GLuint o = 0;
- glGenBuffersARB(1, &o);
- return o;
-}
-
-WebGLId WebGraphicsContext3DInProcessImpl::createFramebuffer() {
- makeContextCurrent();
- GLuint o = 0;
- glGenFramebuffersEXT(1, &o);
- return o;
-}
-
-WebGLId WebGraphicsContext3DInProcessImpl::createProgram() {
- makeContextCurrent();
- return glCreateProgram();
-}
-
-WebGLId WebGraphicsContext3DInProcessImpl::createRenderbuffer() {
- makeContextCurrent();
- GLuint o = 0;
- glGenRenderbuffersEXT(1, &o);
- return o;
-}
-
-WebGLId WebGraphicsContext3DInProcessImpl::createShader(
- WGC3Denum shaderType) {
- makeContextCurrent();
- DCHECK(shaderType == GL_VERTEX_SHADER || shaderType == GL_FRAGMENT_SHADER);
- GLuint shader = glCreateShader(shaderType);
- if (shader) {
- ShaderSourceMap::iterator result = shader_source_map_.find(shader);
- if (result != shader_source_map_.end()) {
- delete result->second;
- shader_source_map_.erase(result);
- }
- shader_source_map_.insert(
- ShaderSourceMap::value_type(shader, new ShaderSourceEntry(shaderType)));
- }
-
- return shader;
-}
-
-WebGLId WebGraphicsContext3DInProcessImpl::createTexture() {
- makeContextCurrent();
- GLuint o = 0;
- glGenTextures(1, &o);
- return o;
-}
-
-void WebGraphicsContext3DInProcessImpl::deleteBuffer(WebGLId buffer) {
- makeContextCurrent();
- glDeleteBuffersARB(1, &buffer);
-}
-
-void WebGraphicsContext3DInProcessImpl::deleteFramebuffer(
- WebGLId framebuffer) {
- makeContextCurrent();
- glDeleteFramebuffersEXT(1, &framebuffer);
-}
-
-void WebGraphicsContext3DInProcessImpl::deleteProgram(WebGLId program) {
- makeContextCurrent();
- glDeleteProgram(program);
-}
-
-void WebGraphicsContext3DInProcessImpl::deleteRenderbuffer(
- WebGLId renderbuffer) {
- makeContextCurrent();
- glDeleteRenderbuffersEXT(1, &renderbuffer);
-}
-
-void WebGraphicsContext3DInProcessImpl::deleteShader(WebGLId shader) {
- makeContextCurrent();
-
- ShaderSourceMap::iterator result = shader_source_map_.find(shader);
- if (result != shader_source_map_.end()) {
- delete result->second;
- shader_source_map_.erase(result);
- }
- glDeleteShader(shader);
-}
-
-void WebGraphicsContext3DInProcessImpl::deleteTexture(WebGLId texture) {
- makeContextCurrent();
- glDeleteTextures(1, &texture);
-}
-
-WGC3Denum WebGraphicsContext3DInProcessImpl::getGraphicsResetStatusARB() {
- // TODO(kbr): this implementation doesn't support lost contexts yet.
- return GL_NO_ERROR;
-}
-
-void WebGraphicsContext3DInProcessImpl::texImageIOSurface2DCHROMIUM(
- WGC3Denum target, WGC3Dint width, WGC3Dint height,
- WGC3Duint ioSurfaceId, WGC3Duint plane) {
-}
-
-DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT,
- WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint)
-
-WebGLId WebGraphicsContext3DInProcessImpl::createQueryEXT() {
- makeContextCurrent();
- GLuint o = 0;
- glGenQueriesARB(1, &o);
- return o;
-}
-
-void WebGraphicsContext3DInProcessImpl::deleteQueryEXT(WebGLId query) {
- makeContextCurrent();
- glDeleteQueriesARB(1, &query);
-}
-
-DELEGATE_TO_GL_1R(isQueryEXT, IsQueryARB, WebGLId, WGC3Dboolean)
-DELEGATE_TO_GL_2(beginQueryEXT, BeginQueryARB, WGC3Denum, WebGLId)
-DELEGATE_TO_GL_1(endQueryEXT, EndQueryARB, WGC3Denum)
-DELEGATE_TO_GL_3(getQueryivEXT, GetQueryivARB, WGC3Denum, WGC3Denum, WGC3Dint*)
-DELEGATE_TO_GL_3(getQueryObjectuivEXT, GetQueryObjectuivARB,
- WebGLId, WGC3Denum, WGC3Duint*)
-
-void WebGraphicsContext3DInProcessImpl::copyTextureCHROMIUM(
- WGC3Denum, WGC3Duint, WGC3Duint, WGC3Dint, WGC3Denum, WGC3Denum) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessImpl::bindTexImage2DCHROMIUM(
- WGC3Denum target, WGC3Dint imageId) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessImpl::releaseTexImage2DCHROMIUM(
- WGC3Denum target, WGC3Dint imageId) {
- NOTIMPLEMENTED();
-}
-
-void* WebGraphicsContext3DInProcessImpl::mapBufferCHROMIUM(
- WGC3Denum target, WGC3Denum access) {
- return 0;
-}
-
-WGC3Dboolean WebGraphicsContext3DInProcessImpl::unmapBufferCHROMIUM(
- WGC3Denum target) {
- return false;
-}
-
-void WebGraphicsContext3DInProcessImpl::drawBuffersEXT(
- WGC3Dsizei n, const WGC3Denum* bufs) {
- NOTIMPLEMENTED();
-}
-
-GrGLInterface* WebGraphicsContext3DInProcessImpl::onCreateGrGLInterface() {
- return gfx::CreateInProcessSkiaGLBinding();
-}
-
-bool WebGraphicsContext3DInProcessImpl::AngleCreateCompilers() {
- if (!ShInitialize())
- return false;
-
- ShBuiltInResources resources;
- ShInitBuiltInResources(&resources);
- getIntegerv(GL_MAX_VERTEX_ATTRIBS, &resources.MaxVertexAttribs);
- getIntegerv(MAX_VERTEX_UNIFORM_VECTORS, &resources.MaxVertexUniformVectors);
- getIntegerv(MAX_VARYING_VECTORS, &resources.MaxVaryingVectors);
- getIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,
- &resources.MaxVertexTextureImageUnits);
- getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
- &resources.MaxCombinedTextureImageUnits);
- getIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &resources.MaxTextureImageUnits);
- getIntegerv(MAX_FRAGMENT_UNIFORM_VECTORS,
- &resources.MaxFragmentUniformVectors);
- // Always set to 1 for OpenGL ES.
- resources.MaxDrawBuffers = 1;
-
- resources.OES_standard_derivatives = have_ext_oes_standard_derivatives_;
- resources.OES_EGL_image_external = have_ext_oes_egl_image_external_;
-
- fragment_compiler_ = ShConstructCompiler(
- SH_FRAGMENT_SHADER, SH_WEBGL_SPEC,
- is_gles2_ ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT, &resources);
- vertex_compiler_ = ShConstructCompiler(
- SH_VERTEX_SHADER, SH_WEBGL_SPEC,
- is_gles2_ ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT, &resources);
- return (fragment_compiler_ && vertex_compiler_);
-}
-
-void WebGraphicsContext3DInProcessImpl::AngleDestroyCompilers() {
- if (fragment_compiler_) {
- ShDestruct(fragment_compiler_);
- fragment_compiler_ = 0;
- }
- if (vertex_compiler_) {
- ShDestruct(vertex_compiler_);
- vertex_compiler_ = 0;
- }
-}
-
-bool WebGraphicsContext3DInProcessImpl::AngleValidateShaderSource(
- ShaderSourceEntry* entry) {
- entry->is_valid = false;
- entry->translated_source.reset();
- entry->log.reset();
-
- ShHandle compiler = 0;
- switch (entry->type) {
- case GL_FRAGMENT_SHADER:
- compiler = fragment_compiler_;
- break;
- case GL_VERTEX_SHADER:
- compiler = vertex_compiler_;
- break;
- }
- if (!compiler)
- return false;
-
- char* source = entry->source.get();
- if (!ShCompile(compiler, &source, 1, SH_OBJECT_CODE)) {
-#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
- int logSize = 0;
-#else
- size_t logSize = 0;
-#endif
- ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &logSize);
- if (logSize > 1) {
- entry->log.reset(new char[logSize]);
- ShGetInfoLog(compiler, entry->log.get());
- }
- return false;
- }
-
-#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
- int length = 0;
-#else
- size_t length = 0;
-#endif
- ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &length);
- if (length > 1) {
- entry->translated_source.reset(new char[length]);
- ShGetObjectCode(compiler, entry->translated_source.get());
- }
- entry->is_valid = true;
- return true;
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_impl.h
deleted file mode 100644
index 8187302..0000000
--- a/webkit/gpu/webgraphicscontext3d_in_process_impl.h
+++ /dev/null
@@ -1,577 +0,0 @@
-// Copyright (c) 2012 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_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_
-#define WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_
-
-#include <list>
-#include <set>
-
-#include "base/compiler_specific.h"
-#include "base/hash_tables.h"
-#include "base/memory/ref_counted.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
-#include "third_party/angle/include/GLSLANG/ShaderLang.h"
-#include "ui/gfx/native_widget_types.h"
-#include "webkit/gpu/webkit_gpu_export.h"
-
-namespace gfx {
-class GLContext;
-class GLSurface;
-class GLShareGroup;
-}
-
-using WebKit::WGC3Dbyte;
-using WebKit::WGC3Dchar;
-using WebKit::WGC3Denum;
-using WebKit::WGC3Dboolean;
-using WebKit::WGC3Dbitfield;
-using WebKit::WGC3Dint;
-using WebKit::WGC3Dsizei;
-using WebKit::WGC3Duint;
-using WebKit::WGC3Dfloat;
-using WebKit::WGC3Dclampf;
-using WebKit::WGC3Dintptr;
-using WebKit::WGC3Dsizeiptr;
-
-using WebKit::WebGLId;
-
-using WebKit::WebString;
-
-using WebKit::WebGraphicsContext3D;
-
-namespace webkit {
-namespace gpu {
-
-// The default implementation of WebGL. In Chromium, using this class
-// requires the sandbox to be disabled, which is strongly discouraged.
-// It is provided for support of test_shell and any Chromium ports
-// where an in-renderer WebGL implementation would be helpful.
-
-class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessImpl :
- public NON_EXPORTED_BASE(WebGraphicsContext3D) {
- public:
- // Creates a WebGraphicsContext3DInProcessImpl for a given window. If window
- // is gfx::kNullPluginWindow, then it creates an offscreen context.
- // share_group is the group this context shares namespaces with. It's only
- // used for window-bound countexts.
- WebGraphicsContext3DInProcessImpl(gfx::GLSurface* surface,
- gfx::GLContext* context,
- bool render_directly_to_webview);
- virtual ~WebGraphicsContext3DInProcessImpl();
- static WebGraphicsContext3DInProcessImpl* CreateForWindow(
- WebGraphicsContext3D::Attributes attributes,
- gfx::AcceleratedWidget window,
- gfx::GLShareGroup* share_group);
-
- //----------------------------------------------------------------------
- // WebGraphicsContext3D methods
- virtual bool makeContextCurrent();
-
- virtual int width();
- virtual int height();
-
- virtual bool isGLES2Compliant();
-
- virtual bool setParentContext(WebGraphicsContext3D* parent_context);
-
- virtual void reshape(int width, int height);
- virtual void reshapeWithScaleFactor(
- int width, int height, float scaleFactor);
-
- virtual bool readBackFramebuffer(unsigned char* pixels, size_t bufferSize);
- virtual bool readBackFramebuffer(unsigned char* pixels, size_t buffer_size,
- WebGLId framebuffer, int width, int height);
-
- virtual WebGLId getPlatformTextureId();
- virtual void prepareTexture();
- virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
-
- virtual void synthesizeGLError(WGC3Denum error);
- virtual void* mapBufferSubDataCHROMIUM(WGC3Denum target, WGC3Dintptr offset,
- WGC3Dsizeiptr size, WGC3Denum access);
- virtual void unmapBufferSubDataCHROMIUM(const void*);
- virtual void* mapTexSubImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- WGC3Denum access);
- virtual void unmapTexSubImage2DCHROMIUM(const void*);
-
- virtual void setVisibilityCHROMIUM(bool visible);
-
- virtual void setMemoryAllocationChangedCallbackCHROMIUM(
- WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback);
-
- virtual void discardFramebufferEXT(WGC3Denum target,
- WGC3Dsizei numAttachments,
- const WGC3Denum* attachments);
- virtual void discardBackbufferCHROMIUM();
- virtual void ensureBackbufferCHROMIUM();
-
- virtual void copyTextureToParentTextureCHROMIUM(
- WebGLId texture, WebGLId parentTexture);
-
- virtual void rateLimitOffscreenContextCHROMIUM() { }
-
- virtual WebString getRequestableExtensionsCHROMIUM();
- virtual void requestExtensionCHROMIUM(const char*);
-
- virtual void blitFramebufferCHROMIUM(
- WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
- WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
- WGC3Dbitfield mask, WGC3Denum filter);
- virtual void renderbufferStorageMultisampleCHROMIUM(
- WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
- WGC3Dsizei width, WGC3Dsizei height);
-
- virtual void activeTexture(WGC3Denum texture);
- virtual void attachShader(WebGLId program, WebGLId shader);
- virtual void bindAttribLocation(
- WebGLId program, WGC3Duint index, const WGC3Dchar* name);
- virtual void bindBuffer(WGC3Denum target, WebGLId buffer);
- virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer);
- virtual void bindRenderbuffer(
- WGC3Denum target, WebGLId renderbuffer);
- virtual void bindTexture(WGC3Denum target, WebGLId texture);
- virtual void blendColor(
- WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha);
- virtual void blendEquation(WGC3Denum mode);
- virtual void blendEquationSeparate(WGC3Denum modeRGB, WGC3Denum modeAlpha);
- virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor);
- virtual void blendFuncSeparate(WGC3Denum srcRGB, WGC3Denum dstRGB,
- WGC3Denum srcAlpha, WGC3Denum dstAlpha);
-
- virtual void bufferData(
- WGC3Denum target, WGC3Dsizeiptr size, const void* data, WGC3Denum usage);
- virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset,
- WGC3Dsizeiptr size, const void* data);
-
- virtual WGC3Denum checkFramebufferStatus(WGC3Denum target);
- virtual void clear(WGC3Dbitfield mask);
- virtual void clearColor(
- WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha);
- virtual void clearDepth(WGC3Dclampf depth);
- virtual void clearStencil(WGC3Dint s);
- virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green,
- WGC3Dboolean blue, WGC3Dboolean alpha);
- virtual void compileShader(WebGLId shader);
-
- virtual void compressedTexImage2D(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border,
- WGC3Dsizei imageSize,
- const void* data);
- virtual void compressedTexSubImage2D(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Dsizei imageSize,
- const void* data);
- virtual void copyTexImage2D(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dint x,
- WGC3Dint y,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border);
- virtual void copyTexSubImage2D(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dint x,
- WGC3Dint y,
- WGC3Dsizei width,
- WGC3Dsizei height);
- virtual void cullFace(WGC3Denum mode);
- virtual void depthFunc(WGC3Denum func);
- virtual void depthMask(WGC3Dboolean flag);
- virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar);
- virtual void detachShader(WebGLId program, WebGLId shader);
- virtual void disable(WGC3Denum cap);
- virtual void disableVertexAttribArray(WGC3Duint index);
- virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count);
- virtual void drawElements(
- WGC3Denum mode,
- WGC3Dsizei count,
- WGC3Denum type,
- WGC3Dintptr offset);
-
- virtual void enable(WGC3Denum cap);
- virtual void enableVertexAttribArray(WGC3Duint index);
- virtual void finish();
- virtual void flush();
- virtual void framebufferRenderbuffer(
- WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum renderbuffertarget,
- WebGLId renderbuffer);
- virtual void framebufferTexture2D(
- WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum textarget,
- WebGLId texture,
- WGC3Dint level);
- virtual void frontFace(WGC3Denum mode);
- virtual void generateMipmap(WGC3Denum target);
-
- virtual bool getActiveAttrib(WebGLId program, WGC3Duint index, ActiveInfo&);
- virtual bool getActiveUniform(WebGLId program, WGC3Duint index, ActiveInfo&);
-
- virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount,
- WGC3Dsizei* count, WebGLId* shaders);
-
- virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name);
-
- virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value);
-
- virtual void getBufferParameteriv(
- WGC3Denum target, WGC3Denum pname, WGC3Dint* value);
-
- virtual Attributes getContextAttributes();
-
- virtual WGC3Denum getError();
-
- virtual bool isContextLost();
-
- virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value);
-
- virtual void getFramebufferAttachmentParameteriv(
- WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value);
-
- virtual void getProgramiv(
- WebGLId program, WGC3Denum pname, WGC3Dint* value);
-
- virtual WebString getProgramInfoLog(WebGLId program);
-
- virtual void getRenderbufferParameteriv(
- WGC3Denum target, WGC3Denum pname, WGC3Dint* value);
-
- virtual void getShaderiv(
- WebGLId shader, WGC3Denum pname, WGC3Dint* value);
-
- virtual WebString getShaderInfoLog(WebGLId shader);
-
- virtual void getShaderPrecisionFormat(
- WGC3Denum shadertype, WGC3Denum precisiontype,
- WGC3Dint* range, WGC3Dint* precision);
-
- virtual WebString getShaderSource(WebGLId shader);
- virtual WebString getString(WGC3Denum name);
-
- virtual void getTexParameterfv(
- WGC3Denum target, WGC3Denum pname, WGC3Dfloat* value);
- virtual void getTexParameteriv(
- WGC3Denum target, WGC3Denum pname, WGC3Dint* value);
-
- virtual void getUniformfv(
- WebGLId program, WGC3Dint location, WGC3Dfloat* value);
- virtual void getUniformiv(
- WebGLId program, WGC3Dint location, WGC3Dint* value);
-
- virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name);
-
- virtual void getVertexAttribfv(
- WGC3Duint index, WGC3Denum pname, WGC3Dfloat* value);
- virtual void getVertexAttribiv(
- WGC3Duint index, WGC3Denum pname, WGC3Dint* value);
-
- virtual WGC3Dsizeiptr getVertexAttribOffset(
- WGC3Duint index, WGC3Denum pname);
-
- virtual void hint(WGC3Denum target, WGC3Denum mode);
- virtual WGC3Dboolean isBuffer(WebGLId buffer);
- virtual WGC3Dboolean isEnabled(WGC3Denum cap);
- virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer);
- virtual WGC3Dboolean isProgram(WebGLId program);
- virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer);
- virtual WGC3Dboolean isShader(WebGLId shader);
- virtual WGC3Dboolean isTexture(WebGLId texture);
- virtual void lineWidth(WGC3Dfloat width);
- virtual void linkProgram(WebGLId program);
- virtual void pixelStorei(WGC3Denum pname, WGC3Dint param);
- virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units);
-
- virtual void readPixels(
- WGC3Dint x, WGC3Dint y,
- WGC3Dsizei width, WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- void* pixels);
-
- virtual void releaseShaderCompiler();
- virtual void renderbufferStorage(
- WGC3Denum target,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height);
- virtual void sampleCoverage(WGC3Dclampf value, WGC3Dboolean invert);
- virtual void scissor(
- WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height);
- virtual void shaderSource(WebGLId shader, const WGC3Dchar* source);
- virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask);
- virtual void stencilFuncSeparate(
- WGC3Denum face, WGC3Denum func, WGC3Dint ref, WGC3Duint mask);
- virtual void stencilMask(WGC3Duint mask);
- virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask);
- virtual void stencilOp(WGC3Denum fail, WGC3Denum zfail, WGC3Denum zpass);
- virtual void stencilOpSeparate(
- WGC3Denum face,
- WGC3Denum fail,
- WGC3Denum zfail,
- WGC3Denum zpass);
-
- virtual void texImage2D(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
-
- virtual void texParameterf(
- WGC3Denum target, WGC3Denum pname, WGC3Dfloat param);
- virtual void texParameteri(
- WGC3Denum target, WGC3Denum pname, WGC3Dint param);
-
- virtual void texSubImage2D(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
-
- virtual void uniform1f(WGC3Dint location, WGC3Dfloat x);
- virtual void uniform1fv(WGC3Dint location, WGC3Dsizei count,
- const WGC3Dfloat* v);
- virtual void uniform1i(WGC3Dint location, WGC3Dint x);
- virtual void uniform1iv(WGC3Dint location, WGC3Dsizei count,
- const WGC3Dint* v);
- virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y);
- virtual void uniform2fv(WGC3Dint location, WGC3Dsizei count,
- const WGC3Dfloat* v);
- virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y);
- virtual void uniform2iv(WGC3Dint location, WGC3Dsizei count,
- const WGC3Dint* v);
- virtual void uniform3f(WGC3Dint location,
- WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
- virtual void uniform3fv(WGC3Dint location, WGC3Dsizei count,
- const WGC3Dfloat* v);
- virtual void uniform3i(WGC3Dint location, WGC3Dint x, WGC3Dint y, WGC3Dint z);
- virtual void uniform3iv(WGC3Dint location, WGC3Dsizei count,
- const WGC3Dint* v);
- virtual void uniform4f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y,
- WGC3Dfloat z, WGC3Dfloat w);
- virtual void uniform4fv(WGC3Dint location, WGC3Dsizei count,
- const WGC3Dfloat* v);
- virtual void uniform4i(WGC3Dint location, WGC3Dint x, WGC3Dint y,
- WGC3Dint z, WGC3Dint w);
- virtual void uniform4iv(WGC3Dint location, WGC3Dsizei count,
- const WGC3Dint* v);
- virtual void uniformMatrix2fv(
- WGC3Dint location, WGC3Dsizei count,
- WGC3Dboolean transpose, const WGC3Dfloat* value);
- virtual void uniformMatrix3fv(
- WGC3Dint location, WGC3Dsizei count,
- WGC3Dboolean transpose, const WGC3Dfloat* value);
- virtual void uniformMatrix4fv(
- WGC3Dint location, WGC3Dsizei count,
- WGC3Dboolean transpose, const WGC3Dfloat* value);
-
- virtual void useProgram(WebGLId program);
- virtual void validateProgram(WebGLId program);
-
- virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x);
- virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y);
- virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib3f(
- WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
- virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib4f(
- WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z, WGC3Dfloat w);
- virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttribPointer(
- WGC3Duint index,
- WGC3Dint size,
- WGC3Denum type,
- WGC3Dboolean normalized,
- WGC3Dsizei stride,
- WGC3Dintptr offset);
-
- virtual void viewport(
- WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height);
-
- // Support for buffer creation and deletion
- virtual WebGLId createBuffer();
- virtual WebGLId createFramebuffer();
- virtual WebGLId createProgram();
- virtual WebGLId createRenderbuffer();
- virtual WebGLId createShader(WGC3Denum);
- virtual WebGLId createTexture();
-
- virtual void deleteBuffer(WebGLId);
- virtual void deleteFramebuffer(WebGLId);
- virtual void deleteProgram(WebGLId);
- virtual void deleteRenderbuffer(WebGLId);
- virtual void deleteShader(WebGLId);
- virtual void deleteTexture(WebGLId);
-
- virtual void setContextLostCallback(
- WebGraphicsContext3D::WebGraphicsContextLostCallback* callback) {}
- virtual WGC3Denum getGraphicsResetStatusARB();
-
- virtual void setSwapBuffersCompleteCallbackCHROMIUM(
- WebGraphicsContext3D::
- WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) {}
-
- virtual void texImageIOSurface2DCHROMIUM(
- WGC3Denum target, WGC3Dint width, WGC3Dint height,
- WGC3Duint ioSurfaceId, WGC3Duint plane);
-
- virtual void texStorage2DEXT(
- WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
- WGC3Dint width, WGC3Dint height);
-
- virtual WebGLId createQueryEXT();
- virtual void deleteQueryEXT(WebGLId query);
- virtual WGC3Dboolean isQueryEXT(WebGLId query);
- virtual void beginQueryEXT(WGC3Denum target, WebGLId query);
- virtual void endQueryEXT(WGC3Denum target);
- virtual void getQueryivEXT(
- WGC3Denum target, WGC3Denum pname, WGC3Dint* params);
- virtual void getQueryObjectuivEXT(
- WebGLId query, WGC3Denum pname, WGC3Duint* params);
-
- virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint source_id,
- WGC3Duint dest_id, WGC3Dint level,
- WGC3Denum internal_format,
- WGC3Denum dest_type);
-
- virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location,
- const WGC3Dchar* uniform);
-
- // CHROMIUM_shallow_flush
- // Only applies to contexts that use the command buffer.
- virtual void shallowFlushCHROMIUM() { }
-
- virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox);
- virtual void produceTextureCHROMIUM(WGC3Denum target,
- const WGC3Dbyte* mailbox);
- virtual void consumeTextureCHROMIUM(WGC3Denum target,
- const WGC3Dbyte* mailbox);
-
- virtual void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId);
- virtual void releaseTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId);
-
- virtual void* mapBufferCHROMIUM(WGC3Denum target, WGC3Denum access);
- virtual WGC3Dboolean unmapBufferCHROMIUM(WGC3Denum target);
-
- virtual void drawBuffersEXT(WGC3Dsizei n, const WGC3Denum* bufs);
-
- protected:
- virtual GrGLInterface* onCreateGrGLInterface();
-
- private:
- bool Initialize(Attributes attributes);
-
- // ANGLE related.
- struct ShaderSourceEntry;
-
- typedef base::hash_map<WebGLId, ShaderSourceEntry*> ShaderSourceMap;
-
- bool AllocateOffscreenFrameBuffer(int width, int height);
- void ClearRenderTarget();
-
- void FlipVertically(unsigned char* framebuffer,
- unsigned int width,
- unsigned int height);
-
- // Take into account the user's requested context creation attributes, in
- // particular stencil and antialias, and determine which could or could
- // not be honored based on the capabilities of the OpenGL implementation.
- void ValidateAttributes();
-
- // Resolve the given rectangle of the multisampled framebuffer if necessary.
- void ResolveMultisampledFramebuffer(
- WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height);
-
- bool AngleCreateCompilers();
- void AngleDestroyCompilers();
- bool AngleValidateShaderSource(ShaderSourceEntry* entry);
-
- WebGraphicsContext3D::Attributes attributes_;
- bool initialized_;
- bool render_directly_to_web_view_;
- bool is_gles2_;
- bool have_ext_framebuffer_object_;
- bool have_ext_framebuffer_multisample_;
- bool have_angle_framebuffer_multisample_;
- bool have_ext_oes_standard_derivatives_;
- bool have_ext_oes_egl_image_external_;
-
- WebGLId texture_;
- WebGLId fbo_;
- WebGLId depth_stencil_buffer_;
- int cached_width_, cached_height_;
-
- // For multisampling
- WebGLId multisample_fbo_;
- WebGLId multisample_depth_stencil_buffer_;
- WebGLId multisample_color_buffer_;
-
- // For tracking which FBO is bound
- WebGLId bound_fbo_;
-
- // For tracking which texture is bound
- WebGLId bound_texture_;
-
- unsigned char* scanline_;
-
- // Errors raised by synthesizeGLError().
- std::list<WGC3Denum> synthetic_errors_list_;
- std::set<WGC3Denum> synthetic_errors_set_;
-
- scoped_refptr<gfx::GLContext> gl_context_;
- scoped_refptr<gfx::GLSurface> gl_surface_;
-
- ShaderSourceMap shader_source_map_;
-
- ShHandle fragment_compiler_;
- ShHandle vertex_compiler_;
-};
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_IN_PROCESS_IMPL_H_
diff --git a/webkit/gpu/webgraphicscontext3d_provider_impl.cc b/webkit/gpu/webgraphicscontext3d_provider_impl.cc
deleted file mode 100644
index 00f4391..0000000
--- a/webkit/gpu/webgraphicscontext3d_provider_impl.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2013 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/gpu/webgraphicscontext3d_provider_impl.h"
-
-#include "cc/output/context_provider.h"
-
-namespace webkit {
-namespace gpu {
-
-WebGraphicsContext3DProviderImpl::WebGraphicsContext3DProviderImpl(
- scoped_refptr<cc::ContextProvider> provider)
- : provider_(provider) {}
-
-WebGraphicsContext3DProviderImpl::~WebGraphicsContext3DProviderImpl() {}
-
-WebKit::WebGraphicsContext3D* WebGraphicsContext3DProviderImpl::context3d() {
- return provider_->Context3d();
-}
-
-GrContext* WebGraphicsContext3DProviderImpl::grContext() {
- return provider_->GrContext();
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/webkit/gpu/webgraphicscontext3d_provider_impl.h b/webkit/gpu/webgraphicscontext3d_provider_impl.h
deleted file mode 100644
index 921dd52..0000000
--- a/webkit/gpu/webgraphicscontext3d_provider_impl.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2013 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_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_
-#define WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_
-
-#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3DProvider.h"
-#include "webkit/gpu/webkit_gpu_export.h"
-
-namespace cc { class ContextProvider; }
-
-namespace webkit {
-namespace gpu {
-
-class WEBKIT_GPU_EXPORT WebGraphicsContext3DProviderImpl
- : public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3DProvider) {
- public:
- explicit WebGraphicsContext3DProviderImpl(
- scoped_refptr<cc::ContextProvider> provider);
- virtual ~WebGraphicsContext3DProviderImpl();
-
- // WebGraphicsContext3DProvider implementation.
- virtual WebKit::WebGraphicsContext3D* context3d() OVERRIDE;
- virtual GrContext* grContext() OVERRIDE;
-
- private:
- scoped_refptr<cc::ContextProvider> provider_;
-};
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // WEBKIT_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_
diff --git a/webkit/gpu/webkit_gpu.gyp b/webkit/gpu/webkit_gpu.gyp
deleted file mode 100644
index f7c8b93..0000000
--- a/webkit/gpu/webkit_gpu.gyp
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (c) 2013 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.
-
-{
- 'conditions': [
- # TODO(stuartmorgan): All dependencies from code built on iOS to
- # webkit/ should be removed, at which point this condition can be
- # removed.
- ['OS != "ios"', {
- 'targets': [
- {
- 'target_name': 'webkit_gpu',
- 'type': '<(component)',
- 'variables': { 'enable_wexit_time_destructors': 1, },
- 'dependencies': [
- '<(DEPTH)/base/base.gyp:base',
- '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '<(DEPTH)/gpu/command_buffer/command_buffer.gyp:gles2_utils',
- '<(DEPTH)/gpu/gpu.gyp:command_buffer_client',
- '<(DEPTH)/gpu/gpu.gyp:command_buffer_service',
- '<(DEPTH)/gpu/gpu.gyp:gles2_c_lib',
- '<(DEPTH)/gpu/gpu.gyp:gles2_implementation',
- '<(DEPTH)/skia/skia.gyp:skia',
- '<(DEPTH)/third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit',
- '<(DEPTH)/third_party/angle/src/build_angle.gyp:translator_glsl',
- '<(DEPTH)/ui/gl/gl.gyp:gl',
- '<(DEPTH)/ui/ui.gyp:ui',
- ],
- 'sources': [
- # This list contains all .h and .cc in gpu except for test code.
- 'context_provider_in_process.cc',
- 'context_provider_in_process.h',
- 'gl_bindings_skia_cmd_buffer.cc',
- 'gl_bindings_skia_cmd_buffer.h',
- 'grcontext_for_webgraphicscontext3d.cc',
- 'grcontext_for_webgraphicscontext3d.h',
- 'test_context_provider_factory.cc',
- 'test_context_provider_factory.h',
- 'webgraphicscontext3d_in_process_command_buffer_impl.cc',
- 'webgraphicscontext3d_in_process_command_buffer_impl.h',
- 'webgraphicscontext3d_in_process_impl.cc',
- 'webgraphicscontext3d_in_process_impl.h',
- 'webgraphicscontext3d_provider_impl.cc',
- 'webgraphicscontext3d_provider_impl.h',
- ],
- 'defines': [
- 'WEBKIT_GPU_IMPLEMENTATION',
- ],
- # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
- 'msvs_disabled_warnings': [ 4267, ],
- },
- ],
- }],
- ],
-}
diff --git a/webkit/gpu/webkit_gpu_export.h b/webkit/gpu/webkit_gpu_export.h
deleted file mode 100644
index 486f78e..0000000
--- a/webkit/gpu/webkit_gpu_export.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2012 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_GPU_WEBKIT_GPU_EXPORT_H_
-#define WEBKIT_GPU_WEBKIT_GPU_EXPORT_H_
-
-#if defined(COMPONENT_BUILD)
-#if defined(WIN32)
-
-#if defined(WEBKIT_GPU_IMPLEMENTATION)
-#define WEBKIT_GPU_EXPORT __declspec(dllexport)
-#else
-#define WEBKIT_GPU_EXPORT __declspec(dllimport)
-#endif // defined(WEBKIT_GPU_IMPLEMENTATION)
-
-#else // defined(WIN32)
-#if defined(WEBKIT_GPU_IMPLEMENTATION)
-#define WEBKIT_GPU_EXPORT __attribute__((visibility("default")))
-#else
-#define WEBKIT_GPU_EXPORT
-#endif
-#endif
-
-#else // defined(COMPONENT_BUILD)
-#define WEBKIT_GPU_EXPORT
-#endif
-
-#endif // WEBKIT_GPU_WEBKIT_GPU_EXPORT_H_