summaryrefslogtreecommitdiff
path: root/Source/WebKit/blackberry/Api/BackingStore.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-10-17 16:21:14 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-10-17 16:21:14 +0200
commit8995b83bcbfbb68245f779b64e5517627c6cc6ea (patch)
tree17985605dab9263cc2444bd4d45f189e142cca7c /Source/WebKit/blackberry/Api/BackingStore.cpp
parentb9c9652036d5e9f1e29c574f40bc73a35c81ace6 (diff)
downloadqtwebkit-8995b83bcbfbb68245f779b64e5517627c6cc6ea.tar.gz
Imported WebKit commit cf4f8fc6f19b0629f51860cb2d4b25e139d07e00 (http://svn.webkit.org/repository/webkit/trunk@131592)
New snapshot that includes the build fixes for Mac OS X 10.6 and earlier as well as the previously cherry-picked changes
Diffstat (limited to 'Source/WebKit/blackberry/Api/BackingStore.cpp')
-rw-r--r--Source/WebKit/blackberry/Api/BackingStore.cpp333
1 files changed, 156 insertions, 177 deletions
diff --git a/Source/WebKit/blackberry/Api/BackingStore.cpp b/Source/WebKit/blackberry/Api/BackingStore.cpp
index be2f9ebd3..0c20cdcf4 100644
--- a/Source/WebKit/blackberry/Api/BackingStore.cpp
+++ b/Source/WebKit/blackberry/Api/BackingStore.cpp
@@ -21,6 +21,7 @@
#include "BackingStoreClient.h"
#include "BackingStoreTile.h"
+#include "BackingStoreVisualizationViewportAccessor.h"
#include "BackingStore_p.h"
#include "FatFingers.h"
#include "Frame.h"
@@ -45,6 +46,7 @@
#include <BlackBerryPlatformMessageClient.h>
#include <BlackBerryPlatformScreen.h>
#include <BlackBerryPlatformSettings.h>
+#include <BlackBerryPlatformViewportAccessor.h>
#include <BlackBerryPlatformWindow.h>
#include <SkImageDecoder.h>
@@ -138,7 +140,7 @@ static Divisor bestDivisor(Platform::IntSize size, int tileWidth, int tileHeight
if (isPerfectWidth || isPerfectHeight) {
bestDivisor = divisor; // Found a perfect fit!
#if DEBUG_TILEMATRIX
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "bestDivisor found perfect size isPerfectWidth=%s isPerfectHeight=%s",
+ BBLOG(BlackBerry::Platform::LogLevelCritical, "bestDivisor found perfect size isPerfectWidth=%s isPerfectHeight=%s",
isPerfectWidth ? "true" : "false",
isPerfectHeight ? "true" : "false");
#endif
@@ -279,15 +281,15 @@ bool BackingStorePrivate::isOpenGLCompositing() const
void BackingStorePrivate::suspendScreenAndBackingStoreUpdates()
{
if (m_suspendScreenUpdates) {
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelInfo,
+ BBLOG(BlackBerry::Platform::LogLevelInfo,
"Screen and backingstore already suspended, increasing suspend counter.");
}
++m_suspendBackingStoreUpdates;
// Make sure the user interface thread gets the message before we proceed
- // because blitContents can be called from this thread and it must honor
- // this flag.
+ // because blitVisibleContents() can be called from the user interface
+ // thread and it must honor this flag.
++m_suspendScreenUpdates;
BlackBerry::Platform::userInterfaceThreadMessageClient()->syncToCurrentMessage();
@@ -313,7 +315,7 @@ void BackingStorePrivate::resumeScreenAndBackingStoreUpdates(BackingStore::Resum
m_resumeOperation = op;
if (m_suspendScreenUpdates >= 2 && m_suspendBackingStoreUpdates >= 2) { // we're still suspended
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelInfo,
+ BBLOG(BlackBerry::Platform::LogLevelInfo,
"Screen and backingstore still suspended, decreasing suspend counter.");
--m_suspendBackingStoreUpdates;
--m_suspendScreenUpdates;
@@ -349,8 +351,8 @@ void BackingStorePrivate::resumeScreenAndBackingStoreUpdates(BackingStore::Resum
renderVisibleContents();
// Make sure the user interface thread gets the message before we proceed
- // because blitContents can be called from the user interface thread and
- // it must honor this flag.
+ // because blitVisibleContents() can be called from the user interface
+ // thread and it must honor this flag.
--m_suspendScreenUpdates;
BlackBerry::Platform::userInterfaceThreadMessageClient()->syncToCurrentMessage();
@@ -392,7 +394,7 @@ void BackingStorePrivate::repaint(const Platform::IntRect& windowRect,
return;
#if DEBUG_WEBCORE_REQUESTS
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
+ BBLOG(BlackBerry::Platform::LogLevelCritical,
"BackingStorePrivate::repaint rect=%d,%d %dx%d contentChanged=%s immediate=%s",
rect.x(), rect.y(), rect.width(), rect.height(),
(contentChanged ? "true" : "false"),
@@ -412,6 +414,8 @@ void BackingStorePrivate::repaint(const Platform::IntRect& windowRect,
void BackingStorePrivate::slowScroll(const Platform::IntSize& delta, const Platform::IntRect& windowRect, bool immediate)
{
+ ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
+
#if DEBUG_BACKINGSTORE
// Start the time measurement...
double time = WTF::currentTime();
@@ -437,7 +441,7 @@ void BackingStorePrivate::slowScroll(const Platform::IntSize& delta, const Platf
#if DEBUG_BACKINGSTORE
// Stop the time measurement.
double elapsed = WTF::currentTime() - time;
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::slowScroll elapsed=%f", elapsed);
+ BBLOG(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::slowScroll elapsed=%f", elapsed);
#endif
}
@@ -445,6 +449,8 @@ void BackingStorePrivate::scroll(const Platform::IntSize& delta,
const Platform::IntRect& scrollViewRect,
const Platform::IntRect& clipRect)
{
+ ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
+
// If we are direct rendering then we are forced to go down the slow path
// to scrolling.
if (shouldDirectRenderingToWindow()) {
@@ -468,7 +474,7 @@ void BackingStorePrivate::scroll(const Platform::IntSize& delta,
#if DEBUG_BACKINGSTORE
// Stop the time measurement.
double elapsed = WTF::currentTime() - time;
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::scroll dx=%d, dy=%d elapsed=%f", delta.width(), delta.height(), elapsed);
+ BBLOG(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::scroll dx=%d, dy=%d elapsed=%f", delta.width(), delta.height(), elapsed);
#endif
}
@@ -682,7 +688,7 @@ Platform::IntRect BackingStorePrivate::backingStoreRectForScroll(int deltaX, int
return backingStoreRect;
}
-void BackingStorePrivate::setBackingStoreRect(const Platform::IntRect& backingStoreRect)
+void BackingStorePrivate::setBackingStoreRect(const Platform::IntRect& backingStoreRect, double scale)
{
if (!m_webPage->isVisible())
return;
@@ -693,12 +699,13 @@ void BackingStorePrivate::setBackingStoreRect(const Platform::IntRect& backingSt
}
Platform::IntRect currentBackingStoreRect = frontState()->backingStoreRect();
+ double currentScale = frontState()->scale();
- if (backingStoreRect == currentBackingStoreRect)
+ if (backingStoreRect == currentBackingStoreRect && scale == currentScale)
return;
#if DEBUG_TILEMATRIX
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::setBackingStoreRect changed from (%d,%d %dx%d) to (%d,%d %dx%d)",
+ BBLOG(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::setBackingStoreRect changed from (%d,%d %dx%d) to (%d,%d %dx%d)",
currentBackingStoreRect.x(),
currentBackingStoreRect.y(),
currentBackingStoreRect.width(),
@@ -723,8 +730,8 @@ void BackingStorePrivate::setBackingStoreRect(const Platform::IntRect& backingSt
// our new backing store rect.
TileMap::const_iterator tileMapEnd = currentMap.end();
for (TileMap::const_iterator it = currentMap.begin(); it != tileMapEnd; ++it) {
- TileIndex oldIndex = it->first;
- BackingStoreTile* tile = it->second;
+ TileIndex oldIndex = it->key;
+ BackingStoreTile* tile = it->value;
// Reset the old index.
resetTile(oldIndex, tile, false /*resetBackground*/);
@@ -752,12 +759,12 @@ void BackingStorePrivate::setBackingStoreRect(const Platform::IntRect& backingSt
clearAndUpdateTileOfNotRenderedRegion(newIndex, tile, tileNotRenderedRegion, backingStoreRect);
#if DEBUG_BACKINGSTORE
Platform::IntRect extents = tileNotRenderedRegion.extents();
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::setBackingStoreRect did clear tile %d,%d %dx%d",
+ BBLOG(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::setBackingStoreRect did clear tile %d,%d %dx%d",
extents.x(), extents.y(), extents.width(), extents.height());
#endif
} else {
// Mark as needing update.
- if (!tile->frontBuffer()->isRendered()
+ if (!tile->frontBuffer()->isRendered(currentState->scale())
&& !isCurrentVisibleJob(newIndex, tile, backingStoreRect))
updateTile(origin, false /*immediate*/);
}
@@ -780,8 +787,8 @@ void BackingStorePrivate::setBackingStoreRect(const Platform::IntRect& backingSt
size_t i = 0;
TileMap::const_iterator leftOverEnd = leftOverTiles.end();
for (TileMap::const_iterator it = leftOverTiles.begin(); it != leftOverEnd; ++it) {
- TileIndex oldIndex = it->first;
- BackingStoreTile* tile = it->second;
+ TileIndex oldIndex = it->key;
+ BackingStoreTile* tile = it->value;
if (i >= indexesToFill.size()) {
ASSERT_NOT_REACHED();
break;
@@ -810,6 +817,7 @@ void BackingStorePrivate::setBackingStoreRect(const Platform::IntRect& backingSt
// Checks to make sure we haven't lost any tiles.
ASSERT(currentMap.size() == newTileMap.size());
+ backState()->setScale(scale);
backState()->setNumberOfTilesWide(backingStoreRect.width() / tileWidth());
backState()->setNumberOfTilesHigh(backingStoreRect.height() / tileHeight());
backState()->setBackingStoreOffset(backingStoreRect.location());
@@ -940,6 +948,8 @@ bool BackingStorePrivate::isCurrentVisibleJob(const TileIndex& index, BackingSto
void BackingStorePrivate::scrollBackingStore(int deltaX, int deltaY)
{
+ ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
+
if (!m_webPage->isVisible())
return;
@@ -959,7 +969,7 @@ void BackingStorePrivate::scrollBackingStore(int deltaX, int deltaY)
m_preferredTileMatrixDimension);
#if DEBUG_TILEMATRIX
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::scrollBackingStore divisor %dx%d",
+ BBLOG(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::scrollBackingStore divisor %dx%d",
divisor.first,
divisor.second);
#endif
@@ -972,7 +982,7 @@ void BackingStorePrivate::scrollBackingStore(int deltaX, int deltaY)
ASSERT(!backingStoreRect.isEmpty());
- setBackingStoreRect(backingStoreRect);
+ setBackingStoreRect(backingStoreRect, m_webPage->d->currentScale());
}
bool BackingStorePrivate::renderDirectToWindow(const Platform::IntRect& rect)
@@ -988,7 +998,7 @@ bool BackingStorePrivate::renderDirectToWindow(const Platform::IntRect& rect)
Platform::IntRect screenRect = m_client->mapFromTransformedContentsToTransformedViewport(dirtyRect);
windowFrontBufferState()->clearBlittedRegion(screenRect);
- paintDefaultBackground(dirtyRect, TransformationMatrix(), true /*flush*/);
+ paintDefaultBackground(dirtyRect, m_webPage->webkitThreadViewportAccessor(), true /*flush*/);
const Platform::IntPoint origin = unclippedVisibleContentsRect().location();
// We don't need a buffer since we're direct rendering to window.
@@ -1031,7 +1041,7 @@ bool BackingStorePrivate::render(const Platform::IntRect& rect)
return false;
#if DEBUG_BACKINGSTORE
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
+ BBLOG(BlackBerry::Platform::LogLevelCritical,
"BackingStorePrivate::render rect=(%d,%d %dx%d), m_suspendBackingStoreUpdates = %s",
rect.x(), rect.y(), rect.width(), rect.height(),
m_suspendBackingStoreUpdates ? "true" : "false");
@@ -1039,6 +1049,7 @@ bool BackingStorePrivate::render(const Platform::IntRect& rect)
BackingStoreGeometry* currentState = frontState();
TileMap currentMap = currentState->tileMap();
+ double currentScale = currentState->scale();
for (size_t i = 0; i < tileRectList.size(); ++i) {
TileRect tileRect = tileRectList[i];
@@ -1056,6 +1067,8 @@ bool BackingStorePrivate::render(const Platform::IntRect& rect)
if (!tile->backgroundPainted())
tile->paintBackground();
+ tile->backBuffer()->setScale(currentScale);
+
// Paint default background if contents rect is empty.
if (!expandedContentsRect().isEmpty()) {
// Otherwise we should clip the contents size and render the content.
@@ -1100,7 +1113,7 @@ bool BackingStorePrivate::render(const Platform::IntRect& rect)
// the rendered region of the back buffer contains the rendered region of the front buffer.
// Assert this just to make sure.
// For previously uncommitted tiles, the front buffer's rendered region is not relevant.
- ASSERT(!wasCommitted || tile->backBuffer()->isRendered(tile->frontBuffer()->renderedRegion()));
+ ASSERT(!wasCommitted || tile->backBuffer()->isRendered(tile->frontBuffer()->renderedRegion(), currentScale));
// We will need a swap here because of the shared back buffer.
tile->swapBuffers();
@@ -1141,35 +1154,6 @@ bool BackingStorePrivate::renderBackingStore()
return render(frontState()->backingStoreRect());
}
-void BackingStorePrivate::blitVisibleContents(bool force)
-{
- // Blitting must never happen for direct rendering case.
- ASSERT(!shouldDirectRenderingToWindow());
- if (shouldDirectRenderingToWindow()) {
- BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelCritical,
- "BackingStore::blitVisibleContents operation not supported in direct rendering mode");
- return;
- }
-
- if (m_suspendScreenUpdates) {
- // Avoid client going into busy loop while updates suspended.
- if (force)
- m_hasBlitJobs = false;
- return;
- }
-
- if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
- BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage(
- BlackBerry::Platform::createMethodCallMessage(
- &BackingStorePrivate::blitVisibleContents, this, force));
- return;
- }
-
- blitContents(m_webPage->client()->userInterfaceBlittedDestinationRect(),
- m_webPage->client()->userInterfaceBlittedVisibleContentsRect(),
- force);
-}
-
void BackingStorePrivate::copyPreviousContentsToBackSurfaceOfWindow()
{
Platform::IntRectRegion previousContentsRegion
@@ -1200,31 +1184,27 @@ void BackingStorePrivate::copyPreviousContentsToBackSurfaceOfTile(const Platform
}
}
-void BackingStorePrivate::paintDefaultBackground(const Platform::IntRect& contents,
- const WebCore::TransformationMatrix& transformation,
- bool flush)
+void BackingStorePrivate::paintDefaultBackground(const Platform::IntRect& dstRect, Platform::ViewportAccessor* viewportAccessor, bool flush)
{
- const Platform::IntRect contentsRect = Platform::IntRect(Platform::IntPoint(0, 0), m_webPage->d->transformedContentsSize());
- Platform::IntPoint origin = contents.location();
- Platform::IntRect contentsClipped = contents;
+ Platform::IntRect clippedDstRect = dstRect;
+
+ // Because of rounding it is possible that overScrollRect could be off-by-one larger
+ // than the surface size of the window. We prevent this here, by clamping
+ // it to ensure that can't happen.
+ clippedDstRect.intersect(Platform::IntRect(Platform::IntPoint(0, 0), surfaceSize()));
+
+ if (clippedDstRect.isEmpty())
+ return;
// We have to paint the default background in the case of overzoom and
// make sure it is invalidated.
- Platform::IntRectRegion overScrollRegion
- = Platform::IntRectRegion::subtractRegions(Platform::IntRect(contentsClipped), contentsRect);
+ const Platform::IntRect pixelContentsRect = viewportAccessor->pixelContentsRect();
+ Platform::IntRectRegion overScrollRegion = Platform::IntRectRegion::subtractRegions(
+ dstRect, viewportAccessor->pixelViewportFromContents(pixelContentsRect));
IntRectList overScrollRects = overScrollRegion.rects();
for (size_t i = 0; i < overScrollRects.size(); ++i) {
Platform::IntRect overScrollRect = overScrollRects.at(i);
- overScrollRect.move(-origin.x(), -origin.y());
- overScrollRect = transformation.mapRect(overScrollRect);
-
- if (!transformation.isIdentity()) {
- // Because of rounding it is possible that overScrollRect could be off-by-one larger
- // than the surface size of the window. We prevent this here, by clamping
- // it to ensure that can't happen.
- overScrollRect.intersect(Platform::IntRect(Platform::IntPoint(0, 0), surfaceSize()));
- }
if (m_webPage->settings()->isEnableDefaultOverScrollBackground()) {
fillWindow(BlackBerry::Platform::Graphics::DefaultBackgroundPattern,
@@ -1236,15 +1216,16 @@ void BackingStorePrivate::paintDefaultBackground(const Platform::IntRect& conten
}
}
-void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
- const Platform::IntRect& srcRect,
- bool force)
+void BackingStorePrivate::blitVisibleContents(bool force)
{
// Blitting must never happen for direct rendering case.
// Use invalidateWindow() instead.
ASSERT(!shouldDirectRenderingToWindow());
- if (shouldDirectRenderingToWindow())
+ if (shouldDirectRenderingToWindow()) {
+ BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelCritical,
+ "BackingStore::blitVisibleContents operation not supported in direct rendering mode");
return;
+ }
if (!m_webPage->isVisible() || m_suspendScreenUpdates) {
// Avoid client going into busy loop while blit is impossible.
@@ -1256,7 +1237,7 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage(
BlackBerry::Platform::createMethodCallMessage(
- &BackingStorePrivate::blitContents, this, dstRect, srcRect, force));
+ &BackingStorePrivate::blitVisibleContents, this, force));
return;
}
@@ -1277,64 +1258,76 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
m_hasBlitJobs = false;
- const Platform::IntRect contentsRect = Platform::IntRect(Platform::IntPoint(0, 0), m_client->transformedContentsSize());
+ Platform::ViewportAccessor* viewportAccessor = m_webPage->client()->userInterfaceViewportAccessor();
+ const Platform::IntRect dstRect = viewportAccessor->destinationSurfaceRect();
+
+ const Platform::IntRect pixelViewportRect = viewportAccessor->pixelViewportRect();
+ const Platform::FloatRect documentViewportRect = viewportAccessor->documentFromPixelContents(pixelViewportRect);
+ Platform::IntRect pixelSrcRect = pixelViewportRect;
+ Platform::FloatRect documentSrcRect = documentViewportRect;
#if DEBUG_VISUALIZE
- // Substitute a debugRect that consists of the union of the backingstore rect
- // and the ui thread viewport rect instead of the normal source rect so we
- // can visualize the entire backingstore and what it is doing when we
- // scroll and zoom!
- // FIXME: This should not explicitely depend on WebCore::.
- WebCore::IntRect debugRect = frontState()->backingStoreRect();
- debugRect.unite(m_webPage->client()->userInterfaceBlittedVisibleContentsRect());
- if (debugRect.width() < debugRect.height())
- debugRect.setWidth(ceil(double(srcRect.width()) * (double(debugRect.height()) / srcRect.height())));
- if (debugRect.height() < debugRect.width())
- debugRect.setHeight(ceil(double(srcRect.height()) * (double(debugRect.width()) / srcRect.width())));
- Platform::IntRect contents = debugRect;
-#else
- Platform::IntRect contents = srcRect;
+ // Substitute a srcRect that consists of the whole backingstore geometry
+ // instead of the normal viewport so we can visualize the entire
+ // backingstore and what it is doing when we scroll and zoom!
+ Platform::ViewportAccessor* debugViewportAccessor = new BackingStoreVisualizationViewportAccessor(viewportAccessor, this);
+ if (isActive()) {
+ viewportAccessor = debugViewportAccessor;
+ documentSrcRect = debugViewportAccessor->documentViewportRect();
+ pixelSrcRect = debugViewportAccessor->pixelViewportRect();
+ }
#endif
- // FIXME: This should not explicitely depend on WebCore::.
- TransformationMatrix transformation;
- if (!contents.isEmpty())
- transformation = TransformationMatrix::rectToRect(FloatRect(FloatPoint(0.0, 0.0), WebCore::IntSize(contents.size())), WebCore::IntRect(dstRect));
-
#if DEBUG_BACKINGSTORE
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
- "BackingStorePrivate::blitContents dstRect=(%d,%d %dx%d) srcRect=(%d,%d %dx%d)",
- dstRect.x(), dstRect.y(), dstRect.width(), dstRect.height(),
- srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height());
+ BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelCritical,
+ "BackingStorePrivate::blitVisibleContents(): dstRect=(%d,%d) %dx%d, documentSrcRect=(%f, %f) %f x %f, scale=%f",
+ dstRect.x(), dstRect.y(), dstRect.width(), dstRect.height(),
+ documentSrcRect.x(), documentSrcRect.y(), documentSrcRect.width(), documentSrcRect.height(),
+ viewportAccessor->scale());
#endif
- Platform::IntPoint origin = contents.location();
- Platform::IntRect contentsClipped = contents;
-
Vector<TileBuffer*> blittedTiles;
if (isActive() && !m_webPage->d->compositorDrawsRootLayer()) {
- paintDefaultBackground(contents, transformation, false /*flush*/);
+ paintDefaultBackground(dstRect, viewportAccessor, false /*flush*/);
BackingStoreGeometry* currentState = frontState();
TileMap currentMap = currentState->tileMap();
+ double currentScale = currentState->scale();
+
+ const Platform::IntRect transformedContentsRect = Platform::IntRect(Platform::IntPoint(0, 0), m_client->transformedContentsSize());
+
+ // For blitting backingstore tiles, we need the srcRect to be specified
+ // in backingstore tile pixel coordinates. If our viewport accessor is
+ // at a different scale, we calculate those coordinates by ourselves.
+ const Platform::IntRect transformedSrcRect = currentScale == viewportAccessor->scale()
+ ? pixelSrcRect
+ : viewportAccessor->roundFromDocumentContents(documentSrcRect, currentScale);
+
+ Platform::IntRect clippedTransformedSrcRect = transformedSrcRect;
+ const Platform::IntPoint origin = transformedSrcRect.location();
+
+ // FIXME: This should not explicitly depend on WebCore::.
+ TransformationMatrix transformation;
+ if (!transformedSrcRect.isEmpty())
+ transformation = TransformationMatrix::rectToRect(FloatRect(FloatPoint(0.0, 0.0), WebCore::IntSize(transformedSrcRect.size())), WebCore::IntRect(dstRect));
#if DEBUG_CHECKERBOARD
bool blitCheckered = false;
#endif
// Don't clip to contents if it is empty so we can still paint default background.
- if (!contentsRect.isEmpty()) {
- contentsClipped.intersect(contentsRect);
- if (contentsClipped.isEmpty()) {
+ if (!transformedContentsRect.isEmpty()) {
+ clippedTransformedSrcRect.intersect(transformedContentsRect);
+ if (clippedTransformedSrcRect.isEmpty()) {
invalidateWindow(dstRect);
return;
}
- Platform::IntRectRegion contentsRegion = contentsClipped;
+ Platform::IntRectRegion transformedSrcRegion = clippedTransformedSrcRect;
Platform::IntRectRegion backingStoreRegion = currentState->backingStoreRect();
Platform::IntRectRegion checkeredRegion
- = Platform::IntRectRegion::subtractRegions(contentsRegion, backingStoreRegion);
+ = Platform::IntRectRegion::subtractRegions(transformedSrcRegion, backingStoreRegion);
// Blit checkered to those parts that are not covered by the backingStoreRect.
IntRectList checkeredRects = checkeredRegion.rects();
@@ -1354,7 +1347,7 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
}
// Get the list of tile rects that makeup the content.
- TileRectList tileRectList = mapFromTransformedContentsToTiles(contentsClipped, currentState);
+ TileRectList tileRectList = mapFromTransformedContentsToTiles(clippedTransformedSrcRect, currentState);
for (size_t i = 0; i < tileRectList.size(); ++i) {
TileRect tileRect = tileRectList[i];
TileIndex index = tileRect.first;
@@ -1368,9 +1361,9 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
= mapFromTilesToTransformedContents(tileRect, currentState->backingStoreRect());
// Don't clip to contents if it is empty so we can still paint default background.
- if (!contentsRect.isEmpty()) {
+ if (!transformedContentsRect.isEmpty()) {
// Otherwise we should clip the contents size and blit.
- dirtyRect.intersect(contentsRect);
+ dirtyRect.intersect(transformedContentsRect);
// We probably have extra tiles since the contents size is so small.
// Save some cycles here...
@@ -1392,7 +1385,7 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
wholeTileRect.second = this->tileRect();
bool committed = tile->isCommitted();
- bool rendered = tileBuffer->isRendered(dirtyTileRect);
+ bool rendered = tileBuffer->isRendered(dirtyTileRect, currentScale);
bool paintCheckered = !committed || !rendered;
if (paintCheckered) {
@@ -1478,47 +1471,41 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
#if USE(ACCELERATED_COMPOSITING)
if (WebPageCompositorPrivate* compositor = m_webPage->d->compositor()) {
- WebCore::FloatRect contentsRect = m_webPage->d->mapFromTransformedFloatRect(WebCore::FloatRect(WebCore::IntRect(contents)));
- compositor->drawLayers(dstRect, contentsRect);
+ compositor->drawLayers(dstRect, documentSrcRect);
if (compositor->drawsRootLayer())
- paintDefaultBackground(contents, transformation, false /*flush*/);
+ paintDefaultBackground(dstRect, viewportAccessor, false /*flush*/);
}
#endif
#if ENABLE_SCROLLBARS
if (isScrollingOrZooming() && m_client->isMainFrame()) {
- blitHorizontalScrollbar(origin);
- blitVerticalScrollbar(origin);
+ blitHorizontalScrollbar();
+ blitVerticalScrollbar();
}
#endif
#if DEBUG_VISUALIZE
- // FIXME: This should not explicitely depend on WebCore::.
- BlackBerry::Platform::Graphics::Buffer* windowBuffer = buffer();
- BlackBerry::Platform::Graphics::Drawable* bufferDrawable =
- BlackBerry::Platform::Graphics::lockBufferDrawable(windowBuffer);
- PlatformGraphicsContext* bufferPlatformGraphicsContext =
- SurfacePool::globalSurfacePool()->createPlatformGraphicsContext(bufferDrawable);
- GraphicsContext graphicsContext(bufferPlatformGraphicsContext);
- FloatRect wkViewport = FloatRect(visibleContentsRect());
- FloatRect uiViewport = FloatRect(m_webPage->client()->userInterfaceBlittedVisibleContentsRect());
- wkViewport.move(-contents.x(), -contents.y());
- uiViewport.move(-contents.x(), -contents.y());
-
- graphicsContext.save();
-
- // Draw a blue rect for the webkit thread viewport.
- graphicsContext.setStrokeColor(WebCore::Color(0, 0, 255), WebCore::ColorSpaceDeviceRGB);
- graphicsContext.strokeRect(transformation.mapRect(wkViewport), 1.0);
-
- // Draw a red rect for the ui thread viewport.
- graphicsContext.setStrokeColor(WebCore::Color(255, 0, 0), WebCore::ColorSpaceDeviceRGB);
- graphicsContext.strokeRect(transformation.mapRect(uiViewport), 1.0);
-
- graphicsContext.restore();
-
- delete bufferPlatformGraphicsContext;
- releaseBufferDrawable(windowBuffer);
+ if (debugViewportAccessor) {
+ Platform::Graphics::Buffer* targetBuffer = buffer();
+ Platform::IntRect wkViewport = debugViewportAccessor->roundToPixelFromDocumentContents(Platform::IntRect(m_client->visibleContentsRect()));
+ Platform::IntRect uiViewport = debugViewportAccessor->roundToPixelFromDocumentContents(documentViewportRect);
+ wkViewport.move(-pixelSrcRect.x(), -pixelSrcRect.y());
+ uiViewport.move(-pixelSrcRect.x(), -pixelSrcRect.y());
+
+ // Draw a blue rect for the webkit thread viewport.
+ Platform::Graphics::clearBuffer(targetBuffer, Platform::IntRect(wkViewport.x(), wkViewport.y(), wkViewport.width(), 1), 0, 0, 255, 255);
+ Platform::Graphics::clearBuffer(targetBuffer, Platform::IntRect(wkViewport.x(), wkViewport.y(), 1, wkViewport.height()), 0, 0, 255, 255);
+ Platform::Graphics::clearBuffer(targetBuffer, Platform::IntRect(wkViewport.x(), wkViewport.bottom() - 1, wkViewport.width(), 1), 0, 0, 255, 255);
+ Platform::Graphics::clearBuffer(targetBuffer, Platform::IntRect(wkViewport.right() - 1, wkViewport.y(), 1, wkViewport.height()), 0, 0, 255, 255);
+
+ // Draw a red rect for the ui thread viewport.
+ Platform::Graphics::clearBuffer(targetBuffer, Platform::IntRect(uiViewport.x(), uiViewport.y(), uiViewport.width(), 1), 255, 0, 0, 255);
+ Platform::Graphics::clearBuffer(targetBuffer, Platform::IntRect(uiViewport.x(), uiViewport.y(), 1, uiViewport.height()), 255, 0, 0, 255);
+ Platform::Graphics::clearBuffer(targetBuffer, Platform::IntRect(uiViewport.x(), uiViewport.bottom() - 1, uiViewport.width(), 1), 255, 0, 0, 255);
+ Platform::Graphics::clearBuffer(targetBuffer, Platform::IntRect(uiViewport.right() - 1, uiViewport.y(), 1, uiViewport.height()), 255, 0, 0, 255);
+
+ delete debugViewportAccessor;
+ }
#endif
#if DEBUG_CHECKERBOARD
@@ -1526,14 +1513,14 @@ void BackingStorePrivate::blitContents(const Platform::IntRect& dstRect,
if (blitCheckered && !lastCheckeredTime) {
lastCheckeredTime = WTF::currentTime();
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
+ BBLOG(BlackBerry::Platform::LogLevelCritical,
"Blitting checkered pattern at %f\n", lastCheckeredTime);
} else if (blitCheckered && lastCheckeredTime) {
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
+ BBLOG(BlackBerry::Platform::LogLevelCritical,
"Blitting checkered pattern at %f\n", WTF::currentTime());
} else if (!blitCheckered && lastCheckeredTime) {
double time = WTF::currentTime();
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
+ BBLOG(BlackBerry::Platform::LogLevelCritical,
"Blitting over checkered pattern at %f took %f\n", time, time - lastCheckeredTime);
lastCheckeredTime = 0;
}
@@ -1650,7 +1637,7 @@ Platform::IntRect BackingStorePrivate::blitTileRect(TileBuffer* tileBuffer,
return dirtyRect;
}
-void BackingStorePrivate::blitHorizontalScrollbar(const Platform::IntPoint& scrollPosition)
+void BackingStorePrivate::blitHorizontalScrollbar()
{
if (!m_webPage->isVisible())
return;
@@ -1658,7 +1645,7 @@ void BackingStorePrivate::blitHorizontalScrollbar(const Platform::IntPoint& scro
m_webPage->client()->drawHorizontalScrollbar();
}
-void BackingStorePrivate::blitVerticalScrollbar(const Platform::IntPoint& scrollPosition)
+void BackingStorePrivate::blitVerticalScrollbar()
{
if (!m_webPage->isVisible())
return;
@@ -1688,7 +1675,7 @@ Platform::IntRect BackingStorePrivate::visibleTilesRect() const
TileMap::const_iterator end = currentMap.end();
for (TileMap::const_iterator it = currentMap.begin(); it != end; ++it) {
TileRect tileRect;
- tileRect.first = it->first;
+ tileRect.first = it->key;
tileRect.second = this->tileRect();
Platform::IntRect tile = mapFromTilesToTransformedContents(tileRect);
if (tile.intersects(visibleContentsRect()))
@@ -1749,7 +1736,7 @@ void BackingStorePrivate::resetTiles(bool resetBackground)
TileMap::const_iterator end = currentMap.end();
for (TileMap::const_iterator it = currentMap.begin(); it != end; ++it)
- resetTile(it->first, it->second, resetBackground);
+ resetTile(it->key, it->value, resetBackground);
}
void BackingStorePrivate::updateTiles(bool updateVisible, bool immediate)
@@ -1762,10 +1749,10 @@ void BackingStorePrivate::updateTiles(bool updateVisible, bool immediate)
TileMap::const_iterator end = currentMap.end();
for (TileMap::const_iterator it = currentMap.begin(); it != end; ++it) {
- bool isVisible = isTileVisible(it->first);
+ bool isVisible = isTileVisible(it->key);
if (!updateVisible && isVisible)
continue;
- updateTile(it->first, immediate);
+ updateTile(it->key, immediate);
}
}
@@ -1786,8 +1773,8 @@ void BackingStorePrivate::updateTilesForScrollOrNotRenderedRegion(bool checkLoad
TileMap::const_iterator end = currentMap.end();
for (TileMap::const_iterator it = currentMap.begin(); it != end; ++it) {
- TileIndex index = it->first;
- BackingStoreTile* tile = it->second;
+ TileIndex index = it->key;
+ BackingStoreTile* tile = it->value;
bool isVisible = isTileVisible(index);
// The rect in transformed contents coordinates.
Platform::IntRect rect(originOfTile(index), tileSize());
@@ -1812,14 +1799,14 @@ void BackingStorePrivate::updateTilesForScrollOrNotRenderedRegion(bool checkLoad
false /*update*/);
#if DEBUG_BACKINGSTORE
Platform::IntRect extents = tileNotRenderedRegion.extents();
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
+ BBLOG(BlackBerry::Platform::LogLevelCritical,
"BackingStorePrivate::updateTilesForScroll did clear tile %d,%d %dx%d",
extents.x(), extents.y(), extents.width(), extents.height());
#endif
}
updateTile(index, false /*immediate*/);
} else if (isVisible
- && (forceVisible || !tile->frontBuffer()->isRendered(tileVisibleContentsRect(index)))
+ && (forceVisible || !tile->frontBuffer()->isRendered(tileVisibleContentsRect(index), currentState->scale()))
&& !isCurrentVisibleJob(index, tile, backingStoreRect))
updateTile(index, false /*immediate*/);
}
@@ -1930,8 +1917,8 @@ BackingStorePrivate::TileRectList BackingStorePrivate::mapFromTransformedContent
TileRectList tileRectList;
TileMap::const_iterator end = tileMap.end();
for (TileMap::const_iterator it = tileMap.begin(); it != end; ++it) {
- TileIndex index = it->first;
- BackingStoreTile* tile = it->second;
+ TileIndex index = it->key;
+ BackingStoreTile* tile = it->value;
// Need to map the rect to tile coordinates.
Platform::IntRect r = rect;
@@ -1957,6 +1944,8 @@ BackingStorePrivate::TileRectList BackingStorePrivate::mapFromTransformedContent
void BackingStorePrivate::updateTileMatrixIfNeeded()
{
+ ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
+
// This will update the tile matrix.
scrollBackingStore(0, 0);
}
@@ -2030,6 +2019,7 @@ void BackingStorePrivate::transformChanged()
void BackingStorePrivate::orientationChanged()
{
+ ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
updateTileMatrixIfNeeded();
createVisibleTileBuffer();
}
@@ -2083,6 +2073,7 @@ void BackingStorePrivate::createSurfaces()
}
// Set the initial state of the backingstore geometry.
+ backState()->setScale(m_webPage->d->currentScale());
backState()->setNumberOfTilesWide(divisor.first);
backState()->setNumberOfTilesHigh(divisor.second);
backState()->setTileMap(newTileMap);
@@ -2201,7 +2192,7 @@ void BackingStorePrivate::renderContents(BlackBerry::Platform::Graphics::Buffer*
return;
#if DEBUG_BACKINGSTORE
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
+ BBLOG(BlackBerry::Platform::LogLevelCritical,
"BackingStorePrivate::renderContents tileBuffer=0x%x surfaceOffset=(%d,%d) contentsRect=(%d,%d %dx%d)",
tileBuffer, surfaceOffset.x(), surfaceOffset.y(),
contentsRect.x(), contentsRect.y(), contentsRect.width(), contentsRect.height());
@@ -2337,7 +2328,7 @@ void BackingStorePrivate::blitToWindow(const Platform::IntRect& dstRect,
ASSERT(dstBuffer);
ASSERT(srcBuffer);
if (!dstBuffer)
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelWarn, "Empty window buffer, couldn't blitToWindow");
+ BBLOG(BlackBerry::Platform::LogLevelWarn, "Empty window buffer, couldn't blitToWindow");
BlackBerry::Platform::Graphics::BlendMode blendMode = blend
? BlackBerry::Platform::Graphics::SourceOver
@@ -2366,7 +2357,7 @@ void BackingStorePrivate::fillWindow(Platform::Graphics::FillPattern pattern,
BlackBerry::Platform::Graphics::Buffer* dstBuffer = buffer();
ASSERT(dstBuffer);
if (!dstBuffer)
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelWarn, "Empty window buffer, couldn't fillWindow");
+ BBLOG(BlackBerry::Platform::LogLevelWarn, "Empty window buffer, couldn't fillWindow");
BlackBerry::Platform::Graphics::fillBuffer(dstBuffer, pattern, dstRect, contentsOrigin, contentsScale);
}
@@ -2375,7 +2366,7 @@ void BackingStorePrivate::invalidateWindow()
{
// Grab a rect appropriate for the current thread.
if (BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread())
- invalidateWindow(m_webPage->client()->userInterfaceBlittedDestinationRect());
+ invalidateWindow(m_webPage->client()->userInterfaceViewportAccessor()->destinationSurfaceRect());
else
invalidateWindow(Platform::IntRect(Platform::IntPoint(0, 0), m_client->transformedViewportSize()));
}
@@ -2396,7 +2387,7 @@ void BackingStorePrivate::invalidateWindow(const Platform::IntRect& dst)
}
#if DEBUG_BACKINGSTORE
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::invalidateWindow dst = %s", dst.toString().c_str());
+ BBLOG(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::invalidateWindow dst = %s", dst.toString().c_str());
#endif
// Since our window may also be double buffered, we need to also copy the
@@ -2416,7 +2407,7 @@ void BackingStorePrivate::invalidateWindow(const Platform::IntRect& dst)
return;
#if DEBUG_BACKINGSTORE
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::invalidateWindow posting = %s", dstRect.toString().c_str());
+ BBLOG(BlackBerry::Platform::LogLevelCritical, "BackingStorePrivate::invalidateWindow posting = %s", dstRect.toString().c_str());
#endif
m_currentWindowBackBuffer = (m_currentWindowBackBuffer + 1) % 2;
@@ -2451,7 +2442,7 @@ void BackingStorePrivate::clearWindow(const Platform::IntRect& rect,
BlackBerry::Platform::Graphics::Buffer* dstBuffer = buffer();
ASSERT(dstBuffer);
if (!dstBuffer)
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelWarn, "Empty window buffer, couldn't clearWindow");
+ BBLOG(BlackBerry::Platform::LogLevelWarn, "Empty window buffer, couldn't clearWindow");
windowFrontBufferState()->clearBlittedRegion(rect);
windowBackBufferState()->addBlittedRegion(rect);
@@ -2627,18 +2618,6 @@ void BackingStore::blitVisibleContents()
d->blitVisibleContents(false /*force*/);
}
-void BackingStore::blitContents(const BlackBerry::Platform::IntRect& dstRect, const BlackBerry::Platform::IntRect& contents)
-{
- // Blitting during direct rendering is not supported.
- if (isDirectRenderingToWindow()) {
- BlackBerry::Platform::log(BlackBerry::Platform::LogLevelCritical,
- "BackingStore::blitContents operation not supported in direct rendering mode");
- return;
- }
-
- d->blitContents(dstRect, contents);
-}
-
void BackingStore::repaint(int x, int y, int width, int height,
bool contentChanged, bool immediate)
{