| Index: content/renderer/gpu/webgraphicscontext3d_guest.h
|
| diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/renderer/gpu/webgraphicscontext3d_guest.h
|
| similarity index 88%
|
| copy from content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
|
| copy to content/renderer/gpu/webgraphicscontext3d_guest.h
|
| index 31a5c81ffcb8409aff3777df119e129fde743276..e0291a152f97f45b85398ca235891f54a5f217bb 100644
|
| --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
|
| +++ b/content/renderer/gpu/webgraphicscontext3d_guest.h
|
| @@ -2,17 +2,20 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
|
| -#define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
|
| +#ifndef CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_GUEST_H_
|
| +#define CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_GUEST_H_
|
| #pragma once
|
|
|
| +#if defined(ENABLE_GPU)
|
| +
|
| #include <string>
|
| #include <vector>
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| -#include "content/common/gpu/client/content_gl_context.h"
|
| #include "googleurl/src/gurl.h"
|
| +#include "gpu/command_buffer/client/gles2_cmd_helper.h"
|
| +#include "gpu/command_buffer/client/gles2_implementation.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
| @@ -24,8 +27,10 @@
|
| #endif
|
|
|
| class GpuChannelHost;
|
| +class GuestToHostChannel;
|
|
|
| namespace gpu {
|
| +class TransferBuffer;
|
| namespace gles2 {
|
| class GLES2Implementation;
|
| }
|
| @@ -45,31 +50,19 @@ using WebKit::WGC3Dclampf;
|
| using WebKit::WGC3Dintptr;
|
| using WebKit::WGC3Dsizeiptr;
|
|
|
| -// TODO(piman): move this logic to the compositor and remove it from the
|
| -// context...
|
| -class WebGraphicsContext3DSwapBuffersClient {
|
| - public:
|
| - virtual ~WebGraphicsContext3DSwapBuffersClient() { }
|
| - virtual void OnViewContextSwapBuffersPosted() = 0;
|
| - virtual void OnViewContextSwapBuffersComplete() = 0;
|
| - virtual void OnViewContextSwapBuffersAborted() = 0;
|
| -};
|
| -
|
| -class WebGraphicsContext3DCommandBufferImpl
|
| +class WebGraphicsContext3DGuest
|
| : public WebKit::WebGraphicsContext3D {
|
| public:
|
| - WebGraphicsContext3DCommandBufferImpl(
|
| - int surface_id,
|
| - const GURL& active_url,
|
| - const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client);
|
| - virtual ~WebGraphicsContext3DCommandBufferImpl();
|
| -
|
| - bool Initialize(const Attributes& attributes);
|
| + static const int32 kCommandBufferSize = 1024 * 1024;
|
| + static const int32 kTransferBufferSize = 1024 * 1024;
|
| + WebGraphicsContext3DGuest(gpu::CommandBuffer* command_buffer,
|
| + GuestToHostChannel* channel,
|
| + WebKit::WebView* webview);
|
| + virtual ~WebGraphicsContext3DGuest();
|
|
|
| //----------------------------------------------------------------------
|
| // WebGraphicsContext3D methods
|
|
|
| - // Must be called after initialize() and before any of the following methods.
|
| // Permanently binds to the first calling thread. Returns false if the
|
| // graphics context fails to create. Do not call from more than one thread.
|
| virtual bool makeContextCurrent();
|
| @@ -77,6 +70,8 @@ class WebGraphicsContext3DCommandBufferImpl
|
| virtual int width();
|
| virtual int height();
|
|
|
| + virtual void playDead();
|
| +
|
| virtual bool isGLES2Compliant();
|
|
|
| virtual bool setParentContext(WebGraphicsContext3D* parent_context);
|
| @@ -439,9 +434,6 @@ class WebGraphicsContext3DCommandBufferImpl
|
|
|
| virtual void setVisibilityCHROMIUM(bool visible);
|
|
|
| - virtual void setMemoryAllocationChangedCallbackCHROMIUM(
|
| - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback);
|
| -
|
| virtual void copyTextureToParentTextureCHROMIUM(
|
| WebGLId texture, WebGLId parentTexture);
|
|
|
| @@ -460,15 +452,10 @@ class WebGraphicsContext3DCommandBufferImpl
|
|
|
| virtual WebKit::WebString getTranslatedShaderSourceANGLE(WebGLId shader);
|
|
|
| - ContentGLContext* context() { return context_; }
|
| -
|
| virtual void setContextLostCallback(
|
| WebGraphicsContext3D::WebGraphicsContextLostCallback* callback);
|
| virtual WGC3Denum getGraphicsResetStatusARB();
|
|
|
| - virtual void setErrorMessageCallback(
|
| - WebGraphicsContext3D::WebGraphicsErrorMessageCallback* callback);
|
| -
|
| virtual void setSwapBuffersCompleteCallbackCHROMIUM(
|
| WebGraphicsContext3D::
|
| WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback);
|
| @@ -481,14 +468,8 @@ class WebGraphicsContext3DCommandBufferImpl
|
| WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
|
| WGC3Dint width, WGC3Dint height);
|
|
|
| - ContentGLContext* content_gl_context() const { return context_; }
|
| -
|
| - protected:
|
| -#if WEBKIT_USING_SKIA
|
| - virtual GrGLInterface* onCreateGrGLInterface();
|
| -#endif
|
| -
|
| private:
|
| + friend class GuestToHostChannel;
|
| // Initialize the underlying GL context. May be called multiple times; second
|
| // and subsequent calls are ignored. Must be called from the thread that is
|
| // going to use this object to issue GL commands (which might not be the main
|
| @@ -497,44 +478,30 @@ class WebGraphicsContext3DCommandBufferImpl
|
|
|
| // SwapBuffers callback.
|
| void OnSwapBuffersComplete();
|
| - virtual void OnContextLost(ContentGLContext::ContextLostReason reason);
|
| - virtual void OnErrorMessage(const std::string& message, int id);
|
| -
|
| - // Check if we should call into the swap client. We can only do that on the
|
| - // main thread.
|
| - bool ShouldUseSwapClient();
|
|
|
| - // MemoryAllocationChanged callback.
|
| - void OnMemoryAllocationChanged(const GpuMemoryAllocation& allocation);
|
| + GuestToHostChannel* channel_;
|
|
|
| bool initialize_failed_;
|
|
|
| - // The context we use for OpenGL rendering.
|
| - ContentGLContext* context_;
|
| - // The GLES2Implementation we use for OpenGL rendering.
|
| - gpu::gles2::GLES2Implementation* gl_;
|
| -
|
| // State needed by MaybeInitializeGL.
|
| - GpuChannelHost* host_;
|
| - int32 surface_id_;
|
| - GURL active_url_;
|
| - base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client_;
|
| + bool render_directly_to_web_view_;
|
|
|
| - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM*
|
| - memory_allocation_changed_callback_;
|
| + // Context Lost
|
| + void OnContextLost();
|
| +
|
| + // If rendering directly to WebView, weak pointer to it.
|
| + // This is only set when the context is bound to the main thread.
|
| + WebKit::WebView* web_view_;
|
|
|
| WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
|
| WGC3Denum context_lost_reason_;
|
|
|
| - WebGraphicsContext3D::WebGraphicsErrorMessageCallback*
|
| - error_message_callback_;
|
| -
|
| WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM*
|
| swapbuffers_complete_callback_;
|
|
|
| WebKit::WebGraphicsContext3D::Attributes attributes_;
|
| - gfx::GpuPreference gpu_preference_;
|
| int cached_width_, cached_height_;
|
| + bool dead_;
|
|
|
| // For tracking which FBO is bound.
|
| WebGLId bound_fbo_;
|
| @@ -542,14 +509,24 @@ class WebGraphicsContext3DCommandBufferImpl
|
| // Errors raised by synthesizeGLError().
|
| std::vector<WGC3Denum> synthetic_errors_;
|
|
|
| - base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_;
|
| + scoped_ptr<gpu::CommandBuffer> command_buffer_;
|
| +
|
| + scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_;
|
| +
|
| + scoped_ptr<gpu::TransferBuffer> transfer_buffer_;
|
| +
|
| + scoped_ptr<gpu::gles2::GLES2Implementation> gl_;
|
| +
|
| + base::WeakPtrFactory<WebGraphicsContext3DGuest> weak_ptr_factory_;
|
|
|
| #ifdef FLIP_FRAMEBUFFER_VERTICALLY
|
| - std::vector<uint8> scanline_;
|
| + scoped_array<uint8> scanline_;
|
| void FlipVertically(uint8* framebuffer,
|
| unsigned int width,
|
| unsigned int height);
|
| #endif
|
| +
|
| };
|
|
|
| -#endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_
|
| +#endif // defined(ENABLE_GPU)
|
| +#endif // CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_GUEST_H_
|
|
|