Commit 7db0709d authored by pilgrim's avatar pilgrim Committed by Commit bot

Move InitializeOnCurrentThread down from WebGraphicsContext3DImpl to...

Move InitializeOnCurrentThread down from WebGraphicsContext3DImpl to WebGraphicsContext3DCommandBufferImpl and WebGraphicsContext3DInProcessCommandBufferImpl

in preparation for dis-inheriting these classes

BUG=338338
TBR=darin@chromium.org

Review URL: https://codereview.chromium.org/609973002

Cr-Commit-Position: refs/heads/master@{#297362}
parent 1a815bc3
......@@ -223,7 +223,7 @@ SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
return factory;
}
webkit::gpu::WebGraphicsContext3DImpl*
webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl*
SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) {
return WrapContextWithAttributes(CreateOffscreenContext(attributes),
......
......@@ -44,7 +44,7 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
const std::string& debug_name) OVERRIDE;
virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
int view_id) OVERRIDE;
virtual webkit::gpu::WebGraphicsContext3DImpl*
virtual webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl*
CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) OVERRIDE;
......
......@@ -142,8 +142,7 @@ class WebGraphicsContext3DCommandBufferImpl
return mem_limits_.mapped_memory_reclaim_limit;
}
// WebGraphicsContext3DImpl methods
virtual bool InitializeOnCurrentThread() OVERRIDE;
CONTENT_EXPORT bool InitializeOnCurrentThread();
//----------------------------------------------------------------------
// WebGraphicsContext3D methods
......
......@@ -21,7 +21,7 @@ class OutputSurface;
namespace webkit {
namespace gpu {
class ContextProviderWebContext;
class WebGraphicsContext3DImpl;
class WebGraphicsContext3DInProcessCommandBufferImpl;
}
}
......@@ -58,7 +58,7 @@ class SynchronousCompositorFactory {
const std::string& debug_name) = 0;
virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
int frame_id) = 0;
virtual webkit::gpu::WebGraphicsContext3DImpl*
virtual webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl*
CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) = 0;
......
......@@ -81,6 +81,7 @@
#if defined(OS_ANDROID)
#include "content/renderer/android/synchronous_compositor_factory.h"
#include "content/renderer/media/android/audio_decoder_android.h"
#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
#endif
#if defined(OS_MACOSX)
......@@ -952,30 +953,34 @@ RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
if (!RenderThreadImpl::current())
return NULL;
scoped_ptr<webkit::gpu::WebGraphicsContext3DImpl> context;
bool must_use_synchronous_factory = false;
#if defined(OS_ANDROID)
if (SynchronousCompositorFactory* factory =
SynchronousCompositorFactory::GetInstance()) {
context.reset(factory->CreateOffscreenGraphicsContext3D(attributes));
must_use_synchronous_factory = true;
scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
in_process_context(
factory->CreateOffscreenGraphicsContext3D(attributes));
if (!in_process_context ||
!in_process_context->InitializeOnCurrentThread())
return NULL;
return in_process_context.release();
}
#endif
if (!must_use_synchronous_factory) {
scoped_refptr<GpuChannelHost> gpu_channel_host(
RenderThreadImpl::current()->EstablishGpuChannelSync(
CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
bool lose_context_when_out_of_memory = false;
context.reset(WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
gpu_channel_host.get(),
attributes,
lose_context_when_out_of_memory,
GURL(attributes.topDocumentURL),
limits,
static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)));
}
// Most likely the GPU process exited and the attempt to reconnect to it
// failed. Need to try to restore the context again later.
if (!context || !context->InitializeOnCurrentThread())
......
......@@ -48,11 +48,6 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DImpl
public:
virtual ~WebGraphicsContext3DImpl();
// Must be called before any of the following methods. Permanently binds to
// the first calling thread. Returns false if the graphics context fails to
// initialize. Do not call from more than one thread.
virtual bool InitializeOnCurrentThread() = 0;
//----------------------------------------------------------------------
// WebGraphicsContext3D methods
......
......@@ -60,8 +60,7 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
size_t GetMappedMemoryLimit();
// WebGraphicsContext3DImpl methods
virtual bool InitializeOnCurrentThread() OVERRIDE;
bool InitializeOnCurrentThread();
//----------------------------------------------------------------------
// WebGraphicsContext3D methods
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment