diff options
author | Chris Craik <ccraik@google.com> | 2012-04-03 13:10:26 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-03 13:10:26 -0700 |
commit | 27ecdfb1b551244c4c15289fa375f07bee2f95da (patch) | |
tree | e77c338a22690b410af2ed707c4b88a81b390ad8 | |
parent | b568205d0cf87f22b14d32bae063d86dfdc73707 (diff) | |
parent | bf9aa54ac784685db3d2cd8c0d616b25b289c09e (diff) | |
download | external_webkit-27ecdfb1b551244c4c15289fa375f07bee2f95da.zip external_webkit-27ecdfb1b551244c4c15289fa375f07bee2f95da.tar.gz external_webkit-27ecdfb1b551244c4c15289fa375f07bee2f95da.tar.bz2 |
Merge "Use new draw-less functor execution mode to do work without redrawing"
8 files changed, 89 insertions, 78 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index a5080ca..4c4ca3d 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -37,6 +37,7 @@ #include "GLUtils.h" #include "ImagesManager.h" #include "LayerAndroid.h" +#include "private/hwui/DrawGlInfo.h" #include "ScrollableLayerAndroid.h" #include "SkPath.h" #include "TilesManager.h" @@ -301,10 +302,11 @@ bool GLWebViewState::setLayersRenderingMode(TexturesResult& nbTexturesNeeded) return (m_layersRenderingMode != layersRenderingMode && invalBase); } -bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, - IntRect& webViewRect, int titleBarHeight, - IntRect& clip, float scale, - bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr) +int GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, + IntRect& webViewRect, int titleBarHeight, + IntRect& clip, float scale, + bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr, + bool shouldDraw) { TilesManager* tilesManager = TilesManager::instance(); tilesManager->getProfiler()->nextFrame(viewport.fLeft, viewport.fTop, @@ -335,7 +337,9 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, // Upload any pending ImageTexture // Return true if we still have some images to upload. // TODO: upload as many textures as possible within a certain time limit - bool ret = ImagesManager::instance()->prepareTextures(this); + int returnFlags = 0; + if (ImagesManager::instance()->prepareTextures(this)) + returnFlags |= uirenderer::DrawGlInfo::kStatusDraw; if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING) { ALOGW("WARNING, scale seems corrupted after update: %e", scale); @@ -347,14 +351,13 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, double currentTime = setupDrawing(rect, viewport, webViewRect, titleBarHeight, clip, scale); - TexturesResult nbTexturesNeeded; bool fastSwap = isScrolling() || m_layersRenderingMode == kSingleSurfaceRendering; m_glExtras.setViewport(viewport); - ret |= m_surfaceCollectionManager.drawGL(currentTime, rect, viewport, - scale, fastSwap, - collectionsSwappedPtr, newCollectionHasAnimPtr, - &nbTexturesNeeded); + returnFlags |= m_surfaceCollectionManager.drawGL(currentTime, rect, viewport, + scale, fastSwap, + collectionsSwappedPtr, newCollectionHasAnimPtr, + &nbTexturesNeeded, shouldDraw); int nbTexturesForImages = ImagesManager::instance()->nbTextures(); ALOGV("*** We have %d textures for images, %d full, %d clipped, total %d / %d", @@ -363,15 +366,17 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, nbTexturesNeeded.clipped + nbTexturesForImages); nbTexturesNeeded.full += nbTexturesForImages; nbTexturesNeeded.clipped += nbTexturesForImages; - ret |= setLayersRenderingMode(nbTexturesNeeded); + + if (setLayersRenderingMode(nbTexturesNeeded)) + returnFlags |= uirenderer::DrawGlInfo::kStatusDraw | uirenderer::DrawGlInfo::kStatusInvoke; glBindBuffer(GL_ARRAY_BUFFER, 0); // Clean up GL textures for video layer. tilesManager->videoLayerManager()->deleteUnusedTextures(); - if (ret) { - // ret==true && empty inval region means we've inval'd everything, + if (returnFlags & uirenderer::DrawGlInfo::kStatusDraw) { + // returnFlags & kStatusDraw && empty inval region means we've inval'd everything, // but don't have new content. Keep redrawing full view (0,0,0,0) // until tile generation catches up and we swap pages. bool fullScreenInval = m_frameworkLayersInval.isEmpty(); @@ -401,9 +406,10 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, } } - showFrameInfo(rect, *collectionsSwappedPtr); + if (shouldDraw) + showFrameInfo(rect, *collectionsSwappedPtr); - return ret; + return returnFlags; } void GLWebViewState::showFrameInfo(const IntRect& rect, bool collectionsSwapped) diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h index e4b3b3b..82ef16e 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.h +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h @@ -177,10 +177,11 @@ public: bool setLayersRenderingMode(TexturesResult&); - bool drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, - IntRect& webViewRect, int titleBarHeight, - IntRect& clip, float scale, - bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr); + int drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, + IntRect& webViewRect, int titleBarHeight, + IntRect& clip, float scale, + bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr, + bool shouldDraw); #ifdef MEASURES_PERF void dumpMeasures(); diff --git a/Source/WebCore/platform/graphics/android/LayerGroup.cpp b/Source/WebCore/platform/graphics/android/LayerGroup.cpp index 7bdbd11..05180a4 100644 --- a/Source/WebCore/platform/graphics/android/LayerGroup.cpp +++ b/Source/WebCore/platform/graphics/android/LayerGroup.cpp @@ -221,9 +221,8 @@ bool LayerGroup::drawGL(bool layerTilesDisabled) // TODO: why this visibleArea is different from visibleRect at zooming for base? IntRect drawArea = visibleArea(); - askRedraw |= m_dualTiledTexture->drawGL(drawArea, opacity(), - drawTransform(), useAggressiveRendering(), - background()); + m_dualTiledTexture->drawGL(drawArea, opacity(), drawTransform(), + useAggressiveRendering(), background()); } // draw member layers (draws image textures, glextras) diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp index c3c4bda..91dba3c 100644 --- a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp +++ b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp @@ -31,6 +31,7 @@ #include "AndroidLog.h" #include "LayerGroup.h" +#include "private/hwui/DrawGlInfo.h" #include "TilesManager.h" #include "SurfaceCollection.h" @@ -147,7 +148,7 @@ bool SurfaceCollectionManager::updateWithSurfaceCollection(SurfaceCollection* ne m_paintingCollection = newCollection; m_paintingCollection->setIsPainting(m_drawingCollection); } - return m_paintingCollection && TilesManager::instance()->useDoubleBuffering(); + return m_drawingCollection && TilesManager::instance()->useDoubleBuffering(); } void SurfaceCollectionManager::updateScrollableLayer(int layerId, int x, int y) @@ -160,18 +161,18 @@ void SurfaceCollectionManager::updateScrollableLayer(int layerId, int x, int y) m_drawingCollection->updateScrollableLayer(layerId, x, y); } -bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, +int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, SkRect& visibleRect, float scale, bool enterFastSwapMode, bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr, - TexturesResult* texturesResultPtr) + TexturesResult* texturesResultPtr, bool shouldDraw) { m_fastSwapMode |= enterFastSwapMode; - ALOGV("drawGL, D %p, P %p, Q %p, fastSwap %d", - m_drawingCollection, m_paintingCollection, m_queuedCollection, m_fastSwapMode); + ALOGV("drawGL, D %p, P %p, Q %p, fastSwap %d shouldDraw %d", + m_drawingCollection, m_paintingCollection, + m_queuedCollection, m_fastSwapMode, shouldDraw); - bool ret = false; bool didCollectionSwap = false; if (m_paintingCollection) { ALOGV("preparing painting collection %p", m_paintingCollection); @@ -197,6 +198,23 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, m_drawingCollection->computeTexturesAmount(texturesResultPtr); } + // ask for kStatusInvoke while painting, kStatusDraw if we have content to be redrawn next frame + // returning 0 indicates all painting complete, no framework inval needed. + int returnFlags = 0; + + if (m_paintingCollection) + returnFlags |= uirenderer::DrawGlInfo::kStatusInvoke; + + if (!shouldDraw) { + if (didCollectionSwap) { + m_drawingCollection->swapTiles(); + returnFlags |= uirenderer::DrawGlInfo::kStatusDraw; + } + + return returnFlags; + } + + // =========================================================================== // Don't have a drawing collection, draw white background Color background = Color::white; if (m_drawingCollection) { @@ -214,7 +232,7 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, m_fastSwapMode = false; } else { // drawing isn't ready, must redraw - ret = true; + returnFlags |= uirenderer::DrawGlInfo::kStatusInvoke; } m_drawingCollection->evaluateAnimations(currentTime); @@ -231,15 +249,11 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, // If background is opaque, we can safely and efficiently clear it here. // Otherwise, we have to calculate all the missing tiles and blend the background. GLUtils::clearBackgroundIfOpaque(&background); - if (m_drawingCollection) - ret |= m_drawingCollection->drawGL(visibleRect); - - if (m_paintingCollection) { - ALOGV("still have painting collection %p", m_paintingCollection); - return true; - } + if (m_drawingCollection && m_drawingCollection->drawGL(visibleRect)) + returnFlags |= uirenderer::DrawGlInfo::kStatusDraw; - return ret; + ALOGV("returnFlags %d, m_paintingCollection %d ", returnFlags, m_paintingCollection); + return returnFlags; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h index 304d57f..cc98899 100644 --- a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h +++ b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h @@ -49,10 +49,10 @@ public: void updateScrollableLayer(int layerId, int x, int y); - bool drawGL(double currentTime, IntRect& viewRect, + int drawGL(double currentTime, IntRect& viewRect, SkRect& visibleRect, float scale, bool enterFastSwapMode, bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr, - TexturesResult* texturesResultPtr); + TexturesResult* texturesResultPtr, bool shouldDraw); private: void swap(); diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.cpp b/Source/WebCore/platform/graphics/android/TiledTexture.cpp index 11cf906..7087dc7 100644 --- a/Source/WebCore/platform/graphics/android/TiledTexture.cpp +++ b/Source/WebCore/platform/graphics/android/TiledTexture.cpp @@ -258,20 +258,19 @@ int TiledTexture::nbTextures(IntRect& area, float scale) return numberTextures; } -bool TiledTexture::drawGL(const IntRect& visibleArea, float opacity, +void TiledTexture::drawGL(const IntRect& visibleArea, float opacity, const TransformationMatrix* transform, const Color* background) { m_area = computeTilesArea(visibleArea, m_scale); if (m_area.width() == 0 || m_area.height() == 0) - return false; + return; float invScale = 1 / m_scale; const float tileWidth = TilesManager::tileWidth() * invScale; const float tileHeight = TilesManager::tileHeight() * invScale; int drawn = 0; - bool askRedraw = false; SkRegion missingRegion; bool translucentBaseSurface = @@ -287,7 +286,6 @@ bool TiledTexture::drawGL(const IntRect& visibleArea, float opacity, bool tileInView = tile->isTileVisible(m_area); if (tileInView) { - askRedraw |= !tile->isTileReady(); SkRect rect; rect.fLeft = tile->x() * tileWidth; rect.fTop = tile->y() * tileHeight; @@ -315,11 +313,8 @@ bool TiledTexture::drawGL(const IntRect& visibleArea, float opacity, if (translucentBaseSurface) drawMissingRegion(missingRegion, opacity, background); - ALOGV("TT %p drew %d tiles, redraw due to notready %d, scale %f", - this, drawn, askRedraw, m_scale); - - // need to redraw if some visible tile wasn't ready - return askRedraw; + ALOGV("TT %p drew %d tiles, scale %f", + this, drawn, m_scale); } void TiledTexture::drawMissingRegion(const SkRegion& region, float opacity, @@ -428,7 +423,7 @@ void DualTiledTexture::prepareGL(GLWebViewState* state, bool allowZoom, } } -bool DualTiledTexture::drawGL(const IntRect& visibleArea, float opacity, +void DualTiledTexture::drawGL(const IntRect& visibleArea, float opacity, const TransformationMatrix* transform, bool aggressiveRendering, const Color* background) { @@ -436,10 +431,7 @@ bool DualTiledTexture::drawGL(const IntRect& visibleArea, float opacity, if (aggressiveRendering && !m_zooming && m_frontTexture->isMissingContent()) m_backTexture->drawGL(visibleArea, opacity, transform); - bool needsRepaint = m_frontTexture->drawGL(visibleArea, opacity, transform, background); - needsRepaint |= m_zooming; - needsRepaint |= (m_scale <= 0); - return needsRepaint; + m_frontTexture->drawGL(visibleArea, opacity, transform, background); } void DualTiledTexture::markAsDirty(const SkRegion& dirtyArea) diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.h b/Source/WebCore/platform/graphics/android/TiledTexture.h index 2e19cea..7a6c499 100644 --- a/Source/WebCore/platform/graphics/android/TiledTexture.h +++ b/Source/WebCore/platform/graphics/android/TiledTexture.h @@ -62,7 +62,7 @@ public: TilePainter* painter, bool isLowResPrefetch = false, bool useExpandPrefetch = false); void swapTiles(); - bool drawGL(const IntRect& visibleArea, float opacity, + void drawGL(const IntRect& visibleArea, float opacity, const TransformationMatrix* transform, const Color* background = 0); void prepareTile(int x, int y, TilePainter* painter, @@ -102,7 +102,7 @@ public: const IntRect& prepareArea, const IntRect& unclippedArea, TilePainter* painter, bool aggressiveRendering); void swapTiles(); - bool drawGL(const IntRect& visibleArea, float opacity, + void drawGL(const IntRect& visibleArea, float opacity, const TransformationMatrix* transform, bool aggressiveRendering, const Color* background); void markAsDirty(const SkRegion& dirtyArea); @@ -114,7 +114,7 @@ public: } bool isReady() { - return !m_zooming && m_frontTexture->isReady(); + return !m_zooming && m_frontTexture->isReady() && m_scale > 0; } int nbTextures(IntRect& area, float scale) diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 37291de..9907e6f 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -248,13 +248,13 @@ void scrollRectOnScreen(const IntRect& rect) viewInvalidate(); } -bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, +int drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::IntRect& webViewRect, int titleBarHeight, - WebCore::IntRect& clip, float scale, int extras) + WebCore::IntRect& clip, float scale, int extras, bool shouldDraw) { #if USE(ACCELERATED_COMPOSITING) if (!m_baseLayer) - return false; + return 0; if (!m_glWebViewState) { TilesManager::instance()->setHighEndGfx(m_isHighEndGfx); @@ -270,12 +270,12 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, // if the zoom manager is still initializing. We will be redrawn // once the correct scale is set if (!m_visibleRect.isFinite()) - return false; + return 0; bool treesSwapped = false; bool newTreeHasAnim = false; - bool ret = m_glWebViewState->drawGL(viewRect, m_visibleRect, invalRect, + int ret = m_glWebViewState->drawGL(viewRect, m_visibleRect, invalRect, webViewRect, titleBarHeight, clip, scale, - &treesSwapped, &newTreeHasAnim); + &treesSwapped, &newTreeHasAnim, shouldDraw); if (treesSwapped) { ALOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); @@ -285,10 +285,9 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, checkException(env); } } - if (ret) - return !m_isDrawingPaused; + return m_isDrawingPaused ? 0 : ret; #endif - return false; + return 0; } PictureSet* draw(SkCanvas* canvas, SkColor bgColor, DrawExtras extras, bool split) @@ -688,8 +687,8 @@ private: // local state for WebView class GLDrawFunctor : Functor { public: GLDrawFunctor(WebView* _wvInstance, - bool(WebView::*_funcPtr)(WebCore::IntRect&, WebCore::IntRect*, - WebCore::IntRect&, int, WebCore::IntRect&, jfloat, jint), + int (WebView::*_funcPtr)(WebCore::IntRect&, WebCore::IntRect*, + WebCore::IntRect&, int, WebCore::IntRect&, jfloat, jint, bool), WebCore::IntRect _viewRect, float _scale, int _extras) { wvInstance = _wvInstance; funcPtr = _funcPtr; @@ -714,16 +713,15 @@ class GLDrawFunctor : Functor { WebCore::IntRect clip(info->clipLeft, info->clipTop, info->clipRight - info->clipLeft, info->clipBottom - info->clipTop); + bool shouldDraw = (messageId == uirenderer::DrawGlInfo::kModeDraw); TilesManager::instance()->shader()->setWebViewMatrix(info->transform, info->isLayer); - - bool retVal = (*wvInstance.*funcPtr)(localViewRect, &inval, webViewRect, - titlebarHeight, clip, scale, extras); - if (retVal) { + int returnFlags = (*wvInstance.*funcPtr)(localViewRect, &inval, webViewRect, + titlebarHeight, clip, scale, extras, shouldDraw); + if ((returnFlags & uirenderer::DrawGlInfo::kStatusDraw) != 0) { IntRect finalInval; - if (inval.isEmpty()) { + if (inval.isEmpty()) finalInval = webViewRect; - retVal = true; - } else { + else { finalInval.setX(webViewRect.x() + inval.x()); finalInval.setY(webViewRect.y() + titlebarHeight + inval.y()); finalInval.setWidth(inval.width()); @@ -734,8 +732,9 @@ class GLDrawFunctor : Functor { info->dirtyRight = finalInval.maxX(); info->dirtyBottom = finalInval.maxY(); } - // return 1 if invalidation needed, 0 otherwise - return retVal ? 1 : 0; + // return 1 if invalidation needed, 2 to request non-drawing functor callback, 0 otherwise + ALOGV("returnFlags are %d, shouldDraw %d", returnFlags, shouldDraw); + return returnFlags; } void updateRect(WebCore::IntRect& _viewRect) { viewRect = _viewRect; @@ -748,8 +747,8 @@ class GLDrawFunctor : Functor { } private: WebView* wvInstance; - bool (WebView::*funcPtr)(WebCore::IntRect&, WebCore::IntRect*, - WebCore::IntRect&, int, WebCore::IntRect&, float, int); + int (WebView::*funcPtr)(WebCore::IntRect&, WebCore::IntRect*, + WebCore::IntRect&, int, WebCore::IntRect&, float, int, bool); WebCore::IntRect viewRect; WebCore::IntRect webViewRect; jfloat scale; |