[BlackBerry] Allow WebPageCompositor to blend a transparent web page

https://bugs.webkit.org/show_bug.cgi?id=88233

Patch by Arvid Nilsson <anilsson@rim.com> on 2012-06-07
Reviewed by Rob Buis.

RIM PR #159998

Source/WebCore:

Add a parameter to LayerRenderer::compositeBuffer() indicating whether
the buffer contents are opaque, and set the GL blend mode accordingly.

This is not currently testable using BlackBerry testing infrastructure.

Reviewed internally by Jakob Petsovits.

* platform/graphics/blackberry/LayerRenderer.cpp:
(WebCore::LayerRenderer::compositeBuffer):
* platform/graphics/blackberry/LayerRenderer.h:
(LayerRenderer):

Source/WebKit/blackberry:

Keep track of the web page background color in the compositor so we can
determine whether the contents of the root layer are transparent.

Reviewed internally by Jakob Petsovits.

* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::compositeContents):
* Api/BackingStore_p.h:
(BackingStorePrivate):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::setCompositor):
(BlackBerry::WebKit::WebPagePrivate::setCompositorBackgroundColor):
(WebKit):
(BlackBerry::WebKit::WebPagePrivate::createCompositor):
(BlackBerry::WebKit::WebPagePrivate::didChangeSettings):
* Api/WebPageCompositor.cpp:
(BlackBerry::WebKit::WebPageCompositorPrivate::render):
(BlackBerry::WebKit::WebPageCompositorPrivate::setBackgroundColor):
(WebKit):
* Api/WebPageCompositor_p.h:
(BlackBerry::WebKit::WebPageCompositorPrivate::backgroundColor):
(WebPageCompositorPrivate):
* Api/WebPage_p.h:
(WebPagePrivate):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0022a7f3
2012-06-07 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] Allow WebPageCompositor to blend a transparent web page
https://bugs.webkit.org/show_bug.cgi?id=88233
Reviewed by Rob Buis.
RIM PR #159998
Add a parameter to LayerRenderer::compositeBuffer() indicating whether
the buffer contents are opaque, and set the GL blend mode accordingly.
This is not currently testable using BlackBerry testing infrastructure.
Reviewed internally by Jakob Petsovits.
* platform/graphics/blackberry/LayerRenderer.cpp:
(WebCore::LayerRenderer::compositeBuffer):
* platform/graphics/blackberry/LayerRenderer.h:
(LayerRenderer):
2012-06-07 Alexei Filippov <alexeif@chromium.org>
Web Inspector: reuse edge_count field of heap snapshot to store retained size
......
......@@ -402,7 +402,7 @@ void LayerRenderer::compositeLayers(const TransformationMatrix& matrix, LayerCom
static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0 };
void LayerRenderer::compositeBuffer(const TransformationMatrix& transform, const FloatRect& contents, BlackBerry::Platform::Graphics::Buffer* buffer, float opacity)
void LayerRenderer::compositeBuffer(const TransformationMatrix& transform, const FloatRect& contents, BlackBerry::Platform::Graphics::Buffer* buffer, bool contentsOpaque, float opacity)
{
if (!buffer)
return;
......@@ -415,7 +415,8 @@ void LayerRenderer::compositeBuffer(const TransformationMatrix& transform, const
if (!vertices.boundingBox().intersects(m_clipRect))
return;
if (opacity < 1.0f) {
bool blending = !contentsOpaque || opacity < 1.0f;
if (blending) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
......@@ -431,7 +432,7 @@ void LayerRenderer::compositeBuffer(const TransformationMatrix& transform, const
BlackBerry::Platform::Graphics::releaseBufferGLTexture(buffer);
}
if (opacity < 1.0f)
if (blending)
glDisable(GL_BLEND);
}
......
......@@ -106,7 +106,7 @@ public:
// 3. Prepares all the layers for compositing
// transform is the model-view-project matrix that goes all the way from contents to normalized device coordinates.
void compositeLayers(const TransformationMatrix&, LayerCompositingThread* rootLayer);
void compositeBuffer(const TransformationMatrix&, const FloatRect& contents, BlackBerry::Platform::Graphics::Buffer*, float opacity);
void compositeBuffer(const TransformationMatrix&, const FloatRect& contents, BlackBerry::Platform::Graphics::Buffer*, bool contentsOpaque, float opacity);
void drawCheckerboardPattern(const TransformationMatrix&, const FloatRect& contents);
// Keep track of layers that need cleanup when the LayerRenderer is destroyed
......
......@@ -1637,7 +1637,7 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
}
#if USE(ACCELERATED_COMPOSITING)
void BackingStorePrivate::compositeContents(WebCore::LayerRenderer* layerRenderer, const WebCore::TransformationMatrix& transform, const WebCore::FloatRect& contents)
void BackingStorePrivate::compositeContents(WebCore::LayerRenderer* layerRenderer, const WebCore::TransformationMatrix& transform, const WebCore::FloatRect& contents, bool contentsOpaque)
{
const Platform::IntRect transformedContentsRect = Platform::IntRect(Platform::IntPoint(0, 0), m_client->transformedContentsSize());
Platform::IntRect transformedContents = enclosingIntRect(m_webPage->d->m_transformationMatrix->mapRect(contents));
......@@ -1691,7 +1691,7 @@ void BackingStorePrivate::compositeContents(WebCore::LayerRenderer* layerRendere
if (!committed)
layerRenderer->drawCheckerboardPattern(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(dirtyRect)));
else {
layerRenderer->compositeBuffer(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(wholeRect)), tileBuffer->nativeBuffer(), 1.0f);
layerRenderer->compositeBuffer(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(wholeRect)), tileBuffer->nativeBuffer(), contentsOpaque, 1.0f);
// Intersect the rendered region.
Platform::IntRectRegion notRenderedRegion = Platform::IntRectRegion::subtractRegions(dirtyTileRect, tileBuffer->renderedRegion());
......
......@@ -202,7 +202,7 @@ public:
// Note that contents is expressed in untransformed content coordinates.
// Preconditions: You have to call prepareFrame and setViewport on the LayerRenderer before
// calling this.
void compositeContents(WebCore::LayerRenderer*, const WebCore::TransformationMatrix&, const WebCore::FloatRect& contents);
void compositeContents(WebCore::LayerRenderer*, const WebCore::TransformationMatrix&, const WebCore::FloatRect& contents, bool contentsOpaque);
void blendCompositingSurface(const Platform::IntRect& dstRect);
void clearCompositingSurface();
......
......@@ -5731,14 +5731,23 @@ void WebPagePrivate::setCompositor(PassRefPtr<WebPageCompositorPrivate> composit
}
m_compositor = compositor;
if (m_compositor)
if (m_compositor) {
m_compositor->setPage(this);
m_compositor->setBackgroundColor(m_webSettings->backgroundColor());
}
// The previous compositor, if any, has now released it's OpenGL resources,
// so we can safely free the owned context, if any.
m_ownedContext.clear();
}
void WebPagePrivate::setCompositorBackgroundColor(const Color& backgroundColor)
{
if (m_compositor)
m_compositor->setBackgroundColor(backgroundColor);
}
void WebPagePrivate::commitRootLayer(const IntRect& layoutRectForCompositing,
const IntSize& contentsSizeForCompositing,
bool drawsRootLayer)
......@@ -5972,6 +5981,10 @@ bool WebPagePrivate::createCompositor()
m_compositor = WebPageCompositorPrivate::create(this, 0);
m_compositor->setContext(m_ownedContext.get());
// The compositor is created in a sync message, so there's no risk of race condition on the
// WebSettings.
m_compositor->setBackgroundColor(m_webSettings->backgroundColor());
return true;
}
......@@ -6270,6 +6283,9 @@ void WebPagePrivate::didChangeSettings(WebSettings* webSettings)
if (m_mainFrame && m_mainFrame->view()) {
Color backgroundColor(webSettings->backgroundColor());
m_mainFrame->view()->updateBackgroundRecursively(backgroundColor, backgroundColor.hasAlpha());
Platform::userInterfaceThreadMessageClient()->dispatchMessage(
createMethodCallMessage(&WebPagePrivate::setCompositorBackgroundColor, this, backgroundColor));
}
}
......
......@@ -129,7 +129,7 @@ void WebPageCompositorPrivate::render(const IntRect& targetRect, const IntRect&
transform *= *m_webPage->m_transformationMatrix;
if (!drawsRootLayer())
m_webPage->m_backingStore->d->compositeContents(m_layerRenderer.get(), transform, contents);
m_webPage->m_backingStore->d->compositeContents(m_layerRenderer.get(), transform, contents, !m_backgroundColor.hasAlpha());
compositeLayers(transform);
}
......@@ -192,6 +192,11 @@ bool WebPageCompositorPrivate::drawLayers(const IntRect& dstRect, const FloatRec
return true;
}
void WebPageCompositorPrivate::setBackgroundColor(const Color& color)
{
m_backgroundColor = color;
}
void WebPageCompositorPrivate::releaseLayerResources()
{
if (m_layerRenderer)
......
......@@ -84,6 +84,9 @@ public:
WebCore::LayerRenderingResults lastCompositingResults() const { return m_lastCompositingResults; }
void setLastCompositingResults(const WebCore::LayerRenderingResults& results) { m_lastCompositingResults = results; }
WebCore::Color backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(const WebCore::Color&);
void releaseLayerResources();
WebPagePrivate* page() const { return m_webPage; }
......@@ -111,6 +114,7 @@ private:
WebCore::IntRect m_layoutRectForCompositing;
WebCore::IntSize m_contentsSizeForCompositing;
WebCore::LayerRenderingResults m_lastCompositingResults;
WebCore::Color m_backgroundColor;
bool m_drawsRootLayer;
};
......
......@@ -396,6 +396,7 @@ public:
bool isAcceleratedCompositingActive() const { return m_compositor; }
WebPageCompositorPrivate* compositor() const { return m_compositor.get(); }
void setCompositor(PassRefPtr<WebPageCompositorPrivate>, EGLContext compositingContext);
void setCompositorBackgroundColor(const WebCore::Color&);
bool createCompositor();
void destroyCompositor();
void syncDestroyCompositorOnCompositingThread();
......
2012-06-07 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] Allow WebPageCompositor to blend a transparent web page
https://bugs.webkit.org/show_bug.cgi?id=88233
Reviewed by Rob Buis.
RIM PR #159998
Keep track of the web page background color in the compositor so we can
determine whether the contents of the root layer are transparent.
Reviewed internally by Jakob Petsovits.
* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::compositeContents):
* Api/BackingStore_p.h:
(BackingStorePrivate):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::setCompositor):
(BlackBerry::WebKit::WebPagePrivate::setCompositorBackgroundColor):
(WebKit):
(BlackBerry::WebKit::WebPagePrivate::createCompositor):
(BlackBerry::WebKit::WebPagePrivate::didChangeSettings):
* Api/WebPageCompositor.cpp:
(BlackBerry::WebKit::WebPageCompositorPrivate::render):
(BlackBerry::WebKit::WebPageCompositorPrivate::setBackgroundColor):
(WebKit):
* Api/WebPageCompositor_p.h:
(BlackBerry::WebKit::WebPageCompositorPrivate::backgroundColor):
(WebPageCompositorPrivate):
* Api/WebPage_p.h:
(WebPagePrivate):
2012-06-07 Jonathan Dong <jonathan.dong@torchmobile.com.cn>
[BlackBerry] Add enable credential autofill and enable form autofill feature control in WebSetting
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment