[BlackBerry] Don't use WebKit thread scale information in WebPageCompositor.

https://bugs.webkit.org/show_bug.cgi?id=113447
Internal PR 313452

Patch by Jakob Petsovits <jpetsovits@blackberry.com> on 2013-03-28
Reviewed by Rob Buis.

Potential threading problems are avoided by moving from
WebPage members and mapToTransformed() to the web page
client's userInterfaceViewportAccessor().

As part of this cleaning effort, the WebPageCompositor's
render() method is changed to now take document instead of
pixel coordinates.

* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::compositeContents):
* Api/WebPageCompositor.cpp:
(BlackBerry::WebKit::WebPageCompositorPrivate::render):
(BlackBerry::WebKit::WebPageCompositor::render):
* Api/WebPageCompositor.h:
* Api/WebPageCompositor_p.h:
(WebPageCompositorPrivate):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147136 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2113254c
......@@ -1410,12 +1410,15 @@ void BackingStorePrivate::blitVisibleContents(bool force)
}
#if USE(ACCELERATED_COMPOSITING)
void BackingStorePrivate::compositeContents(WebCore::LayerRenderer* layerRenderer, const WebCore::TransformationMatrix& transform, const WebCore::FloatRect& contents, bool contentsOpaque)
void BackingStorePrivate::compositeContents(WebCore::LayerRenderer* layerRenderer, const WebCore::TransformationMatrix& transform, const WebCore::FloatRect& documentContents, 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));
transformedContents.intersect(transformedContentsRect);
if (transformedContents.isEmpty())
Platform::ViewportAccessor* viewportAccessor = m_webPage->client()->userInterfaceViewportAccessor();
if (!viewportAccessor)
return;
Platform::IntRect pixelContents = viewportAccessor->roundToPixelFromDocumentContents(documentContents);
pixelContents.intersect(viewportAccessor->pixelContentsRect());
if (pixelContents.isEmpty())
return;
if (!isActive())
......@@ -1428,19 +1431,18 @@ void BackingStorePrivate::compositeContents(WebCore::LayerRenderer* layerRendere
TileMap currentMap = geometry->tileMap();
Vector<TileBuffer*> compositedTiles;
Platform::IntRectRegion transformedContentsRegion = transformedContents;
Platform::IntRectRegion pixelContentsRegion = pixelContents;
Platform::IntRectRegion backingStoreRegion = geometry->backingStoreRect();
Platform::IntRectRegion clearRegion
= Platform::IntRectRegion::subtractRegions(transformedContentsRegion, backingStoreRegion);
Platform::IntRectRegion clearRegion = Platform::IntRectRegion::subtractRegions(pixelContentsRegion, backingStoreRegion);
// Clear those parts that are not covered by the backingStoreRect.
Color clearColor(Color::white);
std::vector<Platform::IntRect> clearRects = clearRegion.rects();
for (size_t i = 0; i < clearRects.size(); ++i)
layerRenderer->drawColor(transform, m_webPage->d->mapFromTransformedFloatRect(WebCore::IntRect(clearRects.at(i))), clearColor);
layerRenderer->drawColor(transform, viewportAccessor->documentFromPixelContents(clearRects.at(i)), clearColor);
// Get the list of tile rects that makeup the content.
TileRectList tileRectList = mapFromPixelContentsToTiles(transformedContents, geometry);
TileRectList tileRectList = mapFromPixelContentsToTiles(pixelContents, geometry);
for (size_t i = 0; i < tileRectList.size(); ++i) {
TileRect tileRect = tileRectList[i];
TileIndex index = tileRect.first;
......@@ -1448,10 +1450,10 @@ void BackingStorePrivate::compositeContents(WebCore::LayerRenderer* layerRendere
TileBuffer* tileBuffer = currentMap.get(index);
if (!tileBuffer || !geometry->isTileCorrespondingToBuffer(index, tileBuffer))
layerRenderer->drawColor(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(dirtyRect)), clearColor);
layerRenderer->drawColor(transform, viewportAccessor->documentFromPixelContents(dirtyRect), clearColor);
else {
Platform::IntPoint tileOrigin = tileBuffer->lastRenderOrigin();
Platform::FloatRect tileDocumentContentsRect = m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(tileBuffer->pixelContentsRect()));
Platform::FloatRect tileDocumentContentsRect = viewportAccessor->documentFromPixelContents(tileBuffer->pixelContentsRect());
layerRenderer->compositeBuffer(transform, tileDocumentContentsRect, tileBuffer->nativeBuffer(), contentsOpaque, 1.0f);
compositedTiles.append(tileBuffer);
......@@ -1462,7 +1464,7 @@ void BackingStorePrivate::compositeContents(WebCore::LayerRenderer* layerRendere
for (size_t i = 0; i < notRenderedRects.size(); ++i) {
Platform::IntRect tileSurfaceRect = notRenderedRects.at(i);
tileSurfaceRect.move(-tileOrigin.x(), -tileOrigin.y());
layerRenderer->drawColor(transform, m_webPage->d->mapFromTransformedFloatRect(Platform::FloatRect(tileSurfaceRect)), clearColor);
layerRenderer->drawColor(transform, viewportAccessor->documentFromPixelContents(tileSurfaceRect), clearColor);
}
}
}
......
......@@ -145,7 +145,7 @@ void WebPageCompositorPrivate::prepareFrame(double animationTime)
m_layerRenderer->prepareFrame(animationTime, m_compositingThreadOverlayLayer.get());
}
void WebPageCompositorPrivate::render(const IntRect& targetRect, const IntRect& clipRect, const TransformationMatrix& transformIn, const FloatRect& transformedContents, const FloatRect& /*viewport*/)
void WebPageCompositorPrivate::render(const IntRect& targetRect, const IntRect& clipRect, const TransformationMatrix& transformIn, const FloatRect& documentContents, const FloatRect& /*viewport*/)
{
// m_layerRenderer should have been created in prepareFrame
if (!m_layerRenderer)
......@@ -158,16 +158,13 @@ void WebPageCompositorPrivate::render(const IntRect& targetRect, const IntRect&
if (!m_webPage || m_webPage->compositor() != this)
return;
FloatRect contents = m_webPage->mapFromTransformedFloatRect(transformedContents);
m_layerRenderer->setViewport(targetRect, clipRect, contents, m_layoutRect, m_documentRect.size());
m_layerRenderer->setViewport(targetRect, clipRect, documentContents, m_layoutRect, m_documentRect.size());
TransformationMatrix transform(transformIn);
transform *= *m_webPage->m_transformationMatrix;
transform.translate(-m_documentRect.x(), -m_documentRect.y());
if (!drawsRootLayer())
m_webPage->m_backingStore->d->compositeContents(m_layerRenderer.get(), transform, contents, !m_backgroundColor.hasAlpha());
m_webPage->m_backingStore->d->compositeContents(m_layerRenderer.get(), transform, documentContents, !m_backgroundColor.hasAlpha());
compositeLayers(transform);
}
......@@ -331,15 +328,10 @@ void WebPageCompositor::prepareFrame(Platform::Graphics::GLES2Context* context,
d->prepareFrame(animationTime);
}
void WebPageCompositor::render(Platform::Graphics::GLES2Context* context,
const Platform::IntRect& targetRect,
const Platform::IntRect& clipRect,
const Platform::TransformationMatrix& transform,
const Platform::FloatRect& contents,
const Platform::FloatRect& viewport)
void WebPageCompositor::render(Platform::Graphics::GLES2Context* context, const Platform::IntRect& targetRect, const Platform::IntRect& clipRect, const Platform::TransformationMatrix& transform, const Platform::FloatRect& documentContents, const Platform::FloatRect& viewport)
{
d->setContext(context);
d->render(targetRect, clipRect, TransformationMatrix(reinterpret_cast<const TransformationMatrix&>(transform)), contents, viewport);
d->render(targetRect, clipRect, TransformationMatrix(reinterpret_cast<const TransformationMatrix&>(transform)), documentContents, viewport);
}
void WebPageCompositor::cleanup(Platform::Graphics::GLES2Context* context)
......
......@@ -54,7 +54,7 @@ public:
const Platform::IntRect& targetRect,
const Platform::IntRect& clipRect,
const Platform::TransformationMatrix&,
const Platform::FloatRect& contents,
const Platform::FloatRect& documentContents,
const Platform::FloatRect& viewport);
void cleanup(Platform::Graphics::GLES2Context*);
......
......@@ -61,7 +61,7 @@ public:
void render(const WebCore::IntRect& targetRect,
const WebCore::IntRect& clipRect,
const WebCore::TransformationMatrix&,
const WebCore::FloatRect& contents, // This is public API, thus takes transformed contents
const WebCore::FloatRect& documentContents,
const WebCore::FloatRect& viewport);
Platform::Graphics::GLES2Context* context() const { return m_context; }
......
2013-03-28 Jakob Petsovits <jpetsovits@blackberry.com>
[BlackBerry] Don't use WebKit thread scale information in WebPageCompositor.
https://bugs.webkit.org/show_bug.cgi?id=113447
Internal PR 313452
Reviewed by Rob Buis.
Potential threading problems are avoided by moving from
WebPage members and mapToTransformed() to the web page
client's userInterfaceViewportAccessor().
As part of this cleaning effort, the WebPageCompositor's
render() method is changed to now take document instead of
pixel coordinates.
* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::compositeContents):
* Api/WebPageCompositor.cpp:
(BlackBerry::WebKit::WebPageCompositorPrivate::render):
(BlackBerry::WebKit::WebPageCompositor::render):
* Api/WebPageCompositor.h:
* Api/WebPageCompositor_p.h:
(WebPageCompositorPrivate):
2013-03-28 Matt Falkenhagen <falken@chromium.org>
Refactoring: Replace Element::disabled and isEnabledFormControl with isDisabledFormControl
......
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