summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/accelerated_surface_container_mac.cc40
-rw-r--r--chrome/browser/renderer_host/accelerated_surface_container_mac.h6
-rw-r--r--chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc8
-rw-r--r--chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc3
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h3
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h3
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm4
-rw-r--r--chrome/browser/renderer_host/test/test_render_view_host.cc2
-rw-r--r--chrome/browser/renderer_host/test/test_render_view_host.h3
-rw-r--r--chrome/common/plugin_messages_internal.h6
-rw-r--r--chrome/common/render_messages_internal.h6
-rw-r--r--chrome/plugin/webplugin_proxy.cc4
-rw-r--r--chrome/plugin/webplugin_proxy.h2
-rw-r--r--chrome/renderer/render_view.cc5
-rw-r--r--chrome/renderer/render_view.h2
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc10
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.h4
-rw-r--r--webkit/glue/plugins/webplugin.h5
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm2
21 files changed, 85 insertions, 37 deletions
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc
index fca3a4f..fbdf3cf 100644
--- a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc
+++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc
@@ -10,8 +10,10 @@
#include "webkit/glue/plugins/webplugin.h"
AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac(
- AcceleratedSurfaceContainerManagerMac* manager)
+ AcceleratedSurfaceContainerManagerMac* manager,
+ bool opaque)
: manager_(manager),
+ opaque_(opaque),
x_(0),
y_(0),
surface_(NULL),
@@ -133,10 +135,8 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
}
if (texture_) {
- // TODO(kbr): convert this to use only OpenGL ES 2.0 functionality
- glBindTexture(target, texture_);
- glEnable(target);
- glBegin(GL_TRIANGLE_STRIP);
+ // TODO(kbr): convert this to use only OpenGL ES 2.0 functionality.
+
// TODO(kbr): may need to pay attention to cutout rects.
int clipX = clipRect_.x();
int clipY = clipRect_.y();
@@ -144,6 +144,36 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
int clipHeight = clipRect_.height();
int x = x_ + clipX;
int y = y_ + clipY;
+
+ if (opaque_) {
+ // Pepper 3D's output is currently considered opaque even if the
+ // program draws pixels with alpha less than 1. In order to have
+ // this effect, we need to drop the alpha channel of the input,
+ // replacing it with alpha = 1.
+
+ // First fill the rectangle with alpha=1.
+ glColorMask(false, false, false, true);
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex3f(x, y, 0);
+ glVertex3f(x + clipWidth, y, 0);
+ glVertex3f(x, y + clipHeight, 0);
+ glVertex3f(x + clipWidth, y + clipHeight, 0);
+ glEnd();
+
+ // Now draw the color channels from the incoming texture.
+ glColorMask(true, true, true, false);
+ // This call shouldn't be necessary -- we are using the GL_REPLACE
+ // texture environment mode -- but it appears to be.
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ } else {
+ glColorMask(true, true, true, true);
+ }
+
+ // Draw the color channels from the incoming texture.
+ glBindTexture(target, texture_);
+ glEnable(target);
+ glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(clipX, height_ - clipY);
glVertex3f(x, y, 0);
glTexCoord2f(clipX + clipWidth, height_ - clipY);
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.h b/chrome/browser/renderer_host/accelerated_surface_container_mac.h
index 26f0e30..c03c2801 100644
--- a/chrome/browser/renderer_host/accelerated_surface_container_mac.h
+++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.h
@@ -43,7 +43,8 @@ class AcceleratedSurfaceContainerManagerMac;
class AcceleratedSurfaceContainerMac {
public:
AcceleratedSurfaceContainerMac(
- AcceleratedSurfaceContainerManagerMac* manager);
+ AcceleratedSurfaceContainerManagerMac* manager,
+ bool opaque);
virtual ~AcceleratedSurfaceContainerMac();
// Sets the backing store and size of this accelerated surface container.
@@ -74,6 +75,9 @@ class AcceleratedSurfaceContainerMac {
// The manager of this accelerated surface container.
AcceleratedSurfaceContainerManagerMac* manager_;
+ // Whether this accelerated surface's content is supposed to be opaque.
+ bool opaque_;
+
// The x and y coordinates of the plugin window on the web page.
int x_;
int y_;
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc
index 310d852..716c049 100644
--- a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc
+++ b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc
@@ -13,9 +13,10 @@ AcceleratedSurfaceContainerManagerMac::AcceleratedSurfaceContainerManagerMac()
}
gfx::PluginWindowHandle
-AcceleratedSurfaceContainerManagerMac::AllocateFakePluginWindowHandle() {
+AcceleratedSurfaceContainerManagerMac::AllocateFakePluginWindowHandle(
+ bool opaque) {
AcceleratedSurfaceContainerMac* container =
- new AcceleratedSurfaceContainerMac(this);
+ new AcceleratedSurfaceContainerMac(this, opaque);
gfx::PluginWindowHandle res =
static_cast<gfx::PluginWindowHandle>(++current_id_);
plugin_window_to_container_map_.insert(std::make_pair(res, container));
@@ -76,8 +77,11 @@ void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context) {
}
textures_pending_deletion_.clear();
+ glColorMask(true, true, true, true);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
GLenum target = GL_TEXTURE_RECTANGLE_ARB;
glTexEnvi(target, GL_TEXTURE_ENV_MODE, GL_REPLACE);
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h
index bcfd0aa..bcb3c42 100644
--- a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h
+++ b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h
@@ -27,7 +27,7 @@ class AcceleratedSurfaceContainerManagerMac {
// Allocates a new "fake" PluginWindowHandle, which is used as the
// key for the other operations.
- gfx::PluginWindowHandle AllocateFakePluginWindowHandle();
+ gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque);
// Destroys a fake PluginWindowHandle and associated storage.
void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle id);
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 5dc9badc..6b20935 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -918,11 +918,12 @@ void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id,
}
void RenderWidgetHost::OnAllocateFakePluginWindowHandle(
+ bool opaque,
gfx::PluginWindowHandle* id) {
// TODO(kbr): similar potential issue here as in OnMsgCreatePluginContainer.
// Possibly less of an issue because this is only used for the GPU plugin.
if (view_) {
- *id = view_->AllocateFakePluginWindowHandle();
+ *id = view_->AllocateFakePluginWindowHandle(opaque);
} else {
NOTIMPLEMENTED();
}
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index f8b8218..d57d8bc 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -454,7 +454,8 @@ class RenderWidgetHost : public IPC::Channel::Listener,
WebKit::WebScreenInfo* results);
void OnMsgGetWindowRect(gfx::NativeViewId window_id, gfx::Rect* results);
void OnMsgGetRootWindowRect(gfx::NativeViewId window_id, gfx::Rect* results);
- void OnAllocateFakePluginWindowHandle(gfx::PluginWindowHandle* id);
+ void OnAllocateFakePluginWindowHandle(bool opaque,
+ gfx::PluginWindowHandle* id);
void OnDestroyFakePluginWindowHandle(gfx::PluginWindowHandle id);
void OnAcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
int32 width,
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index 7b516ed..6e5e28e 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -190,7 +190,8 @@ class RenderWidgetHostView {
virtual void WindowFrameChanged() = 0;
// Methods associated with GPU-accelerated plug-in instances.
- virtual gfx::PluginWindowHandle AllocateFakePluginWindowHandle() = 0;
+ virtual gfx::PluginWindowHandle AllocateFakePluginWindowHandle(
+ bool opaque) = 0;
virtual void DestroyFakePluginWindowHandle(
gfx::PluginWindowHandle window) = 0;
virtual void AcceleratedSurfaceSetIOSurface(
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index 61bc7e5..5fa2d68 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -146,7 +146,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
virtual bool ContainsNativeView(gfx::NativeView native_view) const;
// Methods associated with GPU-accelerated plug-in instances.
- virtual gfx::PluginWindowHandle AllocateFakePluginWindowHandle();
+ virtual gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque);
virtual void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
virtual void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
int32 width,
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index c27da76..5acfc4f 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -557,11 +557,11 @@ void RenderWidgetHostViewMac::IMECleanupComposition() {
}
gfx::PluginWindowHandle
-RenderWidgetHostViewMac::AllocateFakePluginWindowHandle() {
+RenderWidgetHostViewMac::AllocateFakePluginWindowHandle(bool opaque) {
// Make sure we have a layer for the plugin to draw into.
[cocoa_view_ ensureAcceleratedPluginLayer];
- return plugin_container_manager_.AllocateFakePluginWindowHandle();
+ return plugin_container_manager_.AllocateFakePluginWindowHandle(opaque);
}
void RenderWidgetHostViewMac::DestroyFakePluginWindowHandle(
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.cc b/chrome/browser/renderer_host/test/test_render_view_host.cc
index fcf4d8b..fd6feeb 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.cc
+++ b/chrome/browser/renderer_host/test/test_render_view_host.cc
@@ -100,7 +100,7 @@ void TestRenderWidgetHostView::SetActive(bool active) {
}
gfx::PluginWindowHandle
-TestRenderWidgetHostView::AllocateFakePluginWindowHandle() {
+TestRenderWidgetHostView::AllocateFakePluginWindowHandle(bool opaque) {
return NULL;
}
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h
index a43af51..2725bb3 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.h
+++ b/chrome/browser/renderer_host/test/test_render_view_host.h
@@ -82,7 +82,8 @@ class TestRenderWidgetHostView : public RenderWidgetHostView {
virtual void SetActive(bool active);
virtual void SetWindowVisibility(bool visible) {}
virtual void WindowFrameChanged() {}
- virtual gfx::PluginWindowHandle AllocateFakePluginWindowHandle();
+ virtual gfx::PluginWindowHandle AllocateFakePluginWindowHandle(
+ bool opaque);
virtual void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
virtual void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
int32 width,
diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h
index 4812d87..87a7e48 100644
--- a/chrome/common/plugin_messages_internal.h
+++ b/chrome/common/plugin_messages_internal.h
@@ -424,8 +424,10 @@ IPC_BEGIN_MESSAGES(PluginHost)
// Synthesize a fake window handle for the plug-in to identify the instance
// to the browser, allowing mapping to a surface for hardware accelleration
// of plug-in content. The browser generates the handle which is then set on
- // the plug-in.
- IPC_MESSAGE_ROUTED0(PluginHostMsg_BindFakePluginWindowHandle)
+ // the plug-in. |opaque| indicates whether the content should be treated as
+ // opaque.
+ IPC_MESSAGE_ROUTED1(PluginHostMsg_BindFakePluginWindowHandle,
+ bool /* opaque */)
// This message, used only on 10.6 and later, is sent from the plug-in process
// to the renderer process to indicate that the plugin allocated a new
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index bbfd9d1..75c10e8 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1902,8 +1902,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
// This is sent from the renderer to the browser to allocate a fake
// PluginWindowHandle on the browser side which is used to identify
// the plugin to the browser later when backing store is allocated
- // or reallocated.
- IPC_SYNC_MESSAGE_ROUTED0_1(ViewHostMsg_AllocateFakePluginWindowHandle,
+ // or reallocated. |opaque| indicates whether the plugin's output is
+ // considered to be opaque, as opposed to translucent.
+ IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_AllocateFakePluginWindowHandle,
+ bool /* opaque */,
gfx::PluginWindowHandle /* id */)
// Destroys a fake window handle previously allocated using
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index c3654e8..9ff6224 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -580,8 +580,8 @@ void WebPluginProxy::SetDeferResourceLoading(unsigned long resource_id,
}
#if defined(OS_MACOSX)
-void WebPluginProxy::BindFakePluginWindowHandle() {
- Send(new PluginHostMsg_BindFakePluginWindowHandle(route_id_));
+void WebPluginProxy::BindFakePluginWindowHandle(bool opaque) {
+ Send(new PluginHostMsg_BindFakePluginWindowHandle(route_id_, opaque));
}
void WebPluginProxy::AcceleratedFrameBuffersDidSwap(
diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h
index f03de96..b7800e3 100644
--- a/chrome/plugin/webplugin_proxy.h
+++ b/chrome/plugin/webplugin_proxy.h
@@ -134,7 +134,7 @@ class WebPluginProxy : public webkit_glue::WebPlugin {
gfx::NativeViewId containing_window() { return containing_window_; }
#if defined(OS_MACOSX)
- virtual void BindFakePluginWindowHandle();
+ virtual void BindFakePluginWindowHandle(bool opaque);
virtual void AcceleratedFrameBuffersDidSwap(gfx::PluginWindowHandle window);
virtual void SetAcceleratedSurface(gfx::PluginWindowHandle window,
int32 width,
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index a733079..bf866ce 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -4851,10 +4851,11 @@ void RenderView::EnsureDocumentTag() {
}
#if defined(OS_MACOSX)
-gfx::PluginWindowHandle RenderView::AllocateFakePluginWindowHandle() {
+gfx::PluginWindowHandle RenderView::AllocateFakePluginWindowHandle(
+ bool opaque) {
gfx::PluginWindowHandle window = NULL;
Send(new ViewHostMsg_AllocateFakePluginWindowHandle(
- routing_id(), &window));
+ routing_id(), opaque, &window));
return window;
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 14bf4bb..7277752 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -490,7 +490,7 @@ class RenderView : public RenderWidget,
#if defined(OS_MACOSX)
// Helper routines for GPU plugin support. Used by the
// WebPluginDelegateProxy, which has a pointer to the RenderView.
- gfx::PluginWindowHandle AllocateFakePluginWindowHandle();
+ gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque);
void DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window);
void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
int32 width,
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index 59843ad..ef2f3f9 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -1336,8 +1336,8 @@ WebPluginDelegateProxy::CreateSeekableResourceClient(
}
#if defined(OS_MACOSX)
-void WebPluginDelegateProxy::OnBindFakePluginWindowHandle() {
- BindFakePluginWindowHandle();
+void WebPluginDelegateProxy::OnBindFakePluginWindowHandle(bool opaque) {
+ BindFakePluginWindowHandle(opaque);
}
// Synthesize a fake window handle for the plug-in to identify the instance
@@ -1345,10 +1345,10 @@ void WebPluginDelegateProxy::OnBindFakePluginWindowHandle() {
// of plug-in content. The browser generates the handle which is then set on
// the plug-in. Returns true if it successfully sets the window handle on the
// plug-in.
-bool WebPluginDelegateProxy::BindFakePluginWindowHandle() {
+bool WebPluginDelegateProxy::BindFakePluginWindowHandle(bool opaque) {
gfx::PluginWindowHandle fake_window = NULL;
if (render_view_)
- fake_window = render_view_->AllocateFakePluginWindowHandle();
+ fake_window = render_view_->AllocateFakePluginWindowHandle(opaque);
// If we aren't running on 10.6, this allocation will fail.
if (!fake_window)
return false;
@@ -1382,7 +1382,7 @@ bool WebPluginDelegateProxy::BindFakePluginWindowHandle() {
CommandBufferProxy* WebPluginDelegateProxy::CreateCommandBuffer() {
#if defined(ENABLE_GPU)
#if defined(OS_MACOSX)
- if (!BindFakePluginWindowHandle())
+ if (!BindFakePluginWindowHandle(true))
return NULL;
#endif
int command_buffer_id;
diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h
index b7b73b8..ae5b4f1 100644
--- a/chrome/renderer/webplugin_delegate_proxy.h
+++ b/chrome/renderer/webplugin_delegate_proxy.h
@@ -149,7 +149,7 @@ class WebPluginDelegateProxy
void OnDeferResourceLoading(unsigned long resource_id, bool defer);
#if defined(OS_MACOSX)
- void OnBindFakePluginWindowHandle();
+ void OnBindFakePluginWindowHandle(bool opaque);
void OnUpdateGeometry_ACK(int ack_key);
void OnAcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
int32 width,
@@ -194,7 +194,7 @@ class WebPluginDelegateProxy
// of plug-in content. The browser generates the handle which is then set on
// the plug-in. Returns true if it successfully sets the window handle on the
// plug-in.
- bool BindFakePluginWindowHandle();
+ bool BindFakePluginWindowHandle(bool opaque);
// The Mac TransportDIB implementation uses base::SharedMemory, which
// cannot be disposed of if an in-flight UpdateGeometry message refers to
diff --git a/webkit/glue/plugins/webplugin.h b/webkit/glue/plugins/webplugin.h
index cde5fce..1813842 100644
--- a/webkit/glue/plugins/webplugin.h
+++ b/webkit/glue/plugins/webplugin.h
@@ -148,8 +148,9 @@ class WebPlugin {
// Synthesize a fake window handle for the plug-in to identify the instance
// to the browser, allowing mapping to a surface for hardware accelleration
// of plug-in content. The browser generates the handle which is then set on
- // the plug-in.
- virtual void BindFakePluginWindowHandle() {}
+ // the plug-in. |opaque| indicates whether the content should be treated as
+ // opaque or translucent.
+ virtual void BindFakePluginWindowHandle(bool opaque) {}
// Tell the browser (via the renderer) to invalidate because the
// accelerated buffers have changed.
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index a2ee61d..13ef782 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -294,7 +294,7 @@ bool WebPluginDelegateImpl::PlatformInitialize() {
reinterpret_cast<void*>(&layer));
if (!err) {
layer_ = layer;
- plugin_->BindFakePluginWindowHandle();
+ plugin_->BindFakePluginWindowHandle(false);
surface_ = new AcceleratedSurface;
surface_->Initialize(NULL, true);
renderer_ = [[CARenderer rendererWithCGLContext:surface_->context()