diff options
| author | Chris Craik <ccraik@google.com> | 2011-12-12 17:57:47 -0800 | 
|---|---|---|
| committer | Chris Craik <ccraik@google.com> | 2011-12-13 08:44:20 -0800 | 
| commit | a3a38731f4eeb01d2a42965b6c875d957999969d (patch) | |
| tree | 9194082f9e4582d72482809a34c456d4f1fd79d1 /Source | |
| parent | a8919811c45b9aac7b20abfb3f5b0fb80deec795 (diff) | |
| download | external_webkit-a3a38731f4eeb01d2a42965b6c875d957999969d.zip external_webkit-a3a38731f4eeb01d2a42965b6c875d957999969d.tar.gz external_webkit-a3a38731f4eeb01d2a42965b6c875d957999969d.tar.bz2 | |
update callback mechanism, adds nativeDiscardAllTextures for TileBenchmark tool
bug:5062896
Depends on frameworks/base change: https://android-git.corp.google.com/g/#/c/154844/
Change-Id: I8e5101fa212568837fe002b14fb9171c2f6dfe22
Diffstat (limited to 'Source')
5 files changed, 44 insertions, 24 deletions
| diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h index cd8e78b..fdd2b0e 100644 --- a/Source/WebCore/platform/graphics/android/BaseTileTexture.h +++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h @@ -83,9 +83,6 @@ public:      bool acquire(TextureOwner* owner, bool force = false);      bool release(TextureOwner* owner); -    // removes Tile->Texture, and Texture->Tile links to fully discard the texture -    void releaseAndRemoveFromTile(); -      // set the texture owner if not busy. Return false if busy, true otherwise.      bool setOwner(TextureOwner* owner, bool force = false); diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index 41ebfef..42a9a57 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -155,7 +155,7 @@ void TilesManager::allocateTiles()           m_tilesTextures.size() * LAYER_TILE_WIDTH * LAYER_TILE_HEIGHT * 4 / 1024 / 1024);  } -void TilesManager::deallocateTextures(bool allTextures) +void TilesManager::discardTextures(bool allTextures, bool glTextures)  {      const unsigned int max = m_textures.size(); @@ -169,24 +169,32 @@ void TilesManager::deallocateTextures(bool allTextures)                  sparedDrawCount = std::max(sparedDrawCount, owner->drawCount());          }      } -    deallocateTexturesVector(sparedDrawCount, m_textures); -    deallocateTexturesVector(sparedDrawCount, m_tilesTextures); +    discardTexturesVector(sparedDrawCount, m_textures, glTextures); +    discardTexturesVector(sparedDrawCount, m_tilesTextures, glTextures);  } -void TilesManager::deallocateTexturesVector(unsigned long long sparedDrawCount, -                                            WTF::Vector<BaseTileTexture*>& textures) +void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount, +                                         WTF::Vector<BaseTileTexture*>& textures, +                                         bool deallocateGLTextures)  {      const unsigned int max = textures.size();      int dealloc = 0;      for (unsigned int i = 0; i < max; i++) {          TextureOwner* owner = textures[i]->owner();          if (!owner || owner->drawCount() < sparedDrawCount) { -            textures[i]->discardGLTexture(); +            if (deallocateGLTextures) { +                // deallocate textures' gl memory +                textures[i]->discardGLTexture(); +            } else if (owner) { +                // simply detach textures from owner +                static_cast<BaseTile*>(owner)->discardTextures(); +            }              dealloc++;          }      } -    XLOG("Deallocated %d gl textures (out of %d %s tiles)", -         dealloc, max, (textures == m_textures) ? "base" : "layer"); +    XLOG("Discarded %d %s textures (out of %d %s tiles)", +         dealloc, (deallocateGLTextures ? "gl" : ""), +         max, (textures == m_textures) ? "base" : "layer");  }  void TilesManager::gatherTexturesNumbers(int* nbTextures, int* nbAllocatedTextures, @@ -390,7 +398,8 @@ void TilesManager::setMaxLayerTextureCount(int max)          double secondsSinceLayersUsed = WTF::currentTime() - m_lastTimeLayersUsed;          if (secondsSinceLayersUsed > LAYER_TEXTURES_DESTROY_TIMEOUT) {              unsigned long long sparedDrawCount = ~0; // by default, spare no textures -            deallocateTexturesVector(sparedDrawCount, m_tilesTextures); +            bool deleteGLTextures = true; +            discardTexturesVector(sparedDrawCount, m_tilesTextures, deleteGLTextures);              m_hasLayerTextures = false;          }          return; diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index 9782fbb..424e226 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -119,8 +119,8 @@ public:      void allocateTiles(); -    // Called when webview is hidden to discard graphics memory -    void deallocateTextures(bool allTextures); +    // remove all tiles from textures (and optionally deallocate gl memory) +    void discardTextures(bool allTextures, bool glTextures);      bool getShowVisualIndicator()      { @@ -209,8 +209,9 @@ private:              m_generatorReadyCond.wait(m_generatorLock);      } -    void deallocateTexturesVector(unsigned long long sparedDrawCount, -                                  WTF::Vector<BaseTileTexture*>& textures); +    void discardTexturesVector(unsigned long long sparedDrawCount, +                               WTF::Vector<BaseTileTexture*>& textures, +                               bool deallocateGLTextures);      Vector<BaseTileTexture*> m_textures;      Vector<BaseTileTexture*> m_availableTextures; diff --git a/Source/WebCore/platform/graphics/android/TreeManager.cpp b/Source/WebCore/platform/graphics/android/TreeManager.cpp index b7eaacf..35ddeb8 100644 --- a/Source/WebCore/platform/graphics/android/TreeManager.cpp +++ b/Source/WebCore/platform/graphics/android/TreeManager.cpp @@ -245,6 +245,10 @@ bool TreeManager::drawGL(double currentTime, IntRect& viewRect,      if (m_drawingTree) {          bool drawingReady = didTreeSwap || m_drawingTree->isReady(); +        // call the page swap callback if registration happened without more trees enqueued +        if (treesSwappedPtr && drawingReady && !m_paintingTree) +            *treesSwappedPtr = true; +          if (didTreeSwap || m_fastSwapMode || (drawingReady && !m_paintingTree))              m_drawingTree->swapTiles(); diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 5e943ae..7861205 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -1907,7 +1907,7 @@ static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint native      return false;  } -static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint layer, jobject inval, +static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint nativeView, jint layer, jobject inval,                                  jboolean showVisualIndicator,                                  jboolean isPictureAfterFirstLayout,                                  jboolean registerPageSwapCallback) @@ -1916,7 +1916,7 @@ static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint layer, jobject inv      SkRegion invalRegion;      if (inval)          invalRegion = *GraphicsJNI::getNativeRegion(env, inval); -    GET_NATIVE_VIEW(env, obj)->setBaseLayer(layerImpl, invalRegion, showVisualIndicator, +    ((WebView*)nativeView)->setBaseLayer(layerImpl, invalRegion, showVisualIndicator,                                              isPictureAfterFirstLayout,                                              registerPageSwapCallback);  } @@ -2494,9 +2494,16 @@ static void nativeSetSelectionPointer(JNIEnv *env, jobject obj, jint nativeView,      ((WebView*)nativeView)->setSelectionPointer(set, scale, x, y);  } -static void nativeRegisterPageSwapCallback(JNIEnv *env, jobject obj) +static void nativeRegisterPageSwapCallback(JNIEnv *env, jobject obj, jint nativeView)  { -    GET_NATIVE_VIEW(env, obj)->registerPageSwapCallback(); +    ((WebView*)nativeView)->registerPageSwapCallback(); +} + +static void nativeDiscardAllTextures(JNIEnv *env, jobject obj) +{ +    //discard all textures for debugging/test purposes, but not gl backing memory +    bool allTextures = true, deleteGLTextures = false; +    TilesManager::instance()->discardTextures(allTextures, deleteGLTextures);  }  static void nativeTileProfilingStart(JNIEnv *env, jobject obj) @@ -2593,8 +2600,8 @@ static jstring nativeGetProperty(JNIEnv *env, jobject obj, jstring key)  static void nativeOnTrimMemory(JNIEnv *env, jobject obj, jint level)  {      if (TilesManager::hardwareAccelerationEnabled()) { -        bool freeAllTextures = (level > TRIM_MEMORY_UI_HIDDEN); -        TilesManager::instance()->deallocateTextures(freeAllTextures); +        bool freeAllTextures = (level > TRIM_MEMORY_UI_HIDDEN), glTextures = true; +        TilesManager::instance()->discardTextures(freeAllTextures, glTextures);      }  } @@ -2850,7 +2857,7 @@ static JNINativeMethod gJavaWebViewMethods[] = {          (void*) nativeSetFindIsUp },      { "nativeSetHeightCanMeasure", "(Z)V",          (void*) nativeSetHeightCanMeasure }, -    { "nativeSetBaseLayer", "(ILandroid/graphics/Region;ZZZ)V", +    { "nativeSetBaseLayer", "(IILandroid/graphics/Region;ZZZ)V",          (void*) nativeSetBaseLayer },      { "nativeGetTextSelectionRegion", "(ILandroid/graphics/Region;)V",          (void*) nativeGetTextSelectionRegion }, @@ -2868,8 +2875,10 @@ static JNINativeMethod gJavaWebViewMethods[] = {          (void*) nativeSetSelectionPointer },      { "nativeShowCursorTimed", "()V",          (void*) nativeShowCursorTimed }, -    { "nativeRegisterPageSwapCallback", "()V", +    { "nativeRegisterPageSwapCallback", "(I)V",          (void*) nativeRegisterPageSwapCallback }, +    { "nativeDiscardAllTextures", "()V", +        (void*) nativeDiscardAllTextures },      { "nativeTileProfilingStart", "()V",          (void*) nativeTileProfilingStart },      { "nativeTileProfilingStop", "()F", | 
