summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics
diff options
context:
space:
mode:
authorNicolas Roard <nicolas@android.com>2011-01-27 21:01:51 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-27 21:01:51 -0800
commited1d43611c94775d963061cc710b601d8b30bf9c (patch)
tree33ba13242e4fdf9f07904b6493cf7e6000399b9f /WebCore/platform/graphics
parentf35a48f5582f4c06526cd8455b3a80a542d645e5 (diff)
parent0dc1a08b899775a08e6b985a5397340ffd9eeb8f (diff)
downloadexternal_webkit-ed1d43611c94775d963061cc710b601d8b30bf9c.zip
external_webkit-ed1d43611c94775d963061cc710b601d8b30bf9c.tar.gz
external_webkit-ed1d43611c94775d963061cc710b601d8b30bf9c.tar.bz2
Merge "Add some debugging functions and some cleanup speeding things in Layers." into honeycomb
Diffstat (limited to 'WebCore/platform/graphics')
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.cpp8
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp114
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h8
-rw-r--r--WebCore/platform/graphics/android/ShaderProgram.cpp6
-rw-r--r--WebCore/platform/graphics/android/ShaderProgram.h2
5 files changed, 111 insertions, 27 deletions
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index b6177aa..f5aa7a2 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -319,6 +319,14 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
}
compositedRoot->setScale(scale);
compositedRoot->reserveGLTextures();
+
+#ifdef DEBUG
+ int size = compositedRoot->countTextureSize();
+ int nbLayers = compositedRoot->nbLayers();
+ XLOG("We are using %d Mb for %d layers", size / 1024 / 1024, nbLayers);
+ compositedRoot->showLayers();
+#endif
+
// Now that we marked the textures being used, we delete
// the unnecessary ones to make space...
TilesManager::instance()->cleanupLayersTextures(compositedRoot);
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 77a948a..824a5d1 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -20,10 +20,11 @@
#define LAYER_DEBUG // Add diagonals for debugging
#undef LAYER_DEBUG
-#ifdef DEBUG
-
#include <cutils/log.h>
#include <wtf/text/CString.h>
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "LayerAndroid", __VA_ARGS__)
+
+#ifdef DEBUG
#undef XLOG
#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "LayerAndroid", __VA_ARGS__)
@@ -580,34 +581,97 @@ bool LayerAndroid::needsTexture()
&& m_recordingPicture->width() && m_recordingPicture->height());
}
+IntRect LayerAndroid::clippedRect()
+{
+ IntRect r(0, 0, getWidth(), getHeight());
+ IntRect tr = drawTransform().mapRect(r);
+ IntRect cr = TilesManager::instance()->shader()->clippedRectWithViewport(tr);
+ IntRect rect = drawTransform().inverse().mapRect(cr);
+ return rect;
+}
+
+bool LayerAndroid::outsideViewport()
+{
+ return m_layerTextureRect.width() == 0 &&
+ m_layerTextureRect.height() == 0;
+}
+
+int LayerAndroid::countTextureSize()
+{
+ IntRect cr = clippedRect();
+ int size = cr.width() * cr.height() * 4;
+ int count = this->countChildren();
+ for (int i = 0; i < count; i++)
+ size += getChild(i)->countTextureSize();
+ return size;
+}
+
+int LayerAndroid::nbLayers()
+{
+ int nb = 1;
+ int count = this->countChildren();
+ for (int i = 0; i < count; i++)
+ nb += getChild(i)->nbLayers();
+ return nb;
+}
+
+void LayerAndroid::showLayers(int indent)
+{
+ IntRect cr = clippedRect();
+ int size = cr.width() * cr.height() * 4;
+
+ char space[256];
+ int p = 0;
+ for (; p < indent; p++)
+ space[p] = ' ';
+ space[p] = '\0';
+
+ bool outside = outsideViewport();
+ if (needsTexture() && !outside) {
+ XLOGC("%s Layer %d (%d, %d), cropped to (%d, %d), using %d Mb",
+ space, uniqueId(), getWidth(), getHeight(),
+ cr.width(), cr.height(), size / 1024 / 1024);
+ } else if (needsTexture() && outside) {
+ XLOGC("%s Layer %d is outside the viewport", space, uniqueId());
+ } else {
+ XLOGC("%s Layer %d has no texture", space, uniqueId());
+ }
+
+ int count = this->countChildren();
+ for (int i = 0; i < count; i++)
+ getChild(i)->showLayers(indent + 1);
+}
+
void LayerAndroid::reserveGLTextures()
{
int count = this->countChildren();
for (int i = 0; i < count; i++)
this->getChild(i)->reserveGLTextures();
+ if (!needsTexture())
+ return;
+
LayerTexture* reservedTexture = 0;
- if (needsTexture()) {
- // Compute the layer size & position we need (clipped to the viewport)
- IntRect r(0, 0, getWidth(), getHeight());
- IntRect tr = drawTransform().mapRect(r);
- IntRect cr = TilesManager::instance()->shader()->clippedRectWithViewport(tr);
- m_layerTextureRect = drawTransform().inverse().mapRect(cr);
-
- reservedTexture = TilesManager::instance()->getExistingTextureForLayer(
- this, m_layerTextureRect);
-
- // If we do not have a drawing texture (i.e. new LayerAndroid tree),
- // we get any one available.
- if (!m_drawingTexture) {
- LayerTexture* texture = reservedTexture;
- m_drawingTexture =
- TilesManager::instance()->getExistingTextureForLayer(
- this, m_layerTextureRect, true, texture);
-
- if (!m_drawingTexture)
- m_drawingTexture = reservedTexture;
- }
+
+ // Compute the layer size & position we need (clipped to the viewport)
+ m_layerTextureRect = clippedRect();
+
+ if (outsideViewport())
+ return;
+
+ reservedTexture = TilesManager::instance()->getExistingTextureForLayer(
+ this, m_layerTextureRect);
+
+ // If we do not have a drawing texture (i.e. new LayerAndroid tree),
+ // we get any one available.
+ if (!m_drawingTexture) {
+ LayerTexture* texture = reservedTexture;
+ m_drawingTexture =
+ TilesManager::instance()->getExistingTextureForLayer(
+ this, m_layerTextureRect, true, texture);
+
+ if (!m_drawingTexture)
+ m_drawingTexture = reservedTexture;
}
// SMP flush
@@ -631,6 +695,9 @@ void LayerAndroid::createGLTextures()
if (!needsTexture())
return;
+ if (outsideViewport())
+ return;
+
LayerTexture* reservedTexture = m_reservedTexture;
if (!reservedTexture)
reservedTexture = TilesManager::instance()->createTextureForLayer(this, m_layerTextureRect);
@@ -678,6 +745,7 @@ bool LayerAndroid::needsScheduleRepaint(LayerTexture* texture)
return false;
if (!texture->ready() ||
+ texture->scale() != m_scale ||
texture->pictureUsed() != m_pictureUsed) {
XLOG("We mark layer %d (%x) as dirty because: m_pictureUsed(%d == 0?), texture picture used %x",
uniqueId(), this, m_pictureUsed, texture->pictureUsed());
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index bb91755..6b76b58 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -104,6 +104,14 @@ public:
void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; }
FloatPoint translation() const;
SkRect bounds() const;
+ IntRect clippedRect();
+ bool outsideViewport();
+
+ // Debug/info functions
+ int countTextureSize();
+ int nbLayers();
+ void showLayers(int indent = 0);
+
// called on the root layer
void reserveGLTextures();
void createGLTextures();
diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp
index dc6577c..ed5fe42 100644
--- a/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -231,10 +231,10 @@ void ShaderProgram::clip(const FloatRect& clip)
m_clipRect = clip;
}
-IntRect ShaderProgram::clippedRectWithViewport(const IntRect& rect)
+IntRect ShaderProgram::clippedRectWithViewport(const IntRect& rect, int margin)
{
- IntRect viewport(m_viewport.fLeft, m_viewport.fTop,
- m_viewport.width(), m_viewport.height());
+ IntRect viewport(m_viewport.fLeft - margin, m_viewport.fTop - margin,
+ m_viewport.width() + margin, m_viewport.height() + margin);
viewport.intersect(rect);
return viewport;
}
diff --git a/WebCore/platform/graphics/android/ShaderProgram.h b/WebCore/platform/graphics/android/ShaderProgram.h
index 68cc560..0298594 100644
--- a/WebCore/platform/graphics/android/ShaderProgram.h
+++ b/WebCore/platform/graphics/android/ShaderProgram.h
@@ -44,7 +44,7 @@ class ShaderProgram {
FloatRect clipRectInScreenCoord(const TransformationMatrix& drawMatrix,
const IntSize& size);
void clip(const FloatRect& rect);
- IntRect clippedRectWithViewport(const IntRect& rect);
+ IntRect clippedRectWithViewport(const IntRect& rect, int margin = 0);
private:
GLuint loadShader(GLenum shaderType, const char* pSource);