diff options
Diffstat (limited to 'WebCore/platform')
18 files changed, 177 insertions, 93 deletions
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp index 0f2e9f0..fdc6860 100644 --- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp +++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp @@ -27,6 +27,7 @@ #include "BackedDoubleBufferedTexture.h" #include "BaseTile.h" +#include "ClassTracker.h" #include "DeleteTextureOperation.h" #include "GLUtils.h" #include "TilesManager.h" @@ -56,6 +57,10 @@ BackedDoubleBufferedTexture::BackedDoubleBufferedTexture(uint32_t w, uint32_t h, m_sharedBitmap = false; m_canvas = 0; } + +#ifdef DEBUG_COUNT + ClassTracker::instance()->increment("BackedDoubleBufferedTexture"); +#endif } SkCanvas* BackedDoubleBufferedTexture::canvas() @@ -77,6 +82,9 @@ BackedDoubleBufferedTexture::~BackedDoubleBufferedTexture() delete m_canvas; SharedTexture* textures[3] = { &m_textureA, &m_textureB, 0 }; destroyTextures(textures); +#ifdef DEBUG_COUNT + ClassTracker::instance()->decrement("BackedDoubleBufferedTexture"); +#endif } void BackedDoubleBufferedTexture::destroyTextures(SharedTexture** textures) diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index f5aa7a2..76e06bf 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -27,6 +27,7 @@ #include "BaseLayerAndroid.h" #if USE(ACCELERATED_COMPOSITING) +#include "ClassTracker.h" #include "GLUtils.h" #include "ShaderProgram.h" #include "SkCanvas.h" @@ -54,14 +55,6 @@ namespace WebCore { using namespace android; -#ifdef DEBUG_COUNT -static int gBaseLayerAndroidCount = 0; -int BaseLayerAndroid::count() -{ - return gBaseLayerAndroidCount; -} -#endif - BaseLayerAndroid::BaseLayerAndroid() #if USE(ACCELERATED_COMPOSITING) : m_glWebViewState(0), @@ -69,7 +62,7 @@ BaseLayerAndroid::BaseLayerAndroid() #endif { #ifdef DEBUG_COUNT - gBaseLayerAndroidCount++; + ClassTracker::instance()->increment("BaseLayerAndroid"); #endif } @@ -80,7 +73,7 @@ BaseLayerAndroid::~BaseLayerAndroid() #endif m_content.clear(); #ifdef DEBUG_COUNT - gBaseLayerAndroidCount--; + ClassTracker::instance()->decrement("BaseLayerAndroid"); #endif } @@ -349,6 +342,9 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect, #endif // DEBUG_COUNT #endif // USE(ACCELERATED_COMPOSITING) +#ifdef DEBUG + ClassTracker::instance()->show(); +#endif return ret; } diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.h b/WebCore/platform/graphics/android/BaseLayerAndroid.h index 93225c2..c57b13d 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.h +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.h @@ -38,9 +38,6 @@ namespace WebCore { class BaseLayerAndroid : public SkLayer { public: -#ifdef DEBUG_COUNT - static int count(); -#endif BaseLayerAndroid(); virtual ~BaseLayerAndroid(); diff --git a/WebCore/platform/graphics/android/BaseTile.cpp b/WebCore/platform/graphics/android/BaseTile.cpp index c45b138..2753fb2 100644 --- a/WebCore/platform/graphics/android/BaseTile.cpp +++ b/WebCore/platform/graphics/android/BaseTile.cpp @@ -58,14 +58,6 @@ namespace WebCore { -#ifdef DEBUG_COUNT -static int gBaseTileCount = 0; -int BaseTile::count() -{ - return gBaseTileCount; -} -#endif - BaseTile::BaseTile() : m_page(0) , m_x(-1) @@ -78,7 +70,7 @@ BaseTile::BaseTile() , m_lastPaintedPicture(0) { #ifdef DEBUG_COUNT - gBaseTileCount++; + ClassTracker::instance()->increment("BaseTile"); #endif } @@ -89,7 +81,7 @@ BaseTile::~BaseTile() m_texture->release(this); #ifdef DEBUG_COUNT - gBaseTileCount--; + ClassTracker::instance()->decrement("BaseTile"); #endif } diff --git a/WebCore/platform/graphics/android/BaseTile.h b/WebCore/platform/graphics/android/BaseTile.h index a7eae23..d22849d 100644 --- a/WebCore/platform/graphics/android/BaseTile.h +++ b/WebCore/platform/graphics/android/BaseTile.h @@ -62,9 +62,6 @@ class BackedDoubleBufferedTexture; */ class BaseTile : public TextureOwner { public: -#ifdef DEBUG_COUNT - static int count(); -#endif BaseTile(); ~BaseTile(); diff --git a/WebCore/platform/graphics/android/ClassTracker.cpp b/WebCore/platform/graphics/android/ClassTracker.cpp new file mode 100644 index 0000000..ad2b4dd --- /dev/null +++ b/WebCore/platform/graphics/android/ClassTracker.cpp @@ -0,0 +1,74 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ClassTracker.h" + +#include <cutils/log.h> +#include <wtf/CurrentTime.h> +#include <wtf/text/CString.h> + +#undef XLOG +#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "ClassTracker", __VA_ARGS__) + +namespace WebCore { + +ClassTracker* ClassTracker::instance() +{ + if (!gInstance) + gInstance = new ClassTracker(); + return gInstance; +} + +ClassTracker* ClassTracker::gInstance = 0; + +void ClassTracker::increment(String name) +{ + int value = 0; + if (m_classes.contains(name)) + value = m_classes.get(name); + + m_classes.set(name, value + 1); +} + +void ClassTracker::decrement(String name) +{ + int value = 0; + if (m_classes.contains(name)) + value = m_classes.get(name); + + m_classes.set(name, value - 1); +} + +void ClassTracker::show() +{ + XLOG("*** Tracking %d classes ***", m_classes.size()); + for (HashMap<String, int>::iterator iter = m_classes.begin(); iter != m_classes.end(); ++iter) { + XLOG("class %s has %d instances", + iter->first.latin1().data(), iter->second); + } +} + +} // namespace WebCore diff --git a/WebCore/platform/graphics/android/ClassTracker.h b/WebCore/platform/graphics/android/ClassTracker.h new file mode 100644 index 0000000..0afde59 --- /dev/null +++ b/WebCore/platform/graphics/android/ClassTracker.h @@ -0,0 +1,51 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ClassTracker_h +#define ClassTracker_h + +#include <wtf/HashMap.h> +#include <wtf/text/StringHash.h> + +#define DEBUG_COUNT // Add instances tracking +#undef DEBUG_COUNT + +namespace WebCore { + +class ClassTracker { + public: + static ClassTracker* instance(); + void show(); + void increment(String name); + void decrement(String name); + private: + ClassTracker() {}; + HashMap<String, int> m_classes; + static ClassTracker* gInstance; +}; + +} + +#endif // ClassTracker_h diff --git a/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp b/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp index 31a1186..7dcd1bc 100644 --- a/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp +++ b/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "DoubleBufferedTexture.h" +#include "ClassTracker.h" #include "GLUtils.h" #define LOG_NDEBUG 1 @@ -34,14 +35,6 @@ namespace WebCore { -#ifdef DEBUG_COUNT -static int gDoubleBufferedTextureCount = 0; -int DoubleBufferedTexture::count() -{ - return gDoubleBufferedTextureCount; -} -#endif - DoubleBufferedTexture::DoubleBufferedTexture(EGLContext sharedContext) { m_display = eglGetCurrentDisplay(); @@ -50,16 +43,15 @@ DoubleBufferedTexture::DoubleBufferedTexture(EGLContext sharedContext) m_writeableTexture = &m_textureA; m_lockedConsumerTexture = GL_NO_TEXTURE; m_supportsEGLImage = GLUtils::isEGLImageSupported(); - #ifdef DEBUG_COUNT - gDoubleBufferedTextureCount++; + ClassTracker::instance()->increment("DoubleBufferedTexture"); #endif } DoubleBufferedTexture::~DoubleBufferedTexture() { #ifdef DEBUG_COUNT - gDoubleBufferedTextureCount--; + ClassTracker::instance()->decrement("DoubleBufferedTexture"); #endif } diff --git a/WebCore/platform/graphics/android/DoubleBufferedTexture.h b/WebCore/platform/graphics/android/DoubleBufferedTexture.h index c7f5f49..b611c2e 100644 --- a/WebCore/platform/graphics/android/DoubleBufferedTexture.h +++ b/WebCore/platform/graphics/android/DoubleBufferedTexture.h @@ -33,9 +33,6 @@ namespace WebCore { class DoubleBufferedTexture { public: -#ifdef DEBUG_COUNT - static int count(); -#endif // consumer thread functions DoubleBufferedTexture(EGLContext sharedContext); virtual ~DoubleBufferedTexture(); diff --git a/WebCore/platform/graphics/android/GLWebViewState.cpp b/WebCore/platform/graphics/android/GLWebViewState.cpp index fa1b055..2f9430a 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -29,6 +29,7 @@ #if USE(ACCELERATED_COMPOSITING) #include "BaseLayerAndroid.h" +#include "ClassTracker.h" #include "LayerAndroid.h" #include "TilesManager.h" @@ -55,14 +56,6 @@ namespace WebCore { using namespace android; -#ifdef DEBUG_COUNT -static int gGLWebViewStateCount = 0; -int GLWebViewState::count() -{ - return gGLWebViewStateCount; -} -#endif - GLWebViewState::GLWebViewState(android::Mutex* buttonMutex) : m_scaleRequestState(kNoScaleRequest) , m_currentScale(1) @@ -85,7 +78,7 @@ GLWebViewState::GLWebViewState(android::Mutex* buttonMutex) m_tiledPageA = new TiledPage(FIRST_TILED_PAGE_ID, this); m_tiledPageB = new TiledPage(SECOND_TILED_PAGE_ID, this); #ifdef DEBUG_COUNT - gGLWebViewStateCount++; + ClassTracker::instance()->increment("GLWebViewState"); #endif } @@ -95,7 +88,7 @@ GLWebViewState::~GLWebViewState() delete m_tiledPageA; delete m_tiledPageB; #ifdef DEBUG_COUNT - gGLWebViewStateCount--; + ClassTracker::instance()->decrement("GLWebViewState"); #endif } diff --git a/WebCore/platform/graphics/android/GLWebViewState.h b/WebCore/platform/graphics/android/GLWebViewState.h index 1ef35d3..7fa5e39 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.h +++ b/WebCore/platform/graphics/android/GLWebViewState.h @@ -141,9 +141,6 @@ class LayerAndroid; class GLWebViewState { public: -#ifdef DEBUG_COUNT - static int count(); -#endif enum GLScaleStates { kNoScaleRequest = 0, kWillScheduleRequest = 1, diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 277840d..5d6d8ff 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -4,6 +4,7 @@ #if USE(ACCELERATED_COMPOSITING) #include "AndroidAnimation.h" +#include "ClassTracker.h" #include "DrawExtra.h" #include "GLUtils.h" #include "MediaLayer.h" @@ -38,14 +39,8 @@ namespace WebCore { -static int gDebugLayerAndroidInstances; static int gUniqueId; -inline int LayerAndroid::instancesCount() -{ - return gDebugLayerAndroidInstances; -} - class OpacityDrawFilter : public SkDrawFilter { public: OpacityDrawFilter(int opacity) : m_opacity(opacity) { } @@ -87,7 +82,9 @@ LayerAndroid::LayerAndroid(bool isRootLayer) : SkLayer(), m_preserves3D = false; m_dirty = false; - gDebugLayerAndroidInstances++; +#ifdef DEBUG_COUNT + ClassTracker::instance()->increment("LayerAndroid"); +#endif } LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), @@ -134,7 +131,9 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), for (KeyframesMap::const_iterator it = layer.m_animations.begin(); it != end; ++it) m_animations.add((it->second)->name(), (it->second)->copy()); - gDebugLayerAndroidInstances++; +#ifdef DEBUG_COUNT + ClassTracker::instance()->increment("LayerAndroid"); +#endif } LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(), @@ -153,7 +152,9 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(), m_backgroundColor = 0; m_dirty = false; SkSafeRef(m_recordingPicture); - gDebugLayerAndroidInstances++; +#ifdef DEBUG_COUNT + ClassTracker::instance()->increment("LayerAndroid"); +#endif } void LayerAndroid::removeTexture(BackedDoubleBufferedTexture* aTexture) @@ -188,7 +189,9 @@ LayerAndroid::~LayerAndroid() m_contentsImage->safeUnref(); m_recordingPicture->safeUnref(); m_animations.clear(); - gDebugLayerAndroidInstances--; +#ifdef DEBUG_COUNT + ClassTracker::instance()->decrement("LayerAndroid"); +#endif } static int gDebugNbAnims = 0; diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 66fbe15..f4fea49 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -99,8 +99,6 @@ public: LayerTexture* texture() { return m_reservedTexture; } virtual TiledPage* page() { return 0; } - static int instancesCount(); - void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; } FloatPoint translation() const; SkRect bounds() const; diff --git a/WebCore/platform/graphics/android/LayerTexture.h b/WebCore/platform/graphics/android/LayerTexture.h index 0632abb..d323d6f 100644 --- a/WebCore/platform/graphics/android/LayerTexture.h +++ b/WebCore/platform/graphics/android/LayerTexture.h @@ -27,6 +27,7 @@ #define LayerTexture_h #include "BackedDoubleBufferedTexture.h" +#include "ClassTracker.h" #include "IntRect.h" namespace WebCore { @@ -40,8 +41,17 @@ class LayerTexture : public BackedDoubleBufferedTexture { , m_scale(1) , m_pictureUsed(0) , m_ready(false) - {} - virtual ~LayerTexture() {}; + { +#ifdef DEBUG_COUNT + ClassTracker::instance()->increment("LayerTexture"); +#endif + } + virtual ~LayerTexture() + { +#ifdef DEBUG_COUNT + ClassTracker::instance()->decrement("LayerTexture"); +#endif + }; int id() { return m_id; } void setId(int id) { m_id = id; } diff --git a/WebCore/platform/graphics/android/TileSet.cpp b/WebCore/platform/graphics/android/TileSet.cpp index 4530640..1214aa2 100644 --- a/WebCore/platform/graphics/android/TileSet.cpp +++ b/WebCore/platform/graphics/android/TileSet.cpp @@ -28,6 +28,7 @@ #if USE(ACCELERATED_COMPOSITING) +#include "ClassTracker.h" #include "TilesManager.h" #ifdef DEBUG @@ -48,28 +49,20 @@ namespace WebCore { -#ifdef DEBUG_COUNT -static int gTileSetCount = 0; -int TileSet::count() -{ - return gTileSetCount; -} -#endif - TileSet::TileSet(TiledPage* tiledPage, int rows, int cols) : m_tiledPage(tiledPage) , m_nbRows(rows) , m_nbCols(cols) { #ifdef DEBUG_COUNT - gTileSetCount++; + ClassTracker::instance()->increment("TileSet"); #endif } TileSet::~TileSet() { #ifdef DEBUG_COUNT - gTileSetCount--; + ClassTracker::instance()->decrement("TileSet"); #endif } diff --git a/WebCore/platform/graphics/android/TileSet.h b/WebCore/platform/graphics/android/TileSet.h index fd65ad7..0cb16d0 100644 --- a/WebCore/platform/graphics/android/TileSet.h +++ b/WebCore/platform/graphics/android/TileSet.h @@ -42,9 +42,6 @@ namespace WebCore { */ class TileSet { public: -#ifdef DEBUG_COUNT - static int count(); -#endif TileSet(TiledPage* tiledPage, int nbRows, int nbCols); ~TileSet(); diff --git a/WebCore/platform/graphics/android/TiledPage.cpp b/WebCore/platform/graphics/android/TiledPage.cpp index 2836d17..68f38ab 100644 --- a/WebCore/platform/graphics/android/TiledPage.cpp +++ b/WebCore/platform/graphics/android/TiledPage.cpp @@ -53,14 +53,6 @@ namespace WebCore { using namespace android; -#ifdef DEBUG_COUNT -static int gTilePageCount = 0; -int TiledPage::count() -{ - return gTilePageCount; -} -#endif - TiledPage::TiledPage(int id, GLWebViewState* state) : m_id(id) , m_scale(1) @@ -81,7 +73,7 @@ TiledPage::TiledPage(int id, GLWebViewState* state) m_baseTiles = new BaseTile[m_baseTileSize]; #ifdef DEBUG_COUNT - gTilePageCount++; + ClassTracker::instance()->increment("TiledPage"); #endif } @@ -92,7 +84,7 @@ TiledPage::~TiledPage() TilesManager::instance()->removeOperationsForPage(this); delete[] m_baseTiles; #ifdef DEBUG_COUNT - gTilePageCount--; + ClassTracker::instance()->decrement("TiledPage"); #endif } diff --git a/WebCore/platform/graphics/android/TiledPage.h b/WebCore/platform/graphics/android/TiledPage.h index a7402b9..6424f34 100644 --- a/WebCore/platform/graphics/android/TiledPage.h +++ b/WebCore/platform/graphics/android/TiledPage.h @@ -50,9 +50,6 @@ class IntRect; */ class TiledPage { public: -#ifdef DEBUG_COUNT - static int count(); -#endif TiledPage(int id, GLWebViewState* state); ~TiledPage(); |