summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/android/LayerAndroid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/android/LayerAndroid.cpp')
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp114
1 files changed, 91 insertions, 23 deletions
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());