Index: chrome/renderer/render_widget.cc |
=================================================================== |
--- chrome/renderer/render_widget.cc (revision 42644) |
+++ chrome/renderer/render_widget.cc (working copy) |
@@ -26,6 +26,13 @@ |
#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" |
#include "webkit/glue/webkit_glue.h" |
+// TODO(apatrick): begin hack. Will remove before checkin. |
+#if defined(OS_WIN) && defined(ENABLE_GPU) |
+#include "chrome/renderer/ggl/ggl.h" |
+#include "gpu/gles2/gl2.h" |
+#endif |
+// end hack |
+ |
#if defined(OS_POSIX) |
#include "ipc/ipc_channel_posix.h" |
#include "third_party/skia/include/core/SkPixelRef.h" |
@@ -150,7 +157,6 @@ |
IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) |
IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint) |
IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
- IPC_MESSAGE_HANDLER(ViewMsg_GpuChannelEstablished, OnGpuChannelEstablished) |
IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
IPC_MESSAGE_UNHANDLED_ERROR() |
IPC_END_MESSAGE_MAP() |
@@ -393,6 +399,44 @@ |
canvas->getTopPlatformDevice().accessBitmap(false); |
canvas->restore(); |
+ |
+ // TODO(apatrick): begin hack. Will remove before checkin. This is an example of how to call OpenGL from a renderer process. |
+#if defined(OS_WIN) && defined(ENABLE_GPU) |
+ //GpuChannelHost* channel = RenderThread::current()->GetGpuChannel(); |
+ //if (!channel) { |
+ // RenderThread::current()->EstablishGpuChannel(); |
+ //} else { |
+ // DebugBreak(); |
+ // ggl::Context* view_context = ggl::CreateViewContext(channel, |
+ // host_window_); |
+ // ggl::Context* offscreen_context = ggl::CreateOffscreenContext(channel, view_context, 256, 256); |
+ // GLuint offscreen_texture_id = ggl::GetParentTextureId(offscreen_context); |
+ |
+ // ggl::MakeCurrent(view_context); |
+ |
+ // GLenum error = glGetError(); |
+ // glBindTexture(GL_TEXTURE_2D, offscreen_texture_id); |
+ // error = glGetError(); |
+ |
+ // ggl::MakeCurrent(offscreen_context); |
+ // glClearColor(1, 1, 0, 1); |
+ // glClear(GL_COLOR_BUFFER_BIT); |
+ // ggl::SwapBuffers(); |
+ // glFinish(); |
+ |
+ // ggl::MakeCurrent(view_context); |
+ // glClearColor(1, 0, 1, 1); |
+ // glClear(GL_COLOR_BUFFER_BIT); |
+ // ggl::SwapBuffers(); |
+ |
+ // error = glGetError(); |
+ // glBindTexture(GL_TEXTURE_2D, offscreen_texture_id); |
+ // error = glGetError(); |
+ |
+ // ggl::DestroyContext(offscreen_context); |
+ // ggl::DestroyContext(view_context); |
+ //} |
+#endif |
} |
void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
@@ -732,23 +776,6 @@ |
webwidget_->setTextDirection(direction); |
} |
-void RenderWidget::OnGpuChannelEstablished( |
- const IPC::ChannelHandle& channel_handle) { |
-#if defined(OS_POSIX) |
- // If we received a ChannelHandle, register it now. |
- if (channel_handle.socket.fd >= 0) |
- IPC::AddChannelSocket(channel_handle.name, channel_handle.socket.fd); |
-#endif |
- |
- if (channel_handle.name.size() != 0) { |
- // Connect to the GPU process if a channel name was received. |
- gpu_channel_->Connect(channel_handle.name); |
- } else { |
- // Otherwise cancel the connection. |
- gpu_channel_ = NULL; |
- } |
-} |
- |
void RenderWidget::SetHidden(bool hidden) { |
if (is_hidden_ == hidden) |
return; |
@@ -892,31 +919,3 @@ |
} |
} |
-void RenderWidget::EstablishGpuChannel() { |
- if (gpu_channel_.get()) { |
- // Do nothing if we are already establishing GPU channel. |
- if (gpu_channel_->state() == GpuChannelHost::UNCONNECTED) |
- return; |
- |
- // Recreate the channel if it has been lost. |
- if (gpu_channel_->state() == GpuChannelHost::LOST) |
- gpu_channel_ = NULL; |
- } |
- |
- if (!gpu_channel_.get()) |
- gpu_channel_ = new GpuChannelHost; |
- |
- // Ask the browser for the channel name. |
- CHECK(Send(new ViewHostMsg_EstablishGpuChannel(routing_id_))); |
-} |
- |
-GpuChannelHost* RenderWidget::GetGpuChannel() { |
- if (!gpu_channel_.get()) |
- return NULL; |
- |
- if (gpu_channel_->state() != GpuChannelHost::CONNECTED) |
- return NULL; |
- |
- return gpu_channel_.get(); |
-} |
- |