summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/aura/gpu_process_transport_factory.cc79
-rw-r--r--content/browser/aura/gpu_process_transport_factory.h8
-rw-r--r--content/browser/renderer_host/compositor_impl_android.cc45
-rw-r--r--content/browser/renderer_host/compositor_impl_android.h12
-rw-r--r--content/browser/renderer_host/image_transport_factory_android.cc2
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc27
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h18
-rw-r--r--content/renderer/gpu/render_widget_compositor.cc10
-rw-r--r--content/renderer/gpu/render_widget_compositor.h4
-rw-r--r--content/renderer/render_widget.cc21
-rw-r--r--content/renderer/render_widget.h18
11 files changed, 57 insertions, 187 deletions
diff --git a/content/browser/aura/gpu_process_transport_factory.cc b/content/browser/aura/gpu_process_transport_factory.cc
index f958ae9..4b8e8ef 100644
--- a/content/browser/aura/gpu_process_transport_factory.cc
+++ b/content/browser/aura/gpu_process_transport_factory.cc
@@ -46,7 +46,6 @@ namespace content {
struct GpuProcessTransportFactory::PerCompositorData {
int surface_id;
- scoped_ptr<CompositorSwapClient> swap_client;
#if defined(OS_WIN)
scoped_ptr<AcceleratedSurface> accelerated_surface;
#endif
@@ -143,48 +142,6 @@ class ImageTransportClientTexture : public OwnedTexture {
DISALLOW_COPY_AND_ASSIGN(ImageTransportClientTexture);
};
-class CompositorSwapClient
- : public base::SupportsWeakPtr<CompositorSwapClient>,
- public WebGraphicsContext3DSwapBuffersClient {
- public:
- CompositorSwapClient(ui::Compositor* compositor,
- GpuProcessTransportFactory* factory)
- : compositor_(compositor),
- factory_(factory) {
- }
-
- virtual ~CompositorSwapClient() {
- }
-
- virtual void OnViewContextSwapBuffersPosted() OVERRIDE {
- compositor_->OnSwapBuffersPosted();
- }
-
- virtual void OnViewContextSwapBuffersComplete() OVERRIDE {
- compositor_->OnSwapBuffersComplete();
- }
-
- virtual void OnViewContextSwapBuffersAborted() OVERRIDE {
- // Recreating contexts directly from here causes issues, so post a task
- // instead.
- // TODO(piman): Fix the underlying issues.
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&CompositorSwapClient::OnLostContext, this->AsWeakPtr()));
- }
-
- private:
- void OnLostContext() {
- factory_->OnLostContext(compositor_);
- // Note: previous line destroyed this. Don't access members from now on.
- }
-
- ui::Compositor* compositor_;
- GpuProcessTransportFactory* factory_;
-
- DISALLOW_COPY_AND_ASSIGN(CompositorSwapClient);
-};
-
GpuProcessTransportFactory::GpuProcessTransportFactory()
: callback_factory_(this) {
output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy(
@@ -200,8 +157,7 @@ GpuProcessTransportFactory::~GpuProcessTransportFactory() {
scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() {
- base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
- return CreateContextCommon(swap_client, 0);
+ return CreateContextCommon(0);
}
scoped_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
@@ -228,17 +184,12 @@ scoped_ptr<cc::OutputSurface> GpuProcessTransportFactory::CreateOutputSurface(
data = CreatePerCompositorData(compositor);
scoped_refptr<ContextProviderCommandBuffer> context_provider;
- base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client_weak_ptr;
- if (data->swap_client)
- swap_client_weak_ptr = data->swap_client->AsWeakPtr();
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kUIEnableSoftwareCompositing)) {
context_provider = ContextProviderCommandBuffer::Create(
- GpuProcessTransportFactory::CreateContextCommon(
- swap_client_weak_ptr,
- data->surface_id),
- "Compositor");
+ GpuProcessTransportFactory::CreateContextCommon(data->surface_id),
+ "Compositor");
}
UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", !!context_provider);
@@ -454,18 +405,6 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() {
return shared_main_thread_contexts_;
}
-void GpuProcessTransportFactory::OnLostContext(ui::Compositor* compositor) {
- LOG(ERROR) << "Lost UI compositor context.";
- PerCompositorData* data = per_compositor_data_[compositor];
- DCHECK(data);
-
- // Prevent callbacks from other contexts in the same share group from
- // calling us again.
- if (data->swap_client.get())
- data->swap_client.reset(new CompositorSwapClient(compositor, this));
- compositor->OnSwapBuffersAborted();
-}
-
GpuProcessTransportFactory::PerCompositorData*
GpuProcessTransportFactory::CreatePerCompositorData(
ui::Compositor* compositor) {
@@ -476,8 +415,6 @@ GpuProcessTransportFactory::CreatePerCompositorData(
PerCompositorData* data = new PerCompositorData;
data->surface_id = tracker->AddSurfaceForNativeWidget(widget);
- if (!ui::Compositor::WasInitializedWithThread())
- data->swap_client.reset(new CompositorSwapClient(compositor, this));
#if defined(OS_WIN)
if (GpuDataManagerImpl::GetInstance()->IsUsingAcceleratedSurface())
data->accelerated_surface.reset(new AcceleratedSurface(widget));
@@ -492,9 +429,7 @@ GpuProcessTransportFactory::CreatePerCompositorData(
}
scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
-GpuProcessTransportFactory::CreateContextCommon(
- const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client,
- int surface_id) {
+GpuProcessTransportFactory::CreateContextCommon(int surface_id) {
if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor())
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
blink::WebGraphicsContext3D::Attributes attrs;
@@ -503,9 +438,10 @@ GpuProcessTransportFactory::CreateContextCommon(
attrs.stencil = false;
attrs.antialias = false;
attrs.noAutomaticFlushes = true;
+ CauseForGpuLaunch cause =
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
scoped_refptr<GpuChannelHost> gpu_channel_host(
- BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(
- CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
+ BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause));
if (!gpu_channel_host)
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon");
@@ -515,7 +451,6 @@ GpuProcessTransportFactory::CreateContextCommon(
surface_id,
url,
gpu_channel_host.get(),
- swap_client,
use_echo_for_swap_ack,
attrs,
false,
diff --git a/content/browser/aura/gpu_process_transport_factory.h b/content/browser/aura/gpu_process_transport_factory.h
index dd6e79a..36ebb00 100644
--- a/content/browser/aura/gpu_process_transport_factory.h
+++ b/content/browser/aura/gpu_process_transport_factory.h
@@ -22,7 +22,6 @@ class CompositorSwapClient;
class ContextProviderCommandBuffer;
class ReflectorImpl;
class WebGraphicsContext3DCommandBufferImpl;
-class WebGraphicsContext3DSwapBuffersClient;
class GpuProcessTransportFactory
: public ui::ContextFactory,
@@ -68,15 +67,12 @@ class GpuProcessTransportFactory
virtual void RemoveObserver(
ImageTransportFactoryObserver* observer) OVERRIDE;
- void OnLostContext(ui::Compositor* compositor);
-
private:
struct PerCompositorData;
PerCompositorData* CreatePerCompositorData(ui::Compositor* compositor);
- scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContextCommon(
- const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client,
- int surface_id);
+ scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
+ CreateContextCommon(int surface_id);
void OnLostMainThreadSharedContextInsideCallback();
void OnLostMainThreadSharedContext();
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index 3189e9f..86acf38 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -134,8 +134,7 @@ CompositorImpl::CompositorImpl(CompositorClient* client)
has_transparent_background_(false),
window_(NULL),
surface_id_(0),
- client_(client),
- weak_factory_(this) {
+ client_(client) {
DCHECK(client);
ImageTransportFactoryAndroid::AddObserver(this);
}
@@ -347,12 +346,13 @@ bool CompositorImpl::CopyTextureToBitmap(blink::WebGLId texture_id,
static scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
CreateGpuProcessViewContext(
const blink::WebGraphicsContext3D::Attributes attributes,
- int surface_id,
- base::WeakPtr<CompositorImpl> compositor_impl) {
+ int surface_id) {
BrowserGpuChannelHostFactory* factory =
BrowserGpuChannelHostFactory::instance();
- scoped_refptr<GpuChannelHost> gpu_channel_host(factory->EstablishGpuChannelSync(
- CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
+ CauseForGpuLaunch cause =
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
+ scoped_refptr<GpuChannelHost> gpu_channel_host(
+ factory->EstablishGpuChannelSync(cause));
if (!gpu_channel_host)
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
@@ -375,7 +375,6 @@ CreateGpuProcessViewContext(
new WebGraphicsContext3DCommandBufferImpl(surface_id,
url,
gpu_channel_host.get(),
- compositor_impl,
use_echo_for_swap_ack,
attributes,
false,
@@ -392,8 +391,8 @@ scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface(
DCHECK(surface_id_);
scoped_refptr<ContextProviderCommandBuffer> context_provider =
- ContextProviderCommandBuffer::Create(CreateGpuProcessViewContext(
- attrs, surface_id_, weak_factory_.GetWeakPtr()), "BrowserCompositor");
+ ContextProviderCommandBuffer::Create(
+ CreateGpuProcessViewContext(attrs, surface_id_), "BrowserCompositor");
if (!context_provider.get()) {
LOG(ERROR) << "Failed to create 3D context for compositor.";
return scoped_ptr<cc::OutputSurface>();
@@ -407,14 +406,6 @@ void CompositorImpl::OnLostResources() {
client_->DidLoseResources();
}
-void CompositorImpl::DidCompleteSwapBuffers() {
- client_->OnSwapBuffersCompleted();
-}
-
-void CompositorImpl::ScheduleComposite() {
- client_->ScheduleComposite();
-}
-
scoped_refptr<cc::ContextProvider> CompositorImpl::OffscreenContextProvider() {
// There is no support for offscreen contexts, or compositor filters that
// would require them in this compositor instance. If they are needed,
@@ -423,19 +414,21 @@ scoped_refptr<cc::ContextProvider> CompositorImpl::OffscreenContextProvider() {
return NULL;
}
-void CompositorImpl::OnViewContextSwapBuffersPosted() {
- TRACE_EVENT0("compositor", "CompositorImpl::OnViewContextSwapBuffersPosted");
- client_->OnSwapBuffersPosted();
+void CompositorImpl::DidCompleteSwapBuffers() {
+ client_->OnSwapBuffersCompleted();
}
-void CompositorImpl::OnViewContextSwapBuffersComplete() {
- TRACE_EVENT0("compositor",
- "CompositorImpl::OnViewContextSwapBuffersComplete");
- client_->OnSwapBuffersCompleted();
+void CompositorImpl::ScheduleComposite() {
+ client_->ScheduleComposite();
+}
+
+void CompositorImpl::DidPostSwapBuffers() {
+ TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers");
+ client_->OnSwapBuffersPosted();
}
-void CompositorImpl::OnViewContextSwapBuffersAborted() {
- TRACE_EVENT0("compositor", "CompositorImpl::OnViewContextSwapBuffersAborted");
+void CompositorImpl::DidAbortSwapBuffers() {
+ TRACE_EVENT0("compositor", "CompositorImpl::DidAbortSwapBuffers");
client_->OnSwapBuffersCompleted();
}
diff --git a/content/browser/renderer_host/compositor_impl_android.h b/content/browser/renderer_host/compositor_impl_android.h
index 95546000..04ae395 100644
--- a/content/browser/renderer_host/compositor_impl_android.h
+++ b/content/browser/renderer_host/compositor_impl_android.h
@@ -9,7 +9,6 @@
#include "base/compiler_specific.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "cc/resources/ui_resource_client.h"
#include "cc/trees/layer_tree_host_client.h"
#include "cc/trees/layer_tree_host_single_thread_client.h"
@@ -38,7 +37,6 @@ class CONTENT_EXPORT CompositorImpl
: public Compositor,
public cc::LayerTreeHostClient,
public cc::LayerTreeHostSingleThreadClient,
- public WebGraphicsContext3DSwapBuffersClient,
public ImageTransportFactoryAndroidObserver {
public:
explicit CompositorImpl(CompositorClient* client);
@@ -91,13 +89,8 @@ class CONTENT_EXPORT CompositorImpl
// LayerTreeHostSingleThreadClient implementation.
virtual void ScheduleComposite() OVERRIDE;
- virtual void DidPostSwapBuffers() OVERRIDE {}
- virtual void DidAbortSwapBuffers() OVERRIDE {}
-
- // WebGraphicsContext3DSwapBuffersClient implementation.
- virtual void OnViewContextSwapBuffersPosted() OVERRIDE;
- virtual void OnViewContextSwapBuffersComplete() OVERRIDE;
- virtual void OnViewContextSwapBuffersAborted() OVERRIDE;
+ virtual void DidPostSwapBuffers() OVERRIDE;
+ virtual void DidAbortSwapBuffers() OVERRIDE;
// ImageTransportFactoryAndroidObserver implementation.
virtual void OnLostResources() OVERRIDE;
@@ -117,7 +110,6 @@ class CONTENT_EXPORT CompositorImpl
int surface_id_;
CompositorClient* client_;
- base::WeakPtrFactory<CompositorImpl> weak_factory_;
scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_;
diff --git a/content/browser/renderer_host/image_transport_factory_android.cc b/content/browser/renderer_host/image_transport_factory_android.cc
index 380cc7a..80c5e84 100644
--- a/content/browser/renderer_host/image_transport_factory_android.cc
+++ b/content/browser/renderer_host/image_transport_factory_android.cc
@@ -65,7 +65,6 @@ CmdBufferImageTransportFactory::CmdBufferImageTransportFactory() {
blink::WebGraphicsContext3D::Attributes attrs;
attrs.shareResources = true;
GURL url("chrome://gpu/ImageTransportFactoryAndroid");
- base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
static const size_t kBytesPerPixel = 4;
gfx::DeviceDisplayInfo display_info;
size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() *
@@ -84,7 +83,6 @@ CmdBufferImageTransportFactory::CmdBufferImageTransportFactory() {
new WebGraphicsContext3DCommandBufferImpl(0, // offscreen
url,
gpu_channel_host.get(),
- swap_client,
use_echo_for_swap_ack,
attrs,
false,
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
index 6cfe532..181d7a5 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
@@ -206,7 +206,6 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
int surface_id,
const GURL& active_url,
GpuChannelHost* host,
- const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client,
bool use_echo_for_swap_ack,
const Attributes& attributes,
bool bind_generates_resources,
@@ -217,7 +216,6 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
host_(host),
surface_id_(surface_id),
active_url_(active_url),
- swap_client_(swap_client),
context_lost_callback_(0),
context_lost_reason_(GL_NO_ERROR),
error_message_callback_(0),
@@ -503,10 +501,6 @@ void WebGraphicsContext3DCommandBufferImpl::prepareTexture() {
"WebGraphicsContext3DCommandBufferImpl::SwapBuffers",
"frame", frame_number_);
frame_number_++;
- // Copies the contents of the off-screen render target into the texture
- // used by the compositor.
- if (ShouldUseSwapClient())
- swap_client_->OnViewContextSwapBuffersPosted();
if (command_buffer_->GetLastState().error == gpu::error::kNoError)
gl_->SwapBuffers();
@@ -516,6 +510,7 @@ void WebGraphicsContext3DCommandBufferImpl::prepareTexture() {
&WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete,
weak_ptr_factory_.GetWeakPtr()));
}
+
#if defined(OS_MACOSX)
// It appears that making the compositor's on-screen context current on
// other platforms implies this flush. TODO(kbr): this means that the
@@ -528,8 +523,6 @@ void WebGraphicsContext3DCommandBufferImpl::postSubBufferCHROMIUM(
int x, int y, int width, int height) {
// Same flow control as WebGraphicsContext3DCommandBufferImpl::prepareTexture
// (see above).
- if (ShouldUseSwapClient())
- swap_client_->OnViewContextSwapBuffersPosted();
gl_->PostSubBufferCHROMIUM(x, y, width, height);
command_buffer_->Echo(base::Bind(
&WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete,
@@ -1206,20 +1199,7 @@ DELEGATE_TO_GL_1(deleteProgram, DeleteProgram, WebGLId)
DELEGATE_TO_GL_1(deleteShader, DeleteShader, WebGLId)
-bool WebGraphicsContext3DCommandBufferImpl::ShouldUseSwapClient() {
- return !!swap_client_.get();
-}
-
void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() {
- typedef WebGraphicsContext3DSwapBuffersClient WGC3DSwapClient;
- // This may be called after tear-down of the RenderView.
- if (ShouldUseSwapClient()) {
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&WGC3DSwapClient::OnViewContextSwapBuffersComplete,
- swap_client_));
- }
-
if (swapbuffers_complete_callback_)
swapbuffers_complete_callback_->onSwapBuffersComplete();
}
@@ -1261,12 +1241,10 @@ WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
const SharedMemoryLimits& limits) {
if (!host)
return NULL;
- base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> null_client;
bool use_echo_for_swap_ack = true;
return new WebGraphicsContext3DCommandBufferImpl(0,
active_url,
host,
- null_client,
use_echo_for_swap_ack,
attributes,
false,
@@ -1446,9 +1424,6 @@ void WebGraphicsContext3DCommandBufferImpl::OnGpuChannelLost() {
base::AutoLock lock(g_all_shared_contexts_lock.Get());
g_all_shared_contexts.Get().erase(host_.get());
}
-
- if (ShouldUseSwapClient())
- swap_client_->OnViewContextSwapBuffersAborted();
}
void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage(
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
index 4823ba2..a8af08a 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
@@ -54,18 +54,6 @@ const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024;
const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024;
const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024;
-// TODO(piman): move this logic to the compositor and remove it from the
-// context...
-class WebGraphicsContext3DSwapBuffersClient {
- public:
- virtual void OnViewContextSwapBuffersPosted() = 0;
- virtual void OnViewContextSwapBuffersComplete() = 0;
- virtual void OnViewContextSwapBuffersAborted() = 0;
-
- protected:
- virtual ~WebGraphicsContext3DSwapBuffersClient() {}
-};
-
class WebGraphicsContext3DErrorMessageCallback;
class WebGraphicsContext3DCommandBufferImpl
@@ -89,7 +77,6 @@ class WebGraphicsContext3DCommandBufferImpl
int surface_id,
const GURL& active_url,
GpuChannelHost* host,
- const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client,
bool use_echo_for_swap_ack,
const Attributes& attributes,
bool bind_generates_resources,
@@ -708,10 +695,6 @@ class WebGraphicsContext3DCommandBufferImpl
virtual void OnGpuChannelLost();
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();
-
bool initialize_failed_;
bool visible_;
@@ -721,7 +704,6 @@ class WebGraphicsContext3DCommandBufferImpl
scoped_refptr<GpuChannelHost> host_;
int32 surface_id_;
GURL active_url_;
- base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client_;
WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
WGC3Denum context_lost_reason_;
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc
index 85b204b..1c24135 100644
--- a/content/renderer/gpu/render_widget_compositor.cc
+++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -641,6 +641,8 @@ void RenderWidgetCompositor::DidCommitAndDrawFrame() {
void RenderWidgetCompositor::DidCompleteSwapBuffers() {
widget_->didCompleteSwapBuffers();
+ if (!threaded_)
+ widget_->OnSwapBuffersComplete();
}
scoped_refptr<cc::ContextProvider>
@@ -653,6 +655,14 @@ void RenderWidgetCompositor::ScheduleComposite() {
widget_->scheduleComposite();
}
+void RenderWidgetCompositor::DidPostSwapBuffers() {
+ widget_->OnSwapBuffersPosted();
+}
+
+void RenderWidgetCompositor::DidAbortSwapBuffers() {
+ widget_->OnSwapBuffersAborted();
+}
+
void RenderWidgetCompositor::RateLimitSharedMainThreadContext() {
cc::ContextProvider* provider =
RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h
index c5fd2cc..40109a8 100644
--- a/content/renderer/gpu/render_widget_compositor.h
+++ b/content/renderer/gpu/render_widget_compositor.h
@@ -131,8 +131,8 @@ class RenderWidgetCompositor : public blink::WebLayerTreeView,
// cc::LayerTreeHostSingleThreadClient implementation.
virtual void ScheduleComposite() OVERRIDE;
- virtual void DidPostSwapBuffers() OVERRIDE {}
- virtual void DidAbortSwapBuffers() OVERRIDE {}
+ virtual void DidPostSwapBuffers() OVERRIDE;
+ virtual void DidAbortSwapBuffers() OVERRIDE;
private:
RenderWidgetCompositor(RenderWidget* widget, bool threaded);
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index b9ad015..06adc63 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -376,8 +376,7 @@ RenderWidget::RenderWidget(blink::WebPopupType popup_type,
outstanding_ime_acks_(0),
#endif
popup_origin_scale_for_emulation_(0.f),
- resizing_mode_selector_(new ResizingModeSelector()),
- weak_ptr_factory_(this) {
+ resizing_mode_selector_(new ResizingModeSelector()) {
if (!swapped_out)
RenderProcess::current()->AddRefProcess();
DCHECK(RenderThread::Get());
@@ -601,8 +600,7 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
- IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK,
- OnViewContextSwapBuffersComplete)
+ IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete)
IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive)
IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
@@ -966,7 +964,7 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) {
use_swap_compositor_frame_message));
}
-void RenderWidget::OnViewContextSwapBuffersAborted() {
+void RenderWidget::OnSwapBuffersAborted() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
while (!updates_pending_swap_.empty()) {
ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
@@ -982,7 +980,7 @@ void RenderWidget::OnViewContextSwapBuffersAborted() {
scheduleComposite();
}
-void RenderWidget::OnViewContextSwapBuffersPosted() {
+void RenderWidget::OnSwapBuffersPosted() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
if (using_asynchronous_swapbuffers_) {
@@ -999,7 +997,7 @@ void RenderWidget::OnViewContextSwapBuffersPosted() {
}
}
-void RenderWidget::OnViewContextSwapBuffersComplete() {
+void RenderWidget::OnSwapBuffersComplete() {
TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete");
// Notify subclasses that composited rendering was flushed to the screen.
@@ -2794,9 +2792,10 @@ RenderWidget::CreateGraphicsContext3D(
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
if (!RenderThreadImpl::current())
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
+ CauseForGpuLaunch cause =
+ CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
scoped_refptr<GpuChannelHost> gpu_channel_host(
- RenderThreadImpl::current()->EstablishGpuChannelSync(
- CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
+ RenderThreadImpl::current()->EstablishGpuChannelSync(cause));
if (!gpu_channel_host)
return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
@@ -2824,11 +2823,8 @@ RenderWidget::CreateGraphicsContext3D(
max_transfer_buffer_usage_mb * kBytesPerMegabyte;
#endif
- base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
-
bool use_echo_for_swap_ack = true;
if (!is_threaded_compositing_enabled_) {
- swap_client = weak_ptr_factory_.GetWeakPtr();
#if (defined(OS_MACOSX) || defined(OS_WIN)) && !defined(USE_AURA)
// ViewMsg_SwapBuffers_ACK is used instead for single-threaded path.
use_echo_for_swap_ack = false;
@@ -2840,7 +2836,6 @@ RenderWidget::CreateGraphicsContext3D(
surface_id(),
GetURLForGraphicsContext3D(),
gpu_channel_host.get(),
- swap_client,
use_echo_for_swap_ack,
attributes,
false /* bind generates resources */,
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index abd20c3..c8812f4 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -12,7 +12,6 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "cc/debug/rendering_stats_instrumentation.h"
@@ -79,7 +78,6 @@ class CONTENT_EXPORT RenderWidget
: public IPC::Listener,
public IPC::Sender,
NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
- NON_EXPORTED_BASE(public WebGraphicsContext3DSwapBuffersClient),
public base::RefCounted<RenderWidget> {
public:
// Creates a new RenderWidget. The opener_id is the routing ID of the
@@ -242,6 +240,12 @@ class CONTENT_EXPORT RenderWidget
void ScheduleCompositeWithForcedRedraw();
+ // Called by the compositor in single-threaded mode when a swap is posted,
+ // completes or is aborted.
+ void OnSwapBuffersPosted();
+ void OnSwapBuffersComplete();
+ void OnSwapBuffersAborted();
+
protected:
// Friend RefCounted so that the dtor can be non-public. Using this class
// without ref-counting is an error.
@@ -400,14 +404,6 @@ class CONTENT_EXPORT RenderWidget
virtual bool ForceCompositingModeEnabled();
- // WebGraphicsContext3DSwapBuffersClient implementation.
-
- // Called by a GraphicsContext associated with this view when swapbuffers
- // is posted, completes or is aborted.
- virtual void OnViewContextSwapBuffersPosted() OVERRIDE;
- virtual void OnViewContextSwapBuffersComplete() OVERRIDE;
- virtual void OnViewContextSwapBuffersAborted() OVERRIDE;
-
// Detects if a suitable opaque plugin covers the given paint bounds with no
// compositing necessary.
//
@@ -792,8 +788,6 @@ class CONTENT_EXPORT RenderWidget
scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
- base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
-
DISALLOW_COPY_AND_ASSIGN(RenderWidget);
};