Skip to content

Commit

Permalink
Move InitializeOnCurrentThread down from WebGraphicsContext3DImpl to …
Browse files Browse the repository at this point in the history
…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}
  • Loading branch information
pilgrim authored and Commit bot committed Sep 30, 2014
1 parent 1a815bc commit 7db0709
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions content/renderer/android/synchronous_compositor_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OutputSurface;
namespace webkit {
namespace gpu {
class ContextProviderWebContext;
class WebGraphicsContext3DImpl;
class WebGraphicsContext3DInProcessCommandBufferImpl;
}
}

Expand Down Expand Up @@ -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;

Expand Down
47 changes: 26 additions & 21 deletions content/renderer/renderer_webkitplatformsupport_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -952,34 +953,38 @@ 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;
SynchronousCompositorFactory::GetInstance()) {
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(
gpu_channel_host.get(),
attributes,
lose_context_when_out_of_memory,
GURL(attributes.topDocumentURL),
limits,
static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)));
}

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;
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())
return NULL;
return NULL;
return context.release();
}

Expand Down
5 changes: 0 additions & 5 deletions webkit/common/gpu/webgraphicscontext3d_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl

size_t GetMappedMemoryLimit();

// WebGraphicsContext3DImpl methods
virtual bool InitializeOnCurrentThread() OVERRIDE;
bool InitializeOnCurrentThread();

//----------------------------------------------------------------------
// WebGraphicsContext3D methods
Expand Down

0 comments on commit 7db0709

Please sign in to comment.