summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/command_buffer_proxy.cc7
-rw-r--r--chrome/renderer/command_buffer_proxy.h2
-rw-r--r--chrome/renderer/ggl/ggl.cc25
-rw-r--r--chrome/renderer/ggl/ggl.h2
-rw-r--r--chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc22
-rw-r--r--chrome/renderer/webgraphicscontext3d_command_buffer_impl.h9
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_impl.h3
7 files changed, 68 insertions, 2 deletions
diff --git a/chrome/renderer/command_buffer_proxy.cc b/chrome/renderer/command_buffer_proxy.cc
index 3112031..fb0b7d1 100644
--- a/chrome/renderer/command_buffer_proxy.cc
+++ b/chrome/renderer/command_buffer_proxy.cc
@@ -54,6 +54,13 @@ void CommandBufferProxy::OnChannelError() {
// When the client sees that the context is lost, they should delete this
// CommandBufferProxy and create a new one.
last_state_.error = gpu::error::kLostContext;
+
+ if (channel_error_callback_.get())
+ channel_error_callback_->Run();
+}
+
+void CommandBufferProxy::SetChannelErrorCallback(Callback0::Type* callback) {
+ channel_error_callback_.reset(callback);
}
bool CommandBufferProxy::Initialize(int32 size) {
diff --git a/chrome/renderer/command_buffer_proxy.h b/chrome/renderer/command_buffer_proxy.h
index 3e7c50c..c49e34a 100644
--- a/chrome/renderer/command_buffer_proxy.h
+++ b/chrome/renderer/command_buffer_proxy.h
@@ -60,6 +60,7 @@ class CommandBufferProxy : public gpu::CommandBuffer,
// Set a callback that will be invoked when the SwapBuffers call has been
// issued.
void SetSwapBuffersCallback(Callback0::Type* callback);
+ void SetChannelErrorCallback(Callback0::Type* callback);
// Asynchronously resizes an offscreen frame buffer.
void ResizeOffscreenFrameBuffer(const gfx::Size& size);
@@ -117,6 +118,7 @@ class CommandBufferProxy : public gpu::CommandBuffer,
scoped_ptr<Task> notify_repaint_task_;
scoped_ptr<Callback0::Type> swap_buffers_callback_;
+ scoped_ptr<Callback0::Type> channel_error_callback_;
DISALLOW_COPY_AND_ASSIGN(CommandBufferProxy);
};
diff --git a/chrome/renderer/ggl/ggl.cc b/chrome/renderer/ggl/ggl.cc
index 16260f1..e829e70 100644
--- a/chrome/renderer/ggl/ggl.cc
+++ b/chrome/renderer/ggl/ggl.cc
@@ -82,6 +82,10 @@ class Context : public base::SupportsWeakPtr<Context> {
swap_buffers_callback_.reset(callback);
}
+ void SetContextLostCallback(Callback0::Type* callback) {
+ context_lost_callback_.reset(callback);
+ }
+
// For an offscreen frame buffer context, return the frame buffer ID with
// respect to the parent.
uint32 parent_texture_id() const {
@@ -130,10 +134,12 @@ class Context : public base::SupportsWeakPtr<Context> {
private:
void OnSwapBuffers();
+ void OnContextLost();
scoped_refptr<GpuChannelHost> channel_;
base::WeakPtr<Context> parent_;
scoped_ptr<Callback0::Type> swap_buffers_callback_;
+ scoped_ptr<Callback0::Type> context_lost_callback_;
uint32 parent_texture_id_;
CommandBufferProxy* command_buffer_;
gpu::gles2::GLES2CmdHelper* gles2_helper_;
@@ -238,8 +244,11 @@ bool Context::Initialize(bool onscreen,
return false;
}
- command_buffer_->SetSwapBuffersCallback(NewCallback(this,
- &Context::OnSwapBuffers));
+ command_buffer_->SetSwapBuffersCallback(
+ NewCallback(this, &Context::OnSwapBuffers));
+
+ command_buffer_->SetChannelErrorCallback(
+ NewCallback(this, &Context::OnContextLost));
// Create the GLES2 helper, which writes the command buffer protocol.
gles2_helper_ = new gpu::gles2::GLES2CmdHelper(command_buffer_);
@@ -435,6 +444,11 @@ void Context::OnSwapBuffers() {
swap_buffers_callback_->Run();
}
+void Context::OnContextLost() {
+ if (context_lost_callback_.get())
+ context_lost_callback_->Run();
+}
+
#endif // ENABLE_GPU
Context* CreateViewContext(GpuChannelHost* channel,
@@ -512,6 +526,13 @@ void SetSwapBuffersCallback(Context* context,
#endif
}
+void SetContextLostCallback(Context* context,
+ Callback0::Type* callback) {
+#if defined(ENABLE_GPU)
+ context->SetContextLostCallback(callback);
+#endif
+}
+
bool MakeCurrent(Context* context) {
#if defined(ENABLE_GPU)
return Context::MakeCurrent(context);
diff --git a/chrome/renderer/ggl/ggl.h b/chrome/renderer/ggl/ggl.h
index 04ac19e..b8e309b 100644
--- a/chrome/renderer/ggl/ggl.h
+++ b/chrome/renderer/ggl/ggl.h
@@ -128,6 +128,8 @@ void DeleteParentTexture(Context* context, uint32 texture);
// service side.
void SetSwapBuffersCallback(Context* context, Callback0::Type* callback);
+void SetContextLostCallback(Context* context, Callback0::Type* callback);
+
// Set the current GGL context for the calling thread.
bool MakeCurrent(Context* context);
diff --git a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc
index c5ad191..52f8440 100644
--- a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc
+++ b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc
@@ -27,6 +27,10 @@
WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl()
: context_(NULL),
web_view_(NULL),
+#if defined(OS_MACOSX)
+ plugin_handle_(NULL),
+#endif // defined(OS_MACOSX)
+ context_lost_callback_(0),
cached_width_(0),
cached_height_(0),
bound_fbo_(0) {
@@ -126,6 +130,12 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize(
}
if (!context_)
return false;
+
+ ggl::SetContextLostCallback(
+ context_,
+ NewCallback(this,
+ &WebGraphicsContext3DCommandBufferImpl::OnContextLost));
+
// TODO(gman): Remove this.
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) {
@@ -998,4 +1008,16 @@ void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffers() {
renderview->DidFlushPaint();
}
+void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback(
+ WebGraphicsContext3D::WebGraphicsContextLostCallback* cb)
+{
+ context_lost_callback_ = cb;
+}
+
+void WebGraphicsContext3DCommandBufferImpl::OnContextLost() {
+ if (context_lost_callback_) {
+ context_lost_callback_->onContextLost();
+ }
+}
+
#endif // defined(ENABLE_GPU)
diff --git a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.h b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.h
index 85edd03..01711e0 100644
--- a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.h
+++ b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.h
@@ -421,14 +421,23 @@ class WebGraphicsContext3DCommandBufferImpl
ggl::Context* context() { return context_; }
+ virtual void setContextLostCallback(
+ WebGraphicsContext3D::WebGraphicsContextLostCallback* callback);
+
private:
// SwapBuffers callback;
void OnSwapBuffers();
+ virtual void OnContextLost();
// The GGL context we use for OpenGL rendering.
ggl::Context* context_;
// If rendering directly to WebView, weak pointer to it.
WebKit::WebView* web_view_;
+#if defined(OS_MACOSX)
+ // "Fake" plugin window handle in browser process for the compositor's output.
+ gfx::PluginWindowHandle plugin_handle_;
+#endif
+ WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
WebKit::WebGraphicsContext3D::Attributes attributes_;
int cached_width_, cached_height_;
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_impl.h
index df4dded..41631e6 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_impl.h
+++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.h
@@ -397,6 +397,9 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D {
virtual void deleteShader(WebGLId);
virtual void deleteTexture(WebGLId);
+ virtual void setContextLostCallback(
+ WebGraphicsContext3D::WebGraphicsContextLostCallback* callback) {}
+
private:
// ANGLE related.
struct ShaderSourceEntry;