summaryrefslogtreecommitdiff
path: root/Source/WebKit/blackberry/Api/BackingStore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/blackberry/Api/BackingStore.cpp')
-rw-r--r--Source/WebKit/blackberry/Api/BackingStore.cpp144
1 files changed, 114 insertions, 30 deletions
diff --git a/Source/WebKit/blackberry/Api/BackingStore.cpp b/Source/WebKit/blackberry/Api/BackingStore.cpp
index 61b90cc24..3daa490d5 100644
--- a/Source/WebKit/blackberry/Api/BackingStore.cpp
+++ b/Source/WebKit/blackberry/Api/BackingStore.cpp
@@ -200,12 +200,14 @@ BackingStorePrivate::BackingStorePrivate()
, m_resumeOperation(BackingStore::None)
, m_suspendRenderJobs(false)
, m_suspendRegularRenderJobs(false)
+ , m_tileMatrixNeedsUpdate(false)
, m_isScrollingOrZooming(false)
, m_webPage(0)
, m_client(0)
, m_renderQueue(adoptPtr(new RenderQueue(this)))
, m_defersBlit(true)
, m_hasBlitJobs(false)
+ , m_webPageBackgroundColor(WebCore::Color::white)
, m_currentWindowBackBuffer(0)
, m_preferredTileMatrixDimension(Vertical)
#if USE(ACCELERATED_COMPOSITING)
@@ -278,14 +280,22 @@ bool BackingStorePrivate::isOpenGLCompositing() const
return true;
}
-void BackingStorePrivate::suspendScreenAndBackingStoreUpdates()
+void BackingStorePrivate::suspendBackingStoreUpdates()
{
- if (m_suspendScreenUpdates) {
+ if (atomic_add_value(&m_suspendBackingStoreUpdates, 0)) {
BBLOG(BlackBerry::Platform::LogLevelInfo,
- "Screen and backingstore already suspended, increasing suspend counter.");
+ "Backingstore already suspended, increasing suspend counter.");
}
- ++m_suspendBackingStoreUpdates;
+ atomic_add(&m_suspendBackingStoreUpdates, 1);
+}
+
+void BackingStorePrivate::suspendScreenUpdates()
+{
+ if (m_suspendScreenUpdates) {
+ BBLOG(BlackBerry::Platform::LogLevelInfo,
+ "Screen already suspended, increasing suspend counter.");
+ }
// Make sure the user interface thread gets the message before we proceed
// because blitVisibleContents() can be called from the user interface
@@ -295,17 +305,32 @@ void BackingStorePrivate::suspendScreenAndBackingStoreUpdates()
BlackBerry::Platform::userInterfaceThreadMessageClient()->syncToCurrentMessage();
}
-void BackingStorePrivate::resumeScreenAndBackingStoreUpdates(BackingStore::ResumeUpdateOperation op)
+void BackingStorePrivate::resumeBackingStoreUpdates()
{
- ASSERT(m_suspendScreenUpdates);
- ASSERT(m_suspendBackingStoreUpdates);
+ unsigned currentValue = atomic_add_value(&m_suspendBackingStoreUpdates, 0);
+ ASSERT(currentValue >= 1);
+ if (currentValue < 1) {
+ BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelCritical,
+ "Call mismatch: Backingstore hasn't been suspended, therefore won't resume!");
+ return;
+ }
+
+ // Set a flag indicating that we're about to resume backingstore updates and
+ // the tile matrix should be updated as a consequence by the first render
+ // job that happens after this resumption of backingstore updates.
+ if (currentValue == 1)
+ setTileMatrixNeedsUpdate();
+
+ atomic_sub(&m_suspendBackingStoreUpdates, 1);
+}
- // Both variables are similar except for the timing of setting them.
- ASSERT(m_suspendScreenUpdates == m_suspendBackingStoreUpdates);
+void BackingStorePrivate::resumeScreenUpdates(BackingStore::ResumeUpdateOperation op)
+{
+ ASSERT(m_suspendScreenUpdates);
- if (!m_suspendScreenUpdates || !m_suspendBackingStoreUpdates) {
+ if (!m_suspendScreenUpdates) {
BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelCritical,
- "Call mismatch: Screen and backingstore haven't been suspended, therefore won't resume!");
+ "Call mismatch: Screen hasn't been suspended, therefore won't resume!");
return;
}
@@ -314,16 +339,13 @@ void BackingStorePrivate::resumeScreenAndBackingStoreUpdates(BackingStore::Resum
|| (m_resumeOperation == BackingStore::None && op == BackingStore::Blit))
m_resumeOperation = op;
- if (m_suspendScreenUpdates >= 2 && m_suspendBackingStoreUpdates >= 2) { // we're still suspended
+ if (m_suspendScreenUpdates >= 2) { // we're still suspended
BBLOG(BlackBerry::Platform::LogLevelInfo,
"Screen and backingstore still suspended, decreasing suspend counter.");
- --m_suspendBackingStoreUpdates;
--m_suspendScreenUpdates;
return;
}
- --m_suspendBackingStoreUpdates;
-
op = m_resumeOperation;
m_resumeOperation = BackingStore::None;
@@ -375,9 +397,6 @@ void BackingStorePrivate::resumeScreenAndBackingStoreUpdates(BackingStore::Resum
void BackingStorePrivate::repaint(const Platform::IntRect& windowRect,
bool contentChanged, bool immediate)
{
- if (m_suspendBackingStoreUpdates)
- return;
-
// If immediate is true, then we're being asked to perform synchronously.
// NOTE: WebCore::ScrollView will call this method with immediate:true and contentChanged:false.
// This is a special case introduced specifically for the Apple's windows port and can be safely ignored I believe.
@@ -406,6 +425,9 @@ void BackingStorePrivate::repaint(const Platform::IntRect& windowRect,
#endif
if (immediate) {
+ if (m_suspendBackingStoreUpdates)
+ return;
+
if (render(rect)) {
if (!shouldDirectRenderingToWindow() && !m_webPage->d->commitRootLayerIfNeeded())
blitVisibleContents();
@@ -701,6 +723,9 @@ void BackingStorePrivate::setBackingStoreRect(const Platform::IntRect& backingSt
return;
}
+ if (m_suspendBackingStoreUpdates)
+ return;
+
Platform::IntRect currentBackingStoreRect = frontState()->backingStoreRect();
double currentScale = frontState()->scale();
@@ -1039,6 +1064,11 @@ bool BackingStorePrivate::render(const Platform::IntRect& rect)
if (!isActive())
return false;
+ // This is the first render job that has been performed since resumption of
+ // backingstore updates and the tile matrix needs updating since we suspend
+ // tile matrix updating with backingstore updates
+ updateTileMatrixIfNeeded();
+
TileRectList tileRectList = mapFromTransformedContentsToTiles(rect);
if (tileRectList.isEmpty())
return false;
@@ -1144,6 +1174,7 @@ void BackingStorePrivate::requestLayoutIfNeeded() const
bool BackingStorePrivate::renderVisibleContents()
{
+ updateTileMatrixIfNeeded();
Platform::IntRect renderRect = shouldDirectRenderingToWindow() ? visibleContentsRect() : visibleTilesRect();
if (render(renderRect)) {
m_renderQueue->clear(renderRect, true /*clearRegularRenderJobs*/);
@@ -1154,6 +1185,7 @@ bool BackingStorePrivate::renderVisibleContents()
bool BackingStorePrivate::renderBackingStore()
{
+ updateTileMatrixIfNeeded();
return render(frontState()->backingStoreRect());
}
@@ -1289,6 +1321,10 @@ void BackingStorePrivate::blitVisibleContents(bool force)
viewportAccessor->scale());
#endif
+#if DEBUG_CHECKERBOARD
+ bool blitCheckered = false;
+#endif
+
Vector<TileBuffer*> blittedTiles;
if (isActive() && !m_webPage->d->compositorDrawsRootLayer()) {
@@ -1315,10 +1351,6 @@ void BackingStorePrivate::blitVisibleContents(bool force)
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 (!transformedContentsRect.isEmpty()) {
clippedTransformedSrcRect.intersect(transformedContentsRect);
@@ -1949,12 +1981,18 @@ void BackingStorePrivate::updateTileMatrixIfNeeded()
{
ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
+ if (!m_tileMatrixNeedsUpdate)
+ return;
+
+ m_tileMatrixNeedsUpdate = false;
+
// This will update the tile matrix.
scrollBackingStore(0, 0);
}
void BackingStorePrivate::contentsSizeChanged(const Platform::IntSize&)
{
+ setTileMatrixNeedsUpdate();
updateTileMatrixIfNeeded();
}
@@ -2023,6 +2061,7 @@ void BackingStorePrivate::transformChanged()
void BackingStorePrivate::orientationChanged()
{
ASSERT(BlackBerry::Platform::webKitThreadMessageClient()->isCurrentThread());
+ setTileMatrixNeedsUpdate();
updateTileMatrixIfNeeded();
createVisibleTileBuffer();
}
@@ -2053,6 +2092,10 @@ void BackingStorePrivate::createSurfaces()
return;
}
+ // Don't try to blit to screen unless we have a buffer.
+ if (!buffer())
+ suspendScreenUpdates();
+
SurfacePool* surfacePool = SurfacePool::globalSurfacePool();
surfacePool->initialize(tileSize());
@@ -2085,10 +2128,6 @@ void BackingStorePrivate::createSurfaces()
swapState();
createVisibleTileBufferForWebPage(m_webPage->d);
-
- // Don't try to blit to screen unless we have a buffer.
- if (!buffer())
- suspendScreenAndBackingStoreUpdates();
}
void BackingStorePrivate::createVisibleTileBuffer()
@@ -2366,9 +2405,38 @@ void BackingStorePrivate::fillWindow(Platform::Graphics::FillPattern pattern,
"Empty window buffer, couldn't fillWindow");
}
+ if (pattern == BlackBerry::Platform::Graphics::CheckerboardPattern && BlackBerry::Platform::Settings::isPublicBuild()) {
+ // For public builds, convey the impression of less checkerboard.
+ // For developer builds, keep the checkerboard to get it fixed better.
+ BlackBerry::Platform::Graphics::clearBuffer(dstBuffer, dstRect,
+ m_webPageBackgroundColor.red(), m_webPageBackgroundColor.green(),
+ m_webPageBackgroundColor.blue(), m_webPageBackgroundColor.alpha());
+ return;
+ }
+
BlackBerry::Platform::Graphics::fillBuffer(dstBuffer, pattern, dstRect, contentsOrigin, contentsScale);
}
+WebCore::Color BackingStorePrivate::webPageBackgroundColorUserInterfaceThread() const
+{
+ ASSERT(BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread());
+ return m_webPageBackgroundColor;
+}
+
+void BackingStorePrivate::setWebPageBackgroundColor(const WebCore::Color& color)
+{
+ if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
+ typedef void (BlackBerry::WebKit::BackingStorePrivate::*FunctionType)(const WebCore::Color&);
+
+ BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage(
+ BlackBerry::Platform::createMethodCallMessage<FunctionType, BackingStorePrivate, WebCore::Color>(
+ &BackingStorePrivate::setWebPageBackgroundColor, this, color));
+ return;
+ }
+
+ m_webPageBackgroundColor = color;
+}
+
void BackingStorePrivate::invalidateWindow()
{
// Grab a rect appropriate for the current thread.
@@ -2490,6 +2558,8 @@ void BackingStorePrivate::setScrollingOrZooming(bool scrollingOrZooming, bool sh
else if (shouldBlit && !shouldDirectRenderingToWindow())
blitVisibleContents();
#endif
+ if (!scrollingOrZooming && shouldPerformRegularRenderJobs())
+ dispatchRenderJob();
}
void BackingStorePrivate::lockBackingStore()
@@ -2602,14 +2672,24 @@ void BackingStore::createSurface()
d->m_webPage->setFocused(true);
}
-void BackingStore::suspendScreenAndBackingStoreUpdates()
+void BackingStore::suspendBackingStoreUpdates()
+{
+ d->suspendBackingStoreUpdates();
+}
+
+void BackingStore::resumeBackingStoreUpdates()
+{
+ d->resumeBackingStoreUpdates();
+}
+
+void BackingStore::suspendScreenUpdates()
{
- d->suspendScreenAndBackingStoreUpdates();
+ d->suspendScreenUpdates();
}
-void BackingStore::resumeScreenAndBackingStoreUpdates(ResumeUpdateOperation op)
+void BackingStore::resumeScreenUpdates(ResumeUpdateOperation op)
{
- d->resumeScreenAndBackingStoreUpdates(op);
+ d->resumeScreenUpdates(op);
}
bool BackingStore::isScrollingOrZooming() const
@@ -2643,10 +2723,14 @@ void BackingStore::createBackingStoreMemory()
{
if (BackingStorePrivate::s_currentBackingStoreOwner == d->m_webPage)
SurfacePool::globalSurfacePool()->createBuffers();
+ resumeBackingStoreUpdates();
+ resumeScreenUpdates(BackingStore::RenderAndBlit);
}
void BackingStore::releaseBackingStoreMemory()
{
+ suspendBackingStoreUpdates();
+ suspendScreenUpdates();
if (BackingStorePrivate::s_currentBackingStoreOwner == d->m_webPage)
SurfacePool::globalSurfacePool()->releaseBuffers();
}