Inform webkit when PPAPI plugin contents are opaque.
Most plugins want to be opaque, and notifying webkit of that will allow it to avoid rendering tiles behind the plugin and doing alpha blending. BUG=116205 TEST= Review URL: http://codereview.chromium.org/9580030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125100 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -21,6 +21,7 @@ PlatformContext3DImpl::PlatformContext3DImpl(
|
||||
PepperParentContextProvider* parent_context_provider)
|
||||
: parent_context_provider_(parent_context_provider),
|
||||
parent_texture_id_(0),
|
||||
has_alpha_(false),
|
||||
command_buffer_(NULL),
|
||||
weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
|
||||
}
|
||||
@ -98,6 +99,9 @@ bool PlatformContext3DImpl::Init(const int32* attrib_list) {
|
||||
case ContentGLContext::HEIGHT:
|
||||
surface_size.set_height(attr[1]);
|
||||
break;
|
||||
case ContentGLContext::ALPHA_SIZE:
|
||||
has_alpha_ = attr[1] > 0;
|
||||
// fall-through
|
||||
default:
|
||||
attribs.push_back(attr[0]);
|
||||
attribs.push_back(attr[1]);
|
||||
@ -152,6 +156,11 @@ unsigned PlatformContext3DImpl::GetBackingTextureId() {
|
||||
return parent_texture_id_;
|
||||
}
|
||||
|
||||
bool PlatformContext3DImpl::IsOpaque() {
|
||||
DCHECK(command_buffer_);
|
||||
return !has_alpha_;
|
||||
}
|
||||
|
||||
gpu::CommandBuffer* PlatformContext3DImpl::GetCommandBuffer() {
|
||||
return command_buffer_;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ class PlatformContext3DImpl
|
||||
|
||||
virtual bool Init(const int32* attrib_list) OVERRIDE;
|
||||
virtual unsigned GetBackingTextureId() OVERRIDE;
|
||||
virtual bool IsOpaque() OVERRIDE;
|
||||
virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE;
|
||||
virtual int GetCommandBufferRouteId() OVERRIDE;
|
||||
virtual void SetContextLostCallback(const base::Closure& callback) OVERRIDE;
|
||||
@ -47,6 +48,7 @@ class PlatformContext3DImpl
|
||||
base::WeakPtr<ContentGLContext> parent_context_;
|
||||
scoped_refptr<GpuChannelHost> channel_;
|
||||
unsigned int parent_texture_id_;
|
||||
bool has_alpha_;
|
||||
CommandBufferProxy* command_buffer_;
|
||||
base::Closure context_lost_callback_;
|
||||
base::WeakPtrFactory<PlatformContext3DImpl> weak_ptr_factory_;
|
||||
|
@ -171,6 +171,9 @@ class PluginDelegate {
|
||||
// compositors namespace. Otherwise return 0. Returns 0 by default.
|
||||
virtual unsigned GetBackingTextureId() = 0;
|
||||
|
||||
// Returns true if the backing texture is always opaque.
|
||||
virtual bool IsOpaque() = 0;
|
||||
|
||||
// This call will return the address of the command buffer for this context
|
||||
// that is constructed in Initialize() and is valid until this context is
|
||||
// destroyed.
|
||||
|
@ -1623,7 +1623,7 @@ PPB_Graphics3D_Impl* PluginInstance::GetBoundGraphics3D() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void PluginInstance::setBackingTextureId(unsigned int id) {
|
||||
void PluginInstance::setBackingTextureId(unsigned int id, bool is_opaque) {
|
||||
// If we have a fullscreen_container_ (under PPB_FlashFullscreen)
|
||||
// or desired_fullscreen_state is true (under PPB_Fullscreen),
|
||||
// then the plugin is fullscreen or transitioning to fullscreen
|
||||
@ -1636,8 +1636,10 @@ void PluginInstance::setBackingTextureId(unsigned int id) {
|
||||
if (fullscreen_container_ || desired_fullscreen_state_)
|
||||
return;
|
||||
|
||||
if (container_)
|
||||
if (container_) {
|
||||
container_->setBackingTextureId(id);
|
||||
container_->setOpaque(is_opaque);
|
||||
}
|
||||
}
|
||||
|
||||
void PluginInstance::AddPluginObject(PluginObject* plugin_object) {
|
||||
@ -1713,7 +1715,7 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
|
||||
|
||||
// Special-case clearing the current device.
|
||||
if (!device) {
|
||||
setBackingTextureId(0);
|
||||
setBackingTextureId(0, false);
|
||||
InvalidateRect(gfx::Rect());
|
||||
return PP_TRUE;
|
||||
}
|
||||
@ -1738,7 +1740,7 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
|
||||
return PP_FALSE; // Can't bind to more than one instance.
|
||||
|
||||
bound_graphics_ = graphics_2d;
|
||||
setBackingTextureId(0);
|
||||
setBackingTextureId(0, graphics_2d->is_always_opaque());
|
||||
// BindToInstance will have invalidated the plugin if necessary.
|
||||
} else if (graphics_3d) {
|
||||
// Make sure graphics can only be bound to the instance it is
|
||||
@ -1749,7 +1751,8 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance,
|
||||
return PP_FALSE;
|
||||
|
||||
bound_graphics_ = graphics_3d;
|
||||
setBackingTextureId(graphics_3d->GetBackingTextureId());
|
||||
setBackingTextureId(graphics_3d->GetBackingTextureId(),
|
||||
graphics_3d->IsOpaque());
|
||||
} else {
|
||||
// The device is not a valid resource type.
|
||||
return PP_FALSE;
|
||||
|
@ -438,7 +438,8 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
|
||||
// Sets the id of the texture that the plugin draws to. The id is in the
|
||||
// compositor space so it can use it to composite with rest of the page.
|
||||
// A value of zero indicates the plugin is not backed by a texture.
|
||||
void setBackingTextureId(unsigned int id);
|
||||
// is_opaque is true if the plugin contents are always opaque.
|
||||
void setBackingTextureId(unsigned int id, bool is_opaque);
|
||||
|
||||
// Internal helper function for PrintPage().
|
||||
bool PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges,
|
||||
|
@ -140,6 +140,10 @@ unsigned int PPB_Graphics3D_Impl::GetBackingTextureId() {
|
||||
return platform_context_->GetBackingTextureId();
|
||||
}
|
||||
|
||||
bool PPB_Graphics3D_Impl::IsOpaque() {
|
||||
return platform_context_->IsOpaque();
|
||||
}
|
||||
|
||||
void PPB_Graphics3D_Impl::ViewWillInitiatePaint() {
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,9 @@ class PPB_Graphics3D_Impl : public ::ppapi::PPB_Graphics3D_Shared {
|
||||
// Returns the id of texture that can be used by the compositor.
|
||||
unsigned int GetBackingTextureId();
|
||||
|
||||
// Returns true if the backing texture is always opaque.
|
||||
bool IsOpaque();
|
||||
|
||||
// Notifications about the view's progress painting. See PluginInstance.
|
||||
// These messages are used to send Flush callbacks to the plugin.
|
||||
void ViewWillInitiatePaint();
|
||||
|
Reference in New Issue
Block a user