From bfeff6cd168c57722ca96c44f7c5caed26c98177 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Fri, 20 Apr 2012 15:55:00 -0700 Subject: DO NOT MERGE: Fix clipping issue due to webview animation(scaling) Our visibleRect didn't respect the webview animation scaling before. Get rid of the old code about scaling for ortho projection, we don't need it any more since we moved onto the clip info. Rename the viewport to visibleRect which is used more often. bug:5684832 Change-Id: I8f49cbfd776a95073414ecc31e2fb40642e1ae0d cherry-pick the master change: https://android-git.corp.google.com/g/#/c/183080/ --- .../platform/graphics/android/GLWebViewState.cpp | 18 +++++++++--------- .../platform/graphics/android/GLWebViewState.h | 2 +- .../graphics/android/rendering/ShaderProgram.cpp | 20 +++----------------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index a52a3fe..7a94eb5 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -288,14 +288,14 @@ bool GLWebViewState::setLayersRenderingMode(TexturesResult& nbTexturesNeeded) } // -rect(viewRect) is the webViewRect with inverted Y, in screen coordinate. -// -viewport(visibleRect) is the visible area in document coordinate. +// -visibleRect is the visible area in document coordinate. // They are both based on webViewRect and calculated in Java side. // // -clip is the final glViewport value in screen coordinate, and it contains the // animation translation/scale and FBO offset. // // TODO: Try to decrease the number of parameters as some info is redundant. -int GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, +int GLWebViewState::drawGL(IntRect& rect, SkRect& visibleRect, IntRect* invalRect, IntRect& webViewRect, int titleBarHeight, IntRect& clip, float scale, bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr, @@ -303,14 +303,14 @@ int GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, { TilesManager* tilesManager = TilesManager::instance(); if (shouldDraw) - tilesManager->getProfiler()->nextFrame(viewport.fLeft, viewport.fTop, - viewport.fRight, viewport.fBottom, + tilesManager->getProfiler()->nextFrame(visibleRect.fLeft, visibleRect.fTop, + visibleRect.fRight, visibleRect.fBottom, scale); tilesManager->incDrawGLCount(); - ALOGV("drawGL, rect/viewRect(%d, %d, %d, %d), viewport/visibleRect(%.2f, %.2f, %.2f, %.2f)", + ALOGV("drawGL, rect/viewRect(%d, %d, %d, %d), visibleRect(%.2f, %.2f, %.2f, %.2f)", rect.x(), rect.y(), rect.width(), rect.height(), - viewport.fLeft, viewport.fTop, viewport.fRight, viewport.fBottom); + visibleRect.fLeft, visibleRect.fTop, visibleRect.fRight, visibleRect.fBottom); ALOGV("drawGL, invalRect(%d, %d, %d, %d), webViewRect(%d, %d, %d, %d)" "clip/glViewport (%d, %d, %d, %d), scale %f titleBarHeight %d", @@ -340,12 +340,12 @@ int GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, // gather the textures we can use tilesManager->gatherTextures(); - double currentTime = setupDrawing(rect, viewport, webViewRect, titleBarHeight, clip, scale); + double currentTime = setupDrawing(rect, visibleRect, webViewRect, titleBarHeight, clip, scale); TexturesResult nbTexturesNeeded; bool fastSwap = isScrolling() || m_layersRenderingMode == kSingleSurfaceRendering; - m_glExtras.setViewport(viewport); - returnFlags |= m_surfaceCollectionManager.drawGL(currentTime, rect, viewport, + m_glExtras.setViewport(visibleRect); + returnFlags |= m_surfaceCollectionManager.drawGL(currentTime, rect, visibleRect, scale, fastSwap, collectionsSwappedPtr, newCollectionHasAnimPtr, &nbTexturesNeeded, shouldDraw); diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h index 2b28619..8d0f214 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.h +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h @@ -177,7 +177,7 @@ public: bool setLayersRenderingMode(TexturesResult&); - int drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, + int drawGL(IntRect& rect, SkRect& visibleRect, IntRect* invalRect, IntRect& webViewRect, int titleBarHeight, IntRect& clip, float scale, bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr, diff --git a/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp index 817efb8..bea418a 100644 --- a/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp @@ -376,23 +376,9 @@ void ShaderProgram::setupDrawing(const IntRect& viewRect, const SkRect& visibleR m_titleBarHeight = titleBarHeight; //// viewport //// - TransformationMatrix ortho; - GLUtils::setOrthographicMatrix(ortho, visibleRect.fLeft, visibleRect.fTop, - visibleRect.fRight, visibleRect.fBottom, -1000, 1000); - // In most case , visibleRect / viewRect * scale should 1.0, but for the - // translation case, the scale factor can be 1 but visibleRect is smaller - // than viewRect, we need to tune in this factor to make sure we scale them - // right. Conceptually, that means, no matter how animation affects the - // visibleRect, the scaling should respect the viewRect if zoomScale is 1.0. - // Note that at TiledPage, we already scale the tile size inversely to make - // zooming animation right. - float orthoScaleX = scale * visibleRect.width() / viewRect.width(); - float orthoScaleY = scale * visibleRect.height() / viewRect.height(); - - TransformationMatrix orthoScale; - orthoScale.scale3d(orthoScaleX, orthoScaleY, 1.0); - - m_visibleRectProjectionMatrix = ortho * orthoScale; + GLUtils::setOrthographicMatrix(m_visibleRectProjectionMatrix, visibleRect.fLeft, + visibleRect.fTop, visibleRect.fRight, visibleRect.fBottom, + -1000, 1000); ALOGV("set m_clipProjectionMatrix, %d, %d, %d, %d", screenClip.x(), screenClip.y(), screenClip.x() + screenClip.width(), -- cgit v1.1