summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.cpp14
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.h2
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/SurfaceCollection.cpp62
-rw-r--r--Source/WebCore/platform/graphics/android/SurfaceCollection.h5
-rw-r--r--Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp26
6 files changed, 46 insertions, 67 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.cpp b/Source/WebCore/platform/graphics/android/GLUtils.cpp
index 1578182..9c5a079 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.cpp
+++ b/Source/WebCore/platform/graphics/android/GLUtils.cpp
@@ -639,17 +639,17 @@ void GLUtils::convertToTransformationMatrix(const float* matrix, TransformationM
matrix[12], matrix[13], matrix[14], matrix[15]);
}
-void GLUtils::drawBackground(Color& backgroundColor)
+void GLUtils::drawBackground(const Color* backgroundColor)
{
if (TilesManager::instance()->invertedScreen()) {
- float color = 1.0 - ((((float) backgroundColor.red() / 255.0) +
- ((float) backgroundColor.green() / 255.0) +
- ((float) backgroundColor.blue() / 255.0)) / 3.0);
+ float color = 1.0 - ((((float) backgroundColor->red() / 255.0) +
+ ((float) backgroundColor->green() / 255.0) +
+ ((float) backgroundColor->blue() / 255.0)) / 3.0);
glClearColor(color, color, color, 1);
} else {
- glClearColor((float)backgroundColor.red() / 255.0,
- (float)backgroundColor.green() / 255.0,
- (float)backgroundColor.blue() / 255.0, 1);
+ glClearColor((float)backgroundColor->red() / 255.0,
+ (float)backgroundColor->green() / 255.0,
+ (float)backgroundColor->blue() / 255.0, 1);
}
glClear(GL_COLOR_BUFFER_BIT);
}
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.h b/Source/WebCore/platform/graphics/android/GLUtils.h
index bfc55d0..70ebbd6 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.h
+++ b/Source/WebCore/platform/graphics/android/GLUtils.h
@@ -86,7 +86,7 @@ public:
static bool isPureColorBitmap(const SkBitmap& bitmap, Color& pureColor);
static bool skipTransferForPureColor(const TileRenderInfo* renderInfo,
const SkBitmap& bitmap);
- static void drawBackground(Color& backgroundColor);
+ static void drawBackground(const Color* backgroundColor);
static bool allowGLLog();
static double m_previousLogTime;
static int m_currentLogCounter;
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 1dfc496..b7458e8 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -101,12 +101,14 @@ bool GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndica
if (!layer || isPictureAfterFirstLayout)
m_layersRenderingMode = kAllTextures;
+ SurfaceCollection* collection = 0;
if (layer) {
ALOGV("layer tree %p, with child %p", layer, layer->getChild(0));
layer->setState(this);
+ collection = new SurfaceCollection(layer);
}
bool queueFull = m_surfaceCollectionManager.updateWithSurfaceCollection(
- new SurfaceCollection(layer), isPictureAfterFirstLayout);
+ collection, isPictureAfterFirstLayout);
m_glExtras.setDrawExtra(0);
#ifdef MEASURES_PERF
diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp
index 1110c29..1ea192c 100644
--- a/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp
+++ b/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp
@@ -32,9 +32,9 @@
#include "AndroidLog.h"
#include "BaseLayerAndroid.h"
#include "ClassTracker.h"
+#include "GLWebViewState.h"
#include "LayerAndroid.h"
#include "LayerGroup.h"
-#include "GLWebViewState.h"
#include "ScrollableLayerAndroid.h"
#include "TilesManager.h"
@@ -47,9 +47,7 @@ namespace WebCore {
SurfaceCollection::SurfaceCollection(LayerAndroid* layer)
: m_compositedRoot(layer)
{
- if (!m_compositedRoot)
- return;
-
+ // layer must be non-null.
SkSafeRef(m_compositedRoot);
// calculate draw transforms and z values
@@ -87,13 +85,11 @@ SurfaceCollection::~SurfaceCollection()
void SurfaceCollection::prepareGL(const SkRect& visibleRect)
{
- if (m_compositedRoot) {
- updateLayerPositions(visibleRect);
- bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
- > GLWebViewState::kClippedTextures;
- for (unsigned int i = 0; i < m_layerGroups.size(); i++)
- m_layerGroups[i]->prepareGL(layerTilesDisabled);
- }
+ updateLayerPositions(visibleRect);
+ bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
+ > GLWebViewState::kClippedTextures;
+ for (unsigned int i = 0; i < m_layerGroups.size(); i++)
+ m_layerGroups[i]->prepareGL(layerTilesDisabled);
}
bool SurfaceCollection::drawGL(const SkRect& visibleRect)
@@ -103,23 +99,18 @@ bool SurfaceCollection::drawGL(const SkRect& visibleRect)
#endif
bool needsRedraw = false;
- if (m_compositedRoot) {
- updateLayerPositions(visibleRect);
- bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
- > GLWebViewState::kClippedTextures;
- for (unsigned int i = 0; i < m_layerGroups.size(); i++)
- needsRedraw |= m_layerGroups[i]->drawGL(layerTilesDisabled);
- }
+ updateLayerPositions(visibleRect);
+ bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
+ > GLWebViewState::kClippedTextures;
+ for (unsigned int i = 0; i < m_layerGroups.size(); i++)
+ needsRedraw |= m_layerGroups[i]->drawGL(layerTilesDisabled);
return needsRedraw;
}
-void SurfaceCollection::drawBackground()
+Color SurfaceCollection::getBackground()
{
- Color background = Color::white;
- if (m_compositedRoot)
- background = static_cast<BaseLayerAndroid*>(m_compositedRoot)->getBackgroundColor();
- GLUtils::drawBackground(background);
+ return static_cast<BaseLayerAndroid*>(m_compositedRoot)->getBackgroundColor();
}
void SurfaceCollection::swapTiles()
@@ -130,9 +121,6 @@ void SurfaceCollection::swapTiles()
bool SurfaceCollection::isReady()
{
- if (!m_compositedRoot)
- return true;
-
// Override layer readiness check for single surface mode
if (m_compositedRoot->state()->layersRenderingMode() > GLWebViewState::kClippedTextures) {
// TODO: single surface mode should be properly double buffered
@@ -160,7 +148,7 @@ void SurfaceCollection::computeTexturesAmount(TexturesResult* result)
void SurfaceCollection::setIsPainting(SurfaceCollection* drawingSurface)
{
- if (!m_compositedRoot || !drawingSurface)
+ if (!drawingSurface)
return;
for (unsigned int i = 0; i < m_layerGroups.size(); i++) {
@@ -178,41 +166,31 @@ void SurfaceCollection::setIsPainting(SurfaceCollection* drawingSurface)
void SurfaceCollection::setIsDrawing()
{
- if (!m_compositedRoot)
- return;
-
m_compositedRoot->initAnimations();
}
void SurfaceCollection::mergeInvalsInto(SurfaceCollection* replacementSurface)
{
- if (m_compositedRoot && replacementSurface->m_compositedRoot)
- m_compositedRoot->mergeInvalsInto(replacementSurface->m_compositedRoot);
+ m_compositedRoot->mergeInvalsInto(replacementSurface->m_compositedRoot);
}
void SurfaceCollection::evaluateAnimations(double currentTime)
{
- if (!m_compositedRoot)
- return;
-
m_compositedRoot->evaluateAnimations(currentTime);
}
bool SurfaceCollection::hasCompositedLayers()
{
- return m_compositedRoot != 0;
+ return m_compositedRoot->countChildren();
}
bool SurfaceCollection::hasCompositedAnimations()
{
- return m_compositedRoot != 0 && m_compositedRoot->hasAnimations();
+ return m_compositedRoot->hasAnimations();
}
void SurfaceCollection::updateScrollableLayer(int layerId, int x, int y)
{
- if (!m_compositedRoot)
- return;
-
LayerAndroid* layer = m_compositedRoot->findById(layerId);
if (layer && layer->contentIsScrollable())
static_cast<ScrollableLayerAndroid*>(layer)->scrollTo(x, y);
@@ -220,9 +198,6 @@ void SurfaceCollection::updateScrollableLayer(int layerId, int x, int y)
void SurfaceCollection::updateLayerPositions(const SkRect& visibleRect)
{
- if (!m_compositedRoot)
- return;
-
TransformationMatrix ident;
m_compositedRoot->updateLayerPositions(visibleRect);
FloatRect clip(0, 0, 1e10, 1e10);
@@ -237,5 +212,4 @@ void SurfaceCollection::updateLayerPositions(const SkRect& visibleRect)
#endif
}
-
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollection.h b/Source/WebCore/platform/graphics/android/SurfaceCollection.h
index 61a523c..e73ec9a 100644
--- a/Source/WebCore/platform/graphics/android/SurfaceCollection.h
+++ b/Source/WebCore/platform/graphics/android/SurfaceCollection.h
@@ -26,8 +26,9 @@
#ifndef SurfaceCollection_h
#define SurfaceCollection_h
-#include "SkRefCnt.h"
+#include "Color.h"
#include "SkRect.h"
+#include "SkRefCnt.h"
#include "Vector.h"
class SkCanvas;
@@ -48,7 +49,7 @@ public:
// Tiled painting methods (executed on groups)
void prepareGL(const SkRect& visibleRect);
bool drawGL(const SkRect& visibleRect);
- void drawBackground();
+ Color getBackground();
void swapTiles();
bool isReady();
void computeTexturesAmount(TexturesResult* result);
diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp
index 8f2b7bd..4c48c14 100644
--- a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp
+++ b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp
@@ -106,10 +106,6 @@ void SurfaceCollectionManager::clearCollections()
bool SurfaceCollectionManager::updateWithSurfaceCollection(SurfaceCollection* newCollection,
bool brandNew)
{
- ALOGV("updateWithSurfaceCollection - %p, has children %d, has animations %d",
- newCollection, newCollection->hasCompositedLayers(),
- newCollection->hasCompositedAnimations());
-
// can't have a queued collection unless have a painting collection too
ASSERT(m_paintingCollection || !m_queuedCollection);
@@ -124,6 +120,10 @@ bool SurfaceCollectionManager::updateWithSurfaceCollection(SurfaceCollection* ne
return false;
}
+ ALOGV("updateWithSurfaceCollection - %p, has children %d, has animations %d",
+ newCollection, newCollection->hasCompositedLayers(),
+ newCollection->hasCompositedAnimations());
+
if (m_queuedCollection || m_paintingCollection) {
// currently painting, so defer this new collection
if (m_queuedCollection) {
@@ -197,6 +197,8 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
m_drawingCollection->computeTexturesAmount(texturesResultPtr);
}
+ // Don't have a drawing collection, draw white background
+ Color background = Color::white;
if (m_drawingCollection) {
bool drawingReady = didCollectionSwap || m_drawingCollection->isReady();
@@ -218,17 +220,17 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
m_drawingCollection->evaluateAnimations(currentTime);
ALOGV("drawing collection %p", m_drawingCollection);
- m_drawingCollection->drawBackground();
- ret |= m_drawingCollection->drawGL(visibleRect);
+ background = m_drawingCollection->getBackground();
} else if (m_paintingCollection) {
- // Draw background color while tiles are being painted.
- m_paintingCollection->drawBackground();
- } else {
- // Dont have a drawing collection, draw white background
- Color defaultBackground = Color::white;
- GLUtils::drawBackground(defaultBackground);
+ // Use paintingCollection background color while tiles are not done painting.
+ background = m_paintingCollection->getBackground();
}
+ // Start doing the actual GL drawing.
+ GLUtils::drawBackground(&background);
+ if (m_drawingCollection)
+ ret |= m_drawingCollection->drawGL(visibleRect);
+
if (m_paintingCollection) {
ALOGV("still have painting collection %p", m_paintingCollection);
return true;