From 7b919f6684d93e520c24bf395dc75258e7d3eaf7 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Wed, 20 Jul 2011 12:55:58 -0700 Subject: [PATCH] Add some debugging functions to LayerAndroid Change-Id: I03922d9788d340ab208677b272470312c92a80ee --- .../platform/graphics/android/BaseLayerAndroid.cpp | 9 +++-- .../platform/graphics/android/LayerAndroid.cpp | 46 ++++++++++++++++++++++ .../platform/graphics/android/LayerAndroid.h | 5 +++ 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index 2866ca1fc..0f5871ddc 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -325,11 +325,12 @@ bool BaseLayerAndroid::drawGL(LayerAndroid* compositedRoot, compositedRoot->setScale(scale); #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(); + compositedRoot->showLayer(0); + XLOG("We have %d layers, %d textured", + compositedRoot->nbLayers(), + compositedRoot->nbTexturedLayers()); #endif + // Clean up GL textures for video layer. TilesManager::instance()->videoLayerManager()->deleteUnusedTextures(); diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index 947a0fc18..05cb85e30 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -659,6 +659,52 @@ IntRect LayerAndroid::clippedRect() const return rect; } +int LayerAndroid::nbLayers() +{ + int nb = 0; + int count = this->countChildren(); + for (int i = 0; i < count; i++) + nb += this->getChild(i)->nbLayers(); + return nb+1; +} + +int LayerAndroid::nbTexturedLayers() +{ + int nb = 0; + int count = this->countChildren(); + for (int i = 0; i < count; i++) + nb += this->getChild(i)->nbTexturedLayers(); + if (needsTexture()) + nb++; + return nb; +} + +void LayerAndroid::showLayer(int indent) +{ + char spaces[256]; + memset(spaces, 0, 256); + for (unsigned int i = 0; i < indent; i++) + spaces[i] = ' '; + + if (!indent) + XLOGC("\n\n--- LAYERS TREE ---"); + + IntRect r(0, 0, getWidth(), getHeight()); + IntRect tr = m_drawTransform.mapRect(r); + XLOGC("%s [%d:0x%x] - %s - (%d, %d, %d, %d) %s prepareContext(%d), pic w: %d h: %d", + spaces, uniqueId(), m_owningLayer, + needsTexture() ? "needs a texture" : "no texture", + tr.x(), tr.y(), tr.width(), tr.height(), + contentIsScrollable() ? "SCROLLABLE" : "", + prepareContext(), + m_recordingPicture ? m_recordingPicture->width() : -1, + m_recordingPicture ? m_recordingPicture->height() : -1); + + int count = this->countChildren(); + for (int i = 0; i < count; i++) + this->getChild(i)->showLayer(indent + 1); +} + void LayerAndroid::assignTexture(LayerAndroid* oldTree) { int count = this->countChildren(); diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index 15c7e0fd1..c4ed9fe5f 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -114,6 +114,11 @@ public: virtual bool needsTexture(); + // Debug helper methods + int nbLayers(); + int nbTexturedLayers(); + void showLayer(int indent); + void setScale(float scale); float getScale() { return m_scale; } virtual bool drawGL(GLWebViewState*, SkMatrix&); -- 2.11.0