summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform')
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp97
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h28
-rw-r--r--Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp24
-rw-r--r--Source/WebCore/platform/graphics/android/layers/CanvasLayer.h4
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp51
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.h4
-rw-r--r--Source/WebCore/platform/graphics/android/layers/MediaLayer.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/GLExtras.h7
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp14
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp138
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ShaderProgram.h38
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.cpp46
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.h6
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp20
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h4
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp12
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h6
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp8
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp16
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TileGrid.h4
22 files changed, 282 insertions, 251 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 89c0ead..bdd8028 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -65,14 +65,14 @@ using namespace android;
GLWebViewState::GLWebViewState()
: m_frameworkLayersInval(0, 0, 0, 0)
, m_isScrolling(false)
- , m_isViewportScrolling(false)
+ , m_isVisibleContentRectScrolling(false)
, m_goingDown(true)
, m_goingLeft(false)
, m_scale(1)
, m_layersRenderingMode(kAllTextures)
, m_surfaceCollectionManager()
{
- m_viewport.setEmpty();
+ m_visibleContentRect.setEmpty();
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("GLWebViewState");
@@ -123,14 +123,16 @@ void GLWebViewState::scrollLayer(int layerId, int x, int y)
m_surfaceCollectionManager.updateScrollableLayer(layerId, x, y);
}
-void GLWebViewState::setViewport(const SkRect& viewport, float scale)
+void GLWebViewState::setVisibleContentRect(const SkRect& visibleContentRect, float scale)
{
- // allocate max possible number of tiles visible with this viewport / expandedTileBounds
+ // allocate max possible number of tiles visible with this visibleContentRect / expandedTileBounds
const float invTileContentWidth = scale / TilesManager::tileWidth();
const float invTileContentHeight = scale / TilesManager::tileHeight();
- int viewMaxTileX = static_cast<int>(ceilf((viewport.width()-1) * invTileContentWidth)) + 1;
- int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1;
+ int viewMaxTileX =
+ static_cast<int>(ceilf((visibleContentRect.width()-1) * invTileContentWidth)) + 1;
+ int viewMaxTileY =
+ static_cast<int>(ceilf((visibleContentRect.height()-1) * invTileContentHeight)) + 1;
TilesManager* tilesManager = TilesManager::instance();
int maxTextureCount = viewMaxTileX * viewMaxTileY * (tilesManager->highEndGfx() ? 4 : 2);
@@ -138,24 +140,26 @@ void GLWebViewState::setViewport(const SkRect& viewport, float scale)
tilesManager->setCurrentTextureCount(maxTextureCount);
// TODO: investigate whether we can move this return earlier.
- if ((m_viewport == viewport)
+ if ((m_visibleContentRect == visibleContentRect)
&& (m_scale == scale)) {
// everything below will stay the same, early return.
- m_isViewportScrolling = false;
+ m_isVisibleContentRectScrolling = false;
return;
}
m_scale = scale;
- m_goingDown = m_viewport.fTop - viewport.fTop <= 0;
- m_goingLeft = m_viewport.fLeft - viewport.fLeft >= 0;
+ m_goingDown = m_visibleContentRect.fTop - visibleContentRect.fTop <= 0;
+ m_goingLeft = m_visibleContentRect.fLeft - visibleContentRect.fLeft >= 0;
- // detect viewport scrolling from short programmatic scrolls/jumps
- m_isViewportScrolling = m_viewport != viewport && SkRect::Intersects(m_viewport, viewport);
- m_viewport = viewport;
+ // detect visibleContentRect scrolling from short programmatic scrolls/jumps
+ m_isVisibleContentRectScrolling = m_visibleContentRect != visibleContentRect
+ && SkRect::Intersects(m_visibleContentRect, visibleContentRect);
+ m_visibleContentRect = visibleContentRect;
- ALOGV("New VIEWPORT %.2f - %.2f %.2f - %.2f (w: %2.f h: %.2f scale: %.2f )",
- m_viewport.fLeft, m_viewport.fTop, m_viewport.fRight, m_viewport.fBottom,
- m_viewport.width(), m_viewport.height(), scale);
+ ALOGV("New visibleContentRect %.2f - %.2f %.2f - %.2f (w: %2.f h: %.2f scale: %.2f )",
+ m_visibleContentRect.fLeft, m_visibleContentRect.fTop,
+ m_visibleContentRect.fRight, m_visibleContentRect.fBottom,
+ m_visibleContentRect.width(), m_visibleContentRect.height(), scale);
}
#ifdef MEASURES_PERF
@@ -192,8 +196,9 @@ void GLWebViewState::resetLayersDirtyArea()
m_frameworkLayersInval.setHeight(0);
}
-double GLWebViewState::setupDrawing(const IntRect& viewRect, const SkRect& visibleRect,
- const IntRect& webViewRect, int titleBarHeight,
+double GLWebViewState::setupDrawing(const IntRect& invScreenRect,
+ const SkRect& visibleContentRect,
+ const IntRect& screenRect, int titleBarHeight,
const IntRect& screenClip, float scale)
{
TilesManager* tilesManager = TilesManager::instance();
@@ -212,12 +217,12 @@ double GLWebViewState::setupDrawing(const IntRect& viewRect, const SkRect& visib
transferQueue->initGLResources(TilesManager::tileWidth(),
TilesManager::tileHeight());
}
- shader->setupDrawing(viewRect, visibleRect, webViewRect,
+ shader->setupDrawing(invScreenRect, visibleContentRect, screenRect,
titleBarHeight, screenClip, scale);
double currentTime = WTF::currentTime();
- setViewport(visibleRect, scale);
+ setVisibleContentRect(visibleContentRect, scale);
return currentTime;
}
@@ -287,36 +292,39 @@ bool GLWebViewState::setLayersRenderingMode(TexturesResult& nbTexturesNeeded)
return (m_layersRenderingMode != layersRenderingMode && invalBase);
}
-// -rect(viewRect) is the webViewRect with inverted Y, in screen coordinate.
-// -visibleRect is the visible area in document coordinate.
-// They are both based on webViewRect and calculated in Java side.
+// -invScreenRect is the webView's rect with inverted Y screen coordinate.
+// -visibleContentRect is the visible area in content coordinate.
+// They are both based on webView's rect and calculated in Java side.
//
-// -clip is the final glViewport value in screen coordinate, and it contains the
-// animation translation/scale and FBO offset.
+// -screenClip is in screen coordinate, so we need to invert the Y axis before
+// passing into GL functions. Clip can be smaller than the webView's rect.
//
// TODO: Try to decrease the number of parameters as some info is redundant.
-int GLWebViewState::drawGL(IntRect& rect, SkRect& visibleRect, IntRect* invalRect,
- IntRect& webViewRect, int titleBarHeight,
- IntRect& clip, float scale,
+int GLWebViewState::drawGL(IntRect& invScreenRect, SkRect& visibleContentRect,
+ IntRect* invalRect, IntRect& screenRect, int titleBarHeight,
+ IntRect& screenClip, float scale,
bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr,
bool shouldDraw)
{
TilesManager* tilesManager = TilesManager::instance();
if (shouldDraw)
- tilesManager->getProfiler()->nextFrame(visibleRect.fLeft, visibleRect.fTop,
- visibleRect.fRight, visibleRect.fBottom,
+ tilesManager->getProfiler()->nextFrame(visibleContentRect.fLeft,
+ visibleContentRect.fTop,
+ visibleContentRect.fRight,
+ visibleContentRect.fBottom,
scale);
tilesManager->incDrawGLCount();
- ALOGV("drawGL, rect/viewRect(%d, %d, %d, %d), visibleRect(%.2f, %.2f, %.2f, %.2f)",
- rect.x(), rect.y(), rect.width(), rect.height(),
- visibleRect.fLeft, visibleRect.fTop, visibleRect.fRight, visibleRect.fBottom);
+ ALOGV("drawGL, invScreenRect(%d, %d, %d, %d), visibleContentRect(%.2f, %.2f, %.2f, %.2f)",
+ invScreenRect.x(), invScreenRect.y(), invScreenRect.width(), invScreenRect.height(),
+ visibleContentRect.fLeft, visibleContentRect.fTop,
+ visibleContentRect.fRight, visibleContentRect.fBottom);
- ALOGV("drawGL, invalRect(%d, %d, %d, %d), webViewRect(%d, %d, %d, %d)"
- "clip/glViewport (%d, %d, %d, %d), scale %f titleBarHeight %d",
+ ALOGV("drawGL, invalRect(%d, %d, %d, %d), screenRect(%d, %d, %d, %d)"
+ "screenClip (%d, %d, %d, %d), scale %f titleBarHeight %d",
invalRect->x(), invalRect->y(), invalRect->width(), invalRect->height(),
- webViewRect.x(), webViewRect.y(), webViewRect.width(), webViewRect.height(),
- clip.x(), clip.y(), clip.width(), clip.height(), scale, titleBarHeight);
+ screenRect.x(), screenRect.y(), screenRect.width(), screenRect.height(),
+ screenClip.x(), screenClip.y(), screenClip.width(), screenClip.height(), scale, titleBarHeight);
resetLayersDirtyArea();
@@ -340,14 +348,17 @@ int GLWebViewState::drawGL(IntRect& rect, SkRect& visibleRect, IntRect* invalRec
// gather the textures we can use
tilesManager->gatherTextures();
- double currentTime = setupDrawing(rect, visibleRect, webViewRect, titleBarHeight, clip, scale);
+ double currentTime = setupDrawing(invScreenRect, visibleContentRect, screenRect,
+ titleBarHeight, screenClip, scale);
TexturesResult nbTexturesNeeded;
bool fastSwap = isScrolling() || m_layersRenderingMode == kSingleSurfaceRendering;
- m_glExtras.setViewport(visibleRect);
- returnFlags |= m_surfaceCollectionManager.drawGL(currentTime, rect, visibleRect,
+ m_glExtras.setVisibleContentRect(visibleContentRect);
+ returnFlags |= m_surfaceCollectionManager.drawGL(currentTime, invScreenRect,
+ visibleContentRect,
scale, fastSwap,
- collectionsSwappedPtr, newCollectionHasAnimPtr,
+ collectionsSwappedPtr,
+ newCollectionHasAnimPtr,
&nbTexturesNeeded, shouldDraw);
int nbTexturesForImages = ImagesManager::instance()->nbTextures();
@@ -380,7 +391,7 @@ int GLWebViewState::drawGL(IntRect& rect, SkRect& visibleRect, IntRect* invalRec
ALOGV("invalRect(%d, %d, %d, %d)", inval.x(),
inval.y(), inval.width(), inval.height());
- if (!invalRect->intersects(rect)) {
+ if (!invalRect->intersects(invScreenRect)) {
// invalidate is occurring offscreen, do full inval to guarantee redraw
fullScreenInval = true;
}
@@ -395,7 +406,7 @@ int GLWebViewState::drawGL(IntRect& rect, SkRect& visibleRect, IntRect* invalRec
}
if (shouldDraw)
- showFrameInfo(rect, *collectionsSwappedPtr);
+ showFrameInfo(invScreenRect, *collectionsSwappedPtr);
return returnFlags;
}
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h
index 8d0f214..7892e83 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -75,7 +75,7 @@ class TexturesResult;
//
// The rendering model is to use tiles to display the BaseLayer (as obviously a
// BaseLayer's area can be arbitrarly large). The idea is to compute a set of
-// tiles covering the viewport's area, paint those tiles using the webview's
+// tiles covering the visibleContentRect's area, paint those tiles using the webview's
// content (i.e. the BaseLayer's PictureSet), then display those tiles.
// We check which tile we should use at every frame.
//
@@ -86,7 +86,7 @@ class TexturesResult;
// the BaseLayer's surface. When drawing, we ask the TiledPage to prepare()
// itself then draw itself on screen. The prepare() function is the one
// that schedules tiles to be painted -- i.e. the subset of tiles that intersect
-// with the current viewport. When they are ready, we can display
+// with the current visibleContentRect. When they are ready, we can display
// the TiledPage.
//
// Note that BaseLayerAndroid::drawGL() will return true to the java side if
@@ -102,7 +102,7 @@ class TexturesResult;
// accordingly (and therefore possible loss of quality): this is fast as it's
// purely a hardware operation. When the user is done zooming, we ask for
// TiledPage B to be painted at the new scale factor, covering the
-// viewport's area. When B is ready, we swap it with A.
+// visibleContentRect's area. When B is ready, we swap it with A.
//
// Texture allocation
// ------------------
@@ -111,17 +111,17 @@ class TexturesResult;
// get the GL textures from an existing pool, and reuse them.
//
// The way we do it is that when we call TiledPage::prepare(), we group the
-// tiles we need (i.e. in the viewport and dirty) into a TilesSet and call
+// tiles we need (i.e. in the visibleContentRect and dirty) into a TilesSet and call
// Tile::reserveTexture() for each tile (which ensures there is a specific
// GL textures backing the Tiles).
//
// reserveTexture() will ask the TilesManager for a texture. The allocation
// mechanism goal is to (in order):
// - prefers to allocate the same texture as the previous time
-// - prefers to allocate textures that are as far from the viewport as possible
+// - prefers to allocate textures that are as far from the visibleContentRect as possible
// - prefers to allocate textures that are used by different TiledPages
//
-// Note that to compute the distance of each tile from the viewport, each time
+// Note that to compute the distance of each tile from the visibleContentRect, each time
// we prepare() a TiledPage. Also during each prepare() we compute which tiles
// are dirty based on the info we have received from webkit.
//
@@ -173,12 +173,12 @@ public:
GLExtras* glExtras() { return &m_glExtras; }
void setIsScrolling(bool isScrolling) { m_isScrolling = isScrolling; }
- bool isScrolling() { return m_isScrolling || m_isViewportScrolling; }
+ bool isScrolling() { return m_isScrolling || m_isVisibleContentRectScrolling; }
bool setLayersRenderingMode(TexturesResult&);
- int drawGL(IntRect& rect, SkRect& visibleRect, IntRect* invalRect,
- IntRect& webViewRect, int titleBarHeight,
+ int drawGL(IntRect& rect, SkRect& visibleContentRect, IntRect* invalRect,
+ IntRect& screenRect, int titleBarHeight,
IntRect& clip, float scale,
bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr,
bool shouldDraw);
@@ -208,16 +208,16 @@ public:
void scrollLayer(int layerId, int x, int y);
private:
- void setViewport(const SkRect& viewport, float scale);
- double setupDrawing(const IntRect& viewRect, const SkRect& visibleRect,
- const IntRect& webViewRect, int titleBarHeight,
+ void setVisibleContentRect(const SkRect& visibleContentRect, float scale);
+ double setupDrawing(const IntRect& invScreenRect, const SkRect& visibleContentRect,
+ const IntRect& screenRect, int titleBarHeight,
const IntRect& screenClip, float scale);
void showFrameInfo(const IntRect& rect, bool collectionsSwapped);
void clearRectWithColor(const IntRect& rect, float r, float g,
float b, float a);
double m_prevDrawTime;
- SkRect m_viewport;
+ SkRect m_visibleContentRect;
IntRect m_frameworkLayersInval;
#ifdef MEASURES_PERF
@@ -229,7 +229,7 @@ private:
GLExtras m_glExtras;
bool m_isScrolling;
- bool m_isViewportScrolling;
+ bool m_isVisibleContentRectScrolling;
bool m_goingDown;
bool m_goingLeft;
diff --git a/Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp b/Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp
index 1813903..40332d0 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp
@@ -63,13 +63,13 @@ CanvasLayer::CanvasLayer(const CanvasLayer& layer)
if (!layer.m_canvas) {
// The canvas has already been destroyed - this shouldn't happen
ALOGW("Creating a CanvasLayer for a destroyed canvas!");
- m_contentRect = IntRect();
+ m_visibleContentRect = IntRect();
m_offsetFromRenderer = IntSize();
m_texture->setHwAccelerated(false);
return;
}
// We are making a copy for the UI, sync the interesting bits
- m_contentRect = layer.contentRect();
+ m_visibleContentRect = layer.visibleContentRect();
m_offsetFromRenderer = layer.offsetFromRenderer();
bool previousState = m_texture->hasValidTexture();
if (!previousState && layer.m_dirtyCanvas.isEmpty()) {
@@ -86,7 +86,7 @@ CanvasLayer::CanvasLayer(const CanvasLayer& layer)
// Merge the canvas invals with the layer's invals to repaint the needed
// tiles.
SkRegion::Iterator iter(layer.m_dirtyCanvas);
- const IntPoint& offset = m_contentRect.location();
+ const IntPoint& offset = m_visibleContentRect.location();
for (; !iter.done(); iter.next()) {
SkIRect diff = iter.rect();
diff.fLeft += offset.x();
@@ -98,8 +98,8 @@ CanvasLayer::CanvasLayer(const CanvasLayer& layer)
}
if (previousState != m_texture->hasValidTexture()) {
// Need to do a full inval of the canvas content as we are mode switching
- m_dirtyRegion.op(m_contentRect.x(), m_contentRect.y(),
- m_contentRect.maxX(), m_contentRect.maxY(), SkRegion::kUnion_Op);
+ m_dirtyRegion.op(m_visibleContentRect.x(), m_visibleContentRect.y(),
+ m_visibleContentRect.maxX(), m_visibleContentRect.maxY(), SkRegion::kUnion_Op);
}
}
}
@@ -160,7 +160,7 @@ SkBitmapRef* CanvasLayer::bitmap() const
return m_canvas->copiedImage()->nativeImageForCurrentFrame();
}
-IntRect CanvasLayer::contentRect() const
+IntRect CanvasLayer::visibleContentRect() const
{
if (!m_canvas
|| !m_canvas->renderer()
@@ -187,9 +187,9 @@ void CanvasLayer::contentDraw(SkCanvas* canvas, PaintStyle style)
if (!m_bitmap)
return;
SkBitmap& bitmap = m_bitmap->bitmap();
- SkRect dst = SkRect::MakeXYWH(m_contentRect.x() - m_offsetFromRenderer.width(),
- m_contentRect.y() - m_offsetFromRenderer.height(),
- m_contentRect.width(), m_contentRect.height());
+ SkRect dst = SkRect::MakeXYWH(m_visibleContentRect.x() - m_offsetFromRenderer.width(),
+ m_visibleContentRect.y() - m_offsetFromRenderer.height(),
+ m_visibleContentRect.width(), m_visibleContentRect.height());
canvas->drawBitmapRect(bitmap, 0, dst, 0);
}
@@ -198,9 +198,9 @@ bool CanvasLayer::drawGL(bool layerTilesDisabled)
bool ret = LayerAndroid::drawGL(layerTilesDisabled);
m_texture->requireTexture();
if (!m_bitmap && m_texture->updateTexImage()) {
- SkRect rect = SkRect::MakeXYWH(m_contentRect.x() - m_offsetFromRenderer.width(),
- m_contentRect.y() - m_offsetFromRenderer.height(),
- m_contentRect.width(), m_contentRect.height());
+ SkRect rect = SkRect::MakeXYWH(m_visibleContentRect.x() - m_offsetFromRenderer.width(),
+ m_visibleContentRect.y() - m_offsetFromRenderer.height(),
+ m_visibleContentRect.width(), m_visibleContentRect.height());
TextureQuadData data(m_texture->texture(), GL_TEXTURE_EXTERNAL_OES,
GL_LINEAR, LayerQuad, &m_drawTransform, &rect);
TilesManager::instance()->shader()->drawQuad(&data);
diff --git a/Source/WebCore/platform/graphics/android/layers/CanvasLayer.h b/Source/WebCore/platform/graphics/android/layers/CanvasLayer.h
index 532dbf2..2bfed1e 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasLayer.h
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasLayer.h
@@ -63,11 +63,11 @@ private:
void init();
SkBitmapRef* bitmap() const;
- IntRect contentRect() const;
+ IntRect visibleContentRect() const;
IntSize offsetFromRenderer() const;
HTMLCanvasElement* m_canvas;
- IntRect m_contentRect;
+ IntRect m_visibleContentRect;
IntSize m_offsetFromRenderer;
SkRegion m_dirtyCanvas;
SkBitmapRef* m_bitmap;
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index 535d211..f0d83ac 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -249,9 +249,12 @@ void LayerAndroid::addDirtyArea()
{
IntSize layerSize(getSize().width(), getSize().height());
- FloatRect area = TilesManager::instance()->shader()->rectInInvScreenCoord(m_drawTransform, layerSize);
- FloatRect clippingRect = TilesManager::instance()->shader()->rectInScreenCoord(m_clippingRect);
- FloatRect clip = TilesManager::instance()->shader()->convertScreenCoordToInvScreenCoord(clippingRect);
+ FloatRect area =
+ TilesManager::instance()->shader()->rectInViewCoord(m_drawTransform, layerSize);
+ FloatRect clippingRect =
+ TilesManager::instance()->shader()->rectInInvViewCoord(m_clippingRect);
+ FloatRect clip =
+ TilesManager::instance()->shader()->convertInvViewCoordToViewCoord(clippingRect);
area.intersect(clip);
IntRect dirtyArea(area.x(), area.y(), area.width(), area.height());
@@ -410,7 +413,8 @@ void LayerAndroid::updatePositions()
}
void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentMatrix,
- const FloatRect& clipping, float opacity, float scale)
+ const FloatRect& clipping, float opacity,
+ float scale)
{
IntSize layerSize(getSize().width(), getSize().height());
FloatPoint anchorPoint(getAnchorPoint().fX, getAnchorPoint().fY);
@@ -441,7 +445,9 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
m_drawTransform.setM42(desiredContentY);
}
- m_zValue = TilesManager::instance()->shader()->zValue(m_drawTransform, getSize().width(), getSize().height());
+ m_zValue = TilesManager::instance()->shader()->zValue(m_drawTransform,
+ getSize().width(),
+ getSize().height());
m_atomicSync.lock();
m_scale = scale;
@@ -451,7 +457,8 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
setDrawOpacity(opacity);
if (m_haveClip) {
- // The clipping rect calculation and intersetion will be done in documents coordinates.
+ // The clipping rect calculation and intersetion will be done in content
+ // coordinates.
FloatRect rect(0, 0, layerSize.width(), layerSize.height());
FloatRect clip = m_drawTransform.mapRect(rect);
clip.intersect(clipping);
@@ -461,7 +468,8 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
}
ALOGV("%s - %d %f %f %f %f",
subclassType() == BaseLayer ? "BASE" : "nonbase",
- m_haveClip, m_clippingRect.x(), m_clippingRect.y(), m_clippingRect.width(), m_clippingRect.height());
+ m_haveClip, m_clippingRect.x(), m_clippingRect.y(),
+ m_clippingRect.width(), m_clippingRect.height());
if (!m_backfaceVisibility
&& m_drawTransform.inverse().m33() < 0) {
@@ -548,7 +556,7 @@ IntRect LayerAndroid::clippedRect() const
{
IntRect r(0, 0, getWidth(), getHeight());
IntRect tr = m_drawTransform.mapRect(r);
- IntRect cr = TilesManager::instance()->shader()->clippedRectWithViewport(tr);
+ IntRect cr = TilesManager::instance()->shader()->clippedRectWithVisibleContentRect(tr);
IntRect rect = m_drawTransform.inverse().mapRect(cr);
return rect;
}
@@ -582,20 +590,21 @@ void LayerAndroid::showLayer(int indent)
if (!indent) {
ALOGD("\n\n--- LAYERS TREE ---");
- IntRect documentViewport(TilesManager::instance()->shader()->documentViewport());
- ALOGD("documentViewport(%d, %d, %d, %d)",
- documentViewport.x(), documentViewport.y(),
- documentViewport.width(), documentViewport.height());
+ IntRect contentViewport(TilesManager::instance()->shader()->contentViewport());
+ ALOGD("contentViewport(%d, %d, %d, %d)",
+ contentViewport.x(), contentViewport.y(),
+ contentViewport.width(), contentViewport.height());
}
IntRect r(0, 0, getWidth(), getHeight());
IntRect tr = m_drawTransform.mapRect(r);
- IntRect visible = visibleArea();
+ IntRect visible = visibleContentArea();
IntRect clip(m_clippingRect.x(), m_clippingRect.y(),
m_clippingRect.width(), m_clippingRect.height());
ALOGD("%s %s %s (%d) [%d:0x%x] - %s %s - area (%d, %d, %d, %d) - visible (%d, %d, %d, %d) "
"clip (%d, %d, %d, %d) %s %s m_content(%x), pic w: %d h: %d",
- spaces, m_haveClip ? "CLIP LAYER" : "", subclassName().ascii().data(), subclassType(), uniqueId(), m_owningLayer,
+ spaces, m_haveClip ? "CLIP LAYER" : "", subclassName().ascii().data(),
+ subclassType(), uniqueId(), m_owningLayer,
needsTexture() ? "needs a texture" : "no texture",
m_imageCRC ? "has an image" : "no image",
tr.x(), tr.y(), tr.width(), tr.height(),
@@ -750,7 +759,7 @@ int LayerAndroid::setHwAccelerated(bool hwAccelerated)
return flags | onSetHwAccelerated(hwAccelerated);
}
-IntRect LayerAndroid::unclippedArea()
+IntRect LayerAndroid::fullContentArea()
{
IntRect area;
area.setX(0);
@@ -760,13 +769,13 @@ IntRect LayerAndroid::unclippedArea()
return area;
}
-IntRect LayerAndroid::visibleArea()
+IntRect LayerAndroid::visibleContentArea()
{
- IntRect area = unclippedArea();
+ IntRect area = fullContentArea();
if (subclassType() == LayerAndroid::FixedBackgroundBaseLayer)
return area;
// First, we get the transformed area of the layer,
- // in document coordinates
+ // in content coordinates
IntRect rect = m_drawTransform.mapRect(area);
int dx = rect.x();
int dy = rect.y();
@@ -775,9 +784,9 @@ IntRect LayerAndroid::visibleArea()
IntRect clip(m_clippingRect);
rect.intersect(clip);
- // Now clip with the viewport in documents coordinate
- IntRect documentViewport(TilesManager::instance()->shader()->documentViewport());
- rect.intersect(documentViewport);
+ // Now clip with the viewport in content coordinate
+ IntRect contentViewport(TilesManager::instance()->shader()->contentViewport());
+ rect.intersect(contentViewport);
// Finally, let's return the visible area, in layers coordinate
rect.move(-dx, -dy);
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
index ca833f7..170ef41 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
@@ -140,8 +140,8 @@ public:
IntRect clippedRect() const;
bool outsideViewport();
- IntRect unclippedArea();
- IntRect visibleArea();
+ IntRect fullContentArea();
+ IntRect visibleContentArea();
virtual bool needsTexture();
diff --git a/Source/WebCore/platform/graphics/android/layers/MediaLayer.cpp b/Source/WebCore/platform/graphics/android/layers/MediaLayer.cpp
index 6227ea4..7a3730b 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaLayer.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/MediaLayer.cpp
@@ -56,7 +56,7 @@ MediaLayer::~MediaLayer()
bool MediaLayer::drawGL(bool layerTilesDisabled)
{
- FloatRect clippingRect = TilesManager::instance()->shader()->rectInScreenCoord(drawClip());
+ FloatRect clippingRect = TilesManager::instance()->shader()->rectInInvViewCoord(drawClip());
TilesManager::instance()->shader()->clip(clippingRect);
// when the plugin gains focus webkit applies an outline to the
diff --git a/Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp b/Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp
index 6498ecf..2c114d6 100644
--- a/Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/GLExtras.cpp
@@ -42,7 +42,7 @@
GLExtras::GLExtras()
: m_drawExtra(0)
- , m_viewport()
+ , m_visibleContentRect()
{
}
diff --git a/Source/WebCore/platform/graphics/android/rendering/GLExtras.h b/Source/WebCore/platform/graphics/android/rendering/GLExtras.h
index 59a7c3c..e9f697a 100644
--- a/Source/WebCore/platform/graphics/android/rendering/GLExtras.h
+++ b/Source/WebCore/platform/graphics/android/rendering/GLExtras.h
@@ -43,7 +43,10 @@ public:
void drawGL(const LayerAndroid* layer);
void setDrawExtra(android::DrawExtra* extra) { m_drawExtra = extra; }
- void setViewport(const SkRect & viewport) { m_viewport = viewport; }
+ void setVisibleContentRect(const SkRect & visibleContentRect)
+ {
+ m_visibleContentRect = visibleContentRect;
+ }
void drawRegion(const SkRegion& region, bool fill, bool drawBorder,
const TransformationMatrix* drawMat, Color color = COLOR_HOLO_LIGHT);
@@ -52,7 +55,7 @@ private:
void drawRing(SkRect& srcRect, Color color, const TransformationMatrix* drawMat);
android::DrawExtra* m_drawExtra;
- SkRect m_viewport;
+ SkRect m_visibleContentRect;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
index 6e4a82c..5098b4b 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
@@ -150,8 +150,8 @@ int ImageTexture::nbTextures()
// TODO: take in account the visible clip (need to maintain
// a list of the clients layer, etc.)
- IntRect visibleArea(0, 0, m_image->width(), m_image->height());
- int nbTextures = m_tileGrid->nbTextures(visibleArea, 1.0);
+ IntRect visibleContentArea(0, 0, m_image->width(), m_image->height());
+ int nbTextures = m_tileGrid->nbTextures(visibleContentArea, 1.0);
ALOGV("ImageTexture %p, %d x %d needs %d textures",
this, m_image->width(), m_image->height(),
nbTextures);
@@ -184,8 +184,8 @@ bool ImageTexture::prepareGL(GLWebViewState* state)
if (!m_tileGrid)
return false;
- IntRect unclippedArea(0, 0, m_image->width(), m_image->height());
- m_tileGrid->prepareGL(state, 1.0, unclippedArea, unclippedArea, this);
+ IntRect fullContentArea(0, 0, m_image->width(), m_image->height());
+ m_tileGrid->prepareGL(state, 1.0, fullContentArea, fullContentArea, this);
if (m_tileGrid->isReady()) {
m_tileGrid->swapTiles();
return false;
@@ -198,7 +198,7 @@ const TransformationMatrix* ImageTexture::transform()
if (!m_layer)
return 0;
- IntRect layerArea = m_layer->unclippedArea();
+ IntRect layerArea = m_layer->fullContentArea();
float scaleW = static_cast<float>(layerArea.width()) / static_cast<float>(m_image->width());
float scaleH = static_cast<float>(layerArea.height()) / static_cast<float>(m_image->height());
TransformationMatrix d = *(m_layer->drawTransform());
@@ -239,8 +239,8 @@ void ImageTexture::drawGL(LayerAndroid* layer, float opacity)
// transform and opacity, so we need to set m_layer
m_layer = layer;
if (m_tileGrid) {
- IntRect visibleArea = m_layer->visibleArea();
- m_tileGrid->drawGL(visibleArea, opacity, transform());
+ IntRect visibleContentArea = m_layer->visibleContentArea();
+ m_tileGrid->drawGL(visibleContentArea, opacity, transform());
}
m_layer = 0;
}
diff --git a/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp
index 423947f..70a1afe 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp
@@ -370,37 +370,46 @@ void ShaderProgram::setBlendingState(bool enableBlending)
// Drawing
/////////////////////////////////////////////////////////////////////////////////////////
-// We have multiple coordinates to deal with, each could be inverted Y or not, and
-// each could be local to webview or global to the screen.
-// viewRect - global screen coordinates starting from lower left.
-// visibleRect - local document coordinates starting from upper left.
-// webViewRect - inverted global screen coordinates starting from upper left.
-// screenClip - inverted global screen coordinates starting from upper left.
+// We have multiple coordinates to deal with: first is the screen coordinates,
+// second is the view coordinates and the last one is content(document) coordinates.
+// Both screen and view coordinates are in pixels.
+// All these coordinates start from upper left, but for the purpose of OpenGL
+// operations, we may need a inverted Y version of such coordinates which
+// start from lower left.
+//
+// invScreenRect - inv screen coordinates starting from lower left.
+// visibleContentRect - local content(document) coordinates starting from upper left.
+// screenRect - screen coordinates starting from upper left.
+// screenClip - screen coordinates starting from upper left.
// ------------------------------------------
-// |(origin of inv global screen) |
+// |(origin of screen) |
// |screen |
// | --------------------------------- |
-// | | (origin of inv local screen) | |
+// | | (origin of view) | |
// | | webview | |
// | | -------- | |
// | | | clip | | |
// | | | | | |
// | | -------- | |
// | | | |
-// | |(origin of local screen) | |
+// | |(origin of inv view) | |
// | --------------------------------- |
-// |(origin of global screen) |
+// |(origin of inv screen) |
// ------------------------------------------
-void ShaderProgram::setupDrawing(const IntRect& viewRect, const SkRect& visibleRect,
- const IntRect& webViewRect, int titleBarHeight,
+void ShaderProgram::setupDrawing(const IntRect& invScreenRect,
+ const SkRect& visibleContentRect,
+ const IntRect& screenRect, int titleBarHeight,
const IntRect& screenClip, float scale)
{
- m_webViewRect = webViewRect;
+ m_screenRect = screenRect;
m_titleBarHeight = titleBarHeight;
//// viewport ////
- GLUtils::setOrthographicMatrix(m_visibleRectProjectionMatrix, visibleRect.fLeft,
- visibleRect.fTop, visibleRect.fRight, visibleRect.fBottom,
+ GLUtils::setOrthographicMatrix(m_visibleContentRectProjectionMatrix,
+ visibleContentRect.fLeft,
+ visibleContentRect.fTop,
+ visibleContentRect.fRight,
+ visibleContentRect.fBottom,
-1000, 1000);
ALOGV("set m_clipProjectionMatrix, %d, %d, %d, %d",
@@ -408,7 +417,7 @@ void ShaderProgram::setupDrawing(const IntRect& viewRect, const SkRect& visibleR
screenClip.y() + screenClip.height());
// In order to incorporate the animation delta X and Y, using the clip as
- // the GL viewport can save all the trouble of re-position from webViewRect
+ // the GL viewport can save all the trouble of re-position from screenRect
// to final position.
GLUtils::setOrthographicMatrix(m_clipProjectionMatrix, screenClip.x(), screenClip.y(),
screenClip.x() + screenClip.width(),
@@ -417,48 +426,45 @@ void ShaderProgram::setupDrawing(const IntRect& viewRect, const SkRect& visibleR
glViewport(screenClip.x(), m_targetHeight - screenClip.y() - screenClip.height() ,
screenClip.width(), screenClip.height());
- m_viewport = visibleRect;
+ m_visibleContentRect = visibleContentRect;
m_currentScale = scale;
//// viewRect ////
- m_viewRect = viewRect;
-
- // The following matrices transform document coordinates into screen coordinates
- // and inv screen coordinates, and they are local to the webview in terms of
- // coordinate origins.
- // Note that GLUtils::setOrthographicMatrix is inverting the Y. So screen
- // coordinates is starting from lower left, and inverted screen coordinates
- // is from upper left.
+ m_invScreenRect = invScreenRect;
+
+ // The following matrices transform content coordinates into view coordinates
+ // and inv view coordinates.
+ // Note that GLUtils::setOrthographicMatrix is inverting the Y.
TransformationMatrix viewTranslate;
viewTranslate.translate(1.0, 1.0);
TransformationMatrix viewScale;
- viewScale.scale3d(m_viewRect.width() * 0.5f, m_viewRect.height() * 0.5f, 1);
+ viewScale.scale3d(m_invScreenRect.width() * 0.5f, m_invScreenRect.height() * 0.5f, 1);
- m_documentToScreenMatrix = viewScale * viewTranslate * m_visibleRectProjectionMatrix;
+ m_contentToInvViewMatrix = viewScale * viewTranslate * m_visibleContentRectProjectionMatrix;
viewTranslate.scale3d(1, -1, 1);
- m_documentToInvScreenMatrix = viewScale * viewTranslate * m_visibleRectProjectionMatrix;
+ m_contentToViewMatrix = viewScale * viewTranslate * m_visibleContentRectProjectionMatrix;
- IntRect rect(0, 0, m_webViewRect.width(), m_webViewRect.height());
- m_documentViewport = m_documentToScreenMatrix.inverse().mapRect(rect);
+ IntRect invViewRect(0, 0, m_screenRect.width(), m_screenRect.height());
+ m_contentViewport = m_contentToInvViewMatrix.inverse().mapRect(invViewRect);
//// clipping ////
- IntRect mclip = screenClip;
+ IntRect viewClip = screenClip;
- // The incoming screenClip is in inverted global screen coordinates, we first
- // translate it into inverted local screen coordinates.
- // Then we convert it into local screen coordinates.
+ // The incoming screenClip is in screen coordinates, we first
+ // translate it into view coordinates.
+ // Then we convert it into inverted view coordinates.
// Therefore, in the clip() function, we need to convert things back from
- // local screen coordinates to global screen coordinates.
- mclip.setX(screenClip.x() - m_webViewRect.x());
- mclip.setY(screenClip.y() - m_webViewRect.y() - m_titleBarHeight);
- FloatRect tclip = convertInvScreenCoordToScreenCoord(mclip);
- m_screenClip.setLocation(IntPoint(tclip.x(), tclip.y()));
+ // inverted view coordinates to inverted screen coordinates which is used by GL.
+ viewClip.setX(screenClip.x() - m_screenRect.x());
+ viewClip.setY(screenClip.y() - m_screenRect.y() - m_titleBarHeight);
+ FloatRect invViewClip = convertViewCoordToInvViewCoord(viewClip);
+ m_invViewClip.setLocation(IntPoint(invViewClip.x(), invViewClip.y()));
// use ceilf to handle view -> doc -> view coord rounding errors
- m_screenClip.setSize(IntSize(ceilf(tclip.width()), ceilf(tclip.height())));
+ m_invViewClip.setSize(IntSize(ceilf(invViewClip.width()), ceilf(invViewClip.height())));
resetBlending();
@@ -509,47 +515,47 @@ ShaderType ShaderProgram::getTextureShaderType(GLenum textureTarget)
}
// This function transform a clip rect extracted from the current layer
-// into a clip rect in screen coordinates -- used by the clipping rects
-FloatRect ShaderProgram::rectInScreenCoord(const TransformationMatrix& drawMatrix, const IntSize& size)
+// into a clip rect in InvView coordinates -- used by the clipping rects
+FloatRect ShaderProgram::rectInInvViewCoord(const TransformationMatrix& drawMatrix, const IntSize& size)
{
FloatRect srect(0, 0, size.width(), size.height());
- TransformationMatrix renderMatrix = m_documentToScreenMatrix * drawMatrix;
+ TransformationMatrix renderMatrix = m_contentToInvViewMatrix * drawMatrix;
return renderMatrix.mapRect(srect);
}
// used by the partial screen invals
-FloatRect ShaderProgram::rectInInvScreenCoord(const TransformationMatrix& drawMatrix, const IntSize& size)
+FloatRect ShaderProgram::rectInViewCoord(const TransformationMatrix& drawMatrix, const IntSize& size)
{
FloatRect srect(0, 0, size.width(), size.height());
- TransformationMatrix renderMatrix = m_documentToInvScreenMatrix * drawMatrix;
+ TransformationMatrix renderMatrix = m_contentToViewMatrix * drawMatrix;
return renderMatrix.mapRect(srect);
}
-FloatRect ShaderProgram::rectInInvScreenCoord(const FloatRect& rect)
+FloatRect ShaderProgram::rectInViewCoord(const FloatRect& rect)
{
- return m_documentToInvScreenMatrix.mapRect(rect);
+ return m_contentToViewMatrix.mapRect(rect);
}
-FloatRect ShaderProgram::rectInScreenCoord(const FloatRect& rect)
+FloatRect ShaderProgram::rectInInvViewCoord(const FloatRect& rect)
{
- return m_documentToScreenMatrix.mapRect(rect);
+ return m_contentToInvViewMatrix.mapRect(rect);
}
-FloatRect ShaderProgram::convertScreenCoordToDocumentCoord(const FloatRect& rect)
+FloatRect ShaderProgram::convertInvViewCoordToContentCoord(const FloatRect& rect)
{
- return m_documentToScreenMatrix.inverse().mapRect(rect);
+ return m_contentToInvViewMatrix.inverse().mapRect(rect);
}
-FloatRect ShaderProgram::convertInvScreenCoordToScreenCoord(const FloatRect& rect)
+FloatRect ShaderProgram::convertViewCoordToInvViewCoord(const FloatRect& rect)
{
- FloatRect documentRect = m_documentToInvScreenMatrix.inverse().mapRect(rect);
- return rectInScreenCoord(documentRect);
+ FloatRect visibleContentRect = m_contentToViewMatrix.inverse().mapRect(rect);
+ return rectInInvViewCoord(visibleContentRect);
}
-FloatRect ShaderProgram::convertScreenCoordToInvScreenCoord(const FloatRect& rect)
+FloatRect ShaderProgram::convertInvViewCoordToViewCoord(const FloatRect& rect)
{
- FloatRect documentRect = m_documentToScreenMatrix.inverse().mapRect(rect);
- return rectInInvScreenCoord(documentRect);
+ FloatRect visibleContentRect = m_contentToInvViewMatrix.inverse().mapRect(rect);
+ return rectInViewCoord(visibleContentRect);
}
// clip is in screen coordinates
@@ -568,14 +574,14 @@ void ShaderProgram::clip(const FloatRect& clip)
clip.y(),
clip.width(), clip.height());
- if (!m_screenClip.isEmpty())
- screenClip.intersect(m_screenClip);
+ if (!m_invViewClip.isEmpty())
+ screenClip.intersect(m_invViewClip);
// The previous intersection calculation is using local screen coordinates.
// Now we need to convert things from local screen coordinates to global
// screen coordinates and pass to the GL functions.
- screenClip.setX(screenClip.x() + m_viewRect.x());
- screenClip.setY(screenClip.y() + m_viewRect.y());
+ screenClip.setX(screenClip.x() + m_invScreenRect.x());
+ screenClip.setY(screenClip.y() + m_invScreenRect.y());
if (screenClip.x() < 0) {
int w = screenClip.width();
w += screenClip.x();
@@ -594,10 +600,11 @@ void ShaderProgram::clip(const FloatRect& clip)
m_clipRect = clip;
}
-IntRect ShaderProgram::clippedRectWithViewport(const IntRect& rect, int margin)
+IntRect ShaderProgram::clippedRectWithVisibleContentRect(const IntRect& rect, int margin)
{
- IntRect viewport(m_viewport.fLeft - margin, m_viewport.fTop - margin,
- m_viewport.width() + margin, m_viewport.height() + margin);
+ IntRect viewport(m_visibleContentRect.fLeft - margin, m_visibleContentRect.fTop - margin,
+ m_visibleContentRect.width() + margin,
+ m_visibleContentRect.height() + margin);
viewport.intersect(rect);
return viewport;
}
@@ -606,7 +613,8 @@ float ShaderProgram::zValue(const TransformationMatrix& drawMatrix, float w, flo
{
TransformationMatrix modifiedDrawMatrix = drawMatrix;
modifiedDrawMatrix.scale3d(w, h, 1);
- TransformationMatrix renderMatrix = m_visibleRectProjectionMatrix * modifiedDrawMatrix;
+ TransformationMatrix renderMatrix =
+ m_visibleContentRectProjectionMatrix * modifiedDrawMatrix;
FloatPoint3D point(0.5, 0.5, 0.0);
FloatPoint3D result = renderMatrix.mapPoint(point);
return result.z();
diff --git a/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.h b/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.h
index 8c9e301..4243e12 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.h
+++ b/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.h
@@ -115,8 +115,8 @@ public:
void initGLResources();
void cleanupGLResources();
// Drawing
- void setupDrawing(const IntRect& viewRect, const SkRect& visibleRect,
- const IntRect& webViewRect, int titleBarHeight,
+ void setupDrawing(const IntRect& invScreenRect, const SkRect& visibleContentRect,
+ const IntRect& screenRect, int titleBarHeight,
const IntRect& screenClip, float scale);
float zValue(const TransformationMatrix& drawMatrix, float w, float h);
@@ -130,20 +130,20 @@ public:
void drawQuad(const DrawQuadData* data);
void drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
float* textureMatrix, SkRect& geometry, int textureId);
- FloatRect rectInScreenCoord(const TransformationMatrix& drawMatrix,
+ FloatRect rectInInvViewCoord(const TransformationMatrix& drawMatrix,
const IntSize& size);
- FloatRect rectInInvScreenCoord(const TransformationMatrix& drawMatrix,
+ FloatRect rectInViewCoord(const TransformationMatrix& drawMatrix,
const IntSize& size);
- FloatRect rectInInvScreenCoord(const FloatRect& rect);
- FloatRect rectInScreenCoord(const FloatRect& rect);
- FloatRect convertScreenCoordToDocumentCoord(const FloatRect& rect);
- FloatRect convertInvScreenCoordToScreenCoord(const FloatRect& rect);
- FloatRect convertScreenCoordToInvScreenCoord(const FloatRect& rect);
+ FloatRect rectInViewCoord(const FloatRect& rect);
+ FloatRect rectInInvViewCoord(const FloatRect& rect);
+ FloatRect convertInvViewCoordToContentCoord(const FloatRect& rect);
+ FloatRect convertViewCoordToInvViewCoord(const FloatRect& rect);
+ FloatRect convertInvViewCoordToViewCoord(const FloatRect& rect);
void clip(const FloatRect& rect);
- IntRect clippedRectWithViewport(const IntRect& rect, int margin = 0);
- FloatRect documentViewport() { return m_documentViewport; }
+ IntRect clippedRectWithVisibleContentRect(const IntRect& rect, int margin = 0);
+ FloatRect contentViewport() { return m_contentViewport; }
float contrast() { return m_contrast; }
void setContrast(float c)
@@ -185,21 +185,21 @@ private:
TransformationMatrix m_surfaceProjectionMatrix;
TransformationMatrix m_clipProjectionMatrix;
- TransformationMatrix m_visibleRectProjectionMatrix;
+ TransformationMatrix m_visibleContentRectProjectionMatrix;
GLuint m_textureBuffer[1];
- TransformationMatrix m_documentToScreenMatrix;
- TransformationMatrix m_documentToInvScreenMatrix;
- SkRect m_viewport;
- IntRect m_viewRect;
+ TransformationMatrix m_contentToInvViewMatrix;
+ TransformationMatrix m_contentToViewMatrix;
+ SkRect m_visibleContentRect;
+ IntRect m_invScreenRect;
FloatRect m_clipRect;
- IntRect m_screenClip;
+ IntRect m_invViewClip;
int m_titleBarHeight;
// This is the layout position in screen coordinate and didn't contain the
// animation offset.
- IntRect m_webViewRect;
+ IntRect m_screenRect;
- FloatRect m_documentViewport;
+ FloatRect m_contentViewport;
float m_contrast;
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
index 652c165..16cad27 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
@@ -45,7 +45,7 @@
#include <wtf/text/CString.h>
// Surfaces with an area larger than 2048*2048 should never be unclipped
-#define MAX_UNCLIPPED_AREA 4194304
+#define MAX_FULL_CONTENT_AREA 4194304
namespace WebCore {
@@ -131,48 +131,48 @@ void Surface::addLayer(LayerAndroid* layer, const TransformationMatrix& transfor
m_hasText |= layer->hasText();
// calculate area size for comparison later
- IntRect rect = layer->unclippedArea();
+ IntRect rect = layer->fullContentArea();
SkPoint pos = layer->getPosition();
rect.setLocation(IntPoint(pos.fX, pos.fY));
if (layer->needsTexture()) {
- if (m_unclippedArea.isEmpty()) {
+ if (m_fullContentArea.isEmpty()) {
m_drawTransform = transform;
m_drawTransform.translate3d(-pos.fX, -pos.fY, 0);
- m_unclippedArea = rect;
+ m_fullContentArea = rect;
} else
- m_unclippedArea.unite(rect);
+ m_fullContentArea.unite(rect);
ALOGV("Surf %p adding LA %p, size %d, %d %dx%d, now Surf size %d,%d %dx%d",
this, layer, rect.x(), rect.y(), rect.width(), rect.height(),
- m_unclippedArea.x(), m_unclippedArea.y(),
- m_unclippedArea.width(), m_unclippedArea.height());
+ m_fullContentArea.x(), m_fullContentArea.y(),
+ m_fullContentArea.width(), m_fullContentArea.height());
}
if (isBase())
m_background = static_cast<BaseLayerAndroid*>(layer)->getBackgroundColor();
}
-IntRect Surface::visibleArea()
+IntRect Surface::visibleContentArea()
{
if (singleLayer())
- return getFirstLayer()->visibleArea();
+ return getFirstLayer()->visibleContentArea();
- IntRect rect = m_unclippedArea;
+ IntRect rect = m_fullContentArea;
- // clip with the viewport in documents coordinate
- IntRect documentViewport(TilesManager::instance()->shader()->documentViewport());
- rect.intersect(documentViewport);
+ // clip with the viewport in content coordinate
+ IntRect contentViewport(TilesManager::instance()->shader()->contentViewport());
+ rect.intersect(contentViewport);
// TODO: handle recursive layer clip
return rect;
}
-IntRect Surface::unclippedArea()
+IntRect Surface::fullContentArea()
{
if (singleLayer())
- return getFirstLayer()->unclippedArea();
- return m_unclippedArea;
+ return getFirstLayer()->fullContentArea();
+ return m_fullContentArea;
}
bool Surface::useAggressiveRendering()
@@ -203,7 +203,7 @@ void Surface::prepareGL(bool layerTilesDisabled, bool updateWithBlit)
} else {
bool allowZoom = hasText(); // only allow for scale > 1 if painting vectors
IntRect prepareArea = computePrepareArea();
- IntRect fullArea = unclippedArea();
+ IntRect fullArea = fullContentArea();
ALOGV("prepareGL on Surf %p with SurfBack %p, %d layers, first layer %s (%d) "
"prepareArea(%d, %d - %d x %d) fullArea(%d, %d - %d x %d)",
@@ -239,7 +239,7 @@ bool Surface::drawGL(bool layerTilesDisabled)
if (!isBaseLayer) {
// TODO: why are clipping regions wrong for base layer?
FloatRect drawClip = getFirstLayer()->drawClip();
- FloatRect clippingRect = TilesManager::instance()->shader()->rectInScreenCoord(drawClip);
+ FloatRect clippingRect = TilesManager::instance()->shader()->rectInInvViewCoord(drawClip);
TilesManager::instance()->shader()->clip(clippingRect);
}
@@ -248,7 +248,7 @@ bool Surface::drawGL(bool layerTilesDisabled)
ALOGV("drawGL on Surf %p with SurfBack %p, first layer %s (%d)", this, m_surfaceBacking,
getFirstLayer()->subclassName().ascii().data(), getFirstLayer()->uniqueId());
- IntRect drawArea = visibleArea();
+ IntRect drawArea = visibleContentArea();
m_surfaceBacking->drawGL(drawArea, opacity(), drawTransform(),
useAggressiveRendering(), background());
}
@@ -312,13 +312,13 @@ IntRect Surface::computePrepareArea()
&& !isBase()
&& getFirstLayer()->state()->layersRenderingMode() == GLWebViewState::kAllTextures) {
- area = unclippedArea();
+ area = fullContentArea();
double total = ((double) area.width()) * ((double) area.height());
- if (total > MAX_UNCLIPPED_AREA)
- area = visibleArea();
+ if (total > MAX_FULL_CONTENT_AREA)
+ area = visibleContentArea();
} else
- area = visibleArea();
+ area = visibleContentArea();
return area;
}
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h
index dc46fcf..50839ee 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.h
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h
@@ -71,13 +71,13 @@ public:
private:
IntRect computePrepareArea();
- IntRect visibleArea();
- IntRect unclippedArea();
+ IntRect visibleContentArea();
+ IntRect fullContentArea();
bool singleLayer() { return m_layers.size() == 1; }
bool useAggressiveRendering();
const TransformationMatrix* drawTransform();
- IntRect m_unclippedArea;
+ IntRect m_fullContentArea;
TransformationMatrix m_drawTransform;
SurfaceBacking* m_surfaceBacking;
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp
index 957aa63..af96560 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp
@@ -56,7 +56,7 @@ SurfaceBacking::~SurfaceBacking()
}
void SurfaceBacking::prepareGL(GLWebViewState* state, bool allowZoom,
- const IntRect& prepareArea, const IntRect& unclippedArea,
+ const IntRect& prepareArea, const IntRect& fullContentArea,
TilePainter* painter, bool aggressiveRendering,
bool updateWithBlit)
{
@@ -89,7 +89,7 @@ void SurfaceBacking::prepareGL(GLWebViewState* state, bool allowZoom,
if (m_zooming && (m_zoomUpdateTime < WTF::currentTime())) {
// prepare the visible portions of the back tile grid at the futureScale
m_backTileGrid->prepareGL(state, m_futureScale,
- prepareArea, unclippedArea, painter,
+ prepareArea, fullContentArea, painter,
TileGrid::StandardRegion, false);
if (m_backTileGrid->isReady()) {
@@ -114,29 +114,29 @@ void SurfaceBacking::prepareGL(GLWebViewState* state, bool allowZoom,
// if the front grid hasn't already prepared, or needs to prepare
// expanded bounds do so now
m_frontTileGrid->prepareGL(state, m_scale,
- prepareArea, unclippedArea, painter,
+ prepareArea, fullContentArea, painter,
prepareRegionFlags, false, updateWithBlit);
}
if (aggressiveRendering) {
// prepare low res content
float lowResPrefetchScale = m_scale * LOW_RES_PREFETCH_SCALE_MODIFIER;
m_lowResTileGrid->prepareGL(state, lowResPrefetchScale,
- prepareArea, unclippedArea, painter,
+ prepareArea, fullContentArea, painter,
TileGrid::StandardRegion | TileGrid::ExpandedRegion, true);
m_lowResTileGrid->swapTiles();
}
}
}
-void SurfaceBacking::drawGL(const IntRect& visibleArea, float opacity,
+void SurfaceBacking::drawGL(const IntRect& visibleContentArea, float opacity,
const TransformationMatrix* transform,
bool aggressiveRendering, const Color* background)
{
// draw low res prefetch page if zooming or front texture missing content
if (aggressiveRendering && isMissingContent())
- m_lowResTileGrid->drawGL(visibleArea, opacity, transform);
+ m_lowResTileGrid->drawGL(visibleContentArea, opacity, transform);
- m_frontTileGrid->drawGL(visibleArea, opacity, transform, background);
+ m_frontTileGrid->drawGL(visibleContentArea, opacity, transform, background);
}
void SurfaceBacking::markAsDirty(const SkRegion& dirtyArea)
@@ -159,14 +159,14 @@ void SurfaceBacking::computeTexturesAmount(TexturesResult* result, LayerAndroid*
if (!layer)
return;
- IntRect unclippedArea = layer->unclippedArea();
- IntRect clippedVisibleArea = layer->visibleArea();
+ IntRect fullContentArea = layer->fullContentArea();
+ IntRect clippedVisibleArea = layer->visibleContentArea();
// get two numbers here:
// - textures needed for a clipped area
// - textures needed for an un-clipped area
TileGrid* tileGrid = m_zooming ? m_backTileGrid : m_frontTileGrid;
- int nbTexturesUnclipped = tileGrid->nbTextures(unclippedArea, m_scale);
+ int nbTexturesUnclipped = tileGrid->nbTextures(fullContentArea, m_scale);
int nbTexturesClipped = tileGrid->nbTextures(clippedVisibleArea, m_scale);
// Set kFixedLayers level
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h
index 08cfc7c..7d3e93c 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h
@@ -41,11 +41,11 @@ public:
SurfaceBacking(bool isBaseSurface);
~SurfaceBacking();
void prepareGL(GLWebViewState* state, bool allowZoom,
- const IntRect& prepareArea, const IntRect& unclippedArea,
+ const IntRect& prepareArea, const IntRect& fullContentArea,
TilePainter* painter, bool aggressiveRendering,
bool updateWithBlit);
void swapTiles();
- void drawGL(const IntRect& visibleArea, float opacity,
+ void drawGL(const IntRect& visibleContentArea, float opacity,
const TransformationMatrix* transform, bool aggressiveRendering,
const Color* background);
void markAsDirty(const SkRegion& dirtyArea);
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
index cf59044..0bdbf38 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
@@ -83,9 +83,9 @@ SurfaceCollection::~SurfaceCollection()
#endif
}
-void SurfaceCollection::prepareGL(const SkRect& visibleRect)
+void SurfaceCollection::prepareGL(const SkRect& visibleContentRect)
{
- updateLayerPositions(visibleRect);
+ updateLayerPositions(visibleContentRect);
bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
> GLWebViewState::kClippedTextures;
bool updateWithBlit = true;
@@ -109,14 +109,14 @@ static inline bool compareSurfaceZ(const Surface* a, const Surface* b)
return (la->zValue() > lb->zValue()) && (la->getParent() == lb->getParent());
}
-bool SurfaceCollection::drawGL(const SkRect& visibleRect)
+bool SurfaceCollection::drawGL(const SkRect& visibleContentRect)
{
#ifdef DEBUG_COUNT
ClassTracker::instance()->show();
#endif
bool needsRedraw = false;
- updateLayerPositions(visibleRect);
+ updateLayerPositions(visibleContentRect);
bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
> GLWebViewState::kClippedTextures;
@@ -231,10 +231,10 @@ void SurfaceCollection::updateScrollableLayer(int layerId, int x, int y)
static_cast<ScrollableLayerAndroid*>(layer)->scrollTo(x, y);
}
-void SurfaceCollection::updateLayerPositions(const SkRect& visibleRect)
+void SurfaceCollection::updateLayerPositions(const SkRect& visibleContentRect)
{
TransformationMatrix ident;
- m_compositedRoot->updateLayerPositions(visibleRect);
+ m_compositedRoot->updateLayerPositions(visibleContentRect);
FloatRect clip(0, 0, 1e10, 1e10);
m_compositedRoot->updateGLPositionsAndScale(
ident, clip, 1, m_compositedRoot->state()->scale());
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
index 7dfe140..5cfd943 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
@@ -48,8 +48,8 @@ public:
virtual ~SurfaceCollection();
// Tiled painting methods (executed on groups)
- void prepareGL(const SkRect& visibleRect);
- bool drawGL(const SkRect& visibleRect);
+ void prepareGL(const SkRect& visibleContentRect);
+ bool drawGL(const SkRect& visibleContentRect);
Color getBackgroundColor();
void swapTiles();
bool isReady();
@@ -67,7 +67,7 @@ public:
void updateScrollableLayer(int layerId, int x, int y);
private:
- void updateLayerPositions(const SkRect& visibleRect);
+ void updateLayerPositions(const SkRect& visibleContentRect);
LayerAndroid* m_compositedRoot;
WTF::Vector<Surface*> m_surfaces;
};
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
index 52a8e44..b26be03 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
@@ -154,7 +154,7 @@ void SurfaceCollectionManager::updateScrollableLayer(int layerId, int x, int y)
}
int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
- SkRect& visibleRect, float scale,
+ SkRect& visibleContentRect, float scale,
bool enterFastSwapMode,
bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr,
TexturesResult* texturesResultPtr, bool shouldDraw)
@@ -171,7 +171,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
m_paintingCollection->evaluateAnimations(currentTime);
- m_paintingCollection->prepareGL(visibleRect);
+ m_paintingCollection->prepareGL(visibleContentRect);
m_paintingCollection->computeTexturesAmount(texturesResultPtr);
if (!TilesManager::instance()->useDoubleBuffering() || m_paintingCollection->isReady()) {
@@ -186,7 +186,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
}
} else if (m_drawingCollection) {
ALOGV("preparing drawing collection %p", m_drawingCollection);
- m_drawingCollection->prepareGL(visibleRect);
+ m_drawingCollection->prepareGL(visibleContentRect);
m_drawingCollection->computeTexturesAmount(texturesResultPtr);
}
@@ -254,7 +254,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
GLUtils::clearBackgroundIfOpaque(&background);
}
- if (m_drawingCollection && m_drawingCollection->drawGL(visibleRect))
+ if (m_drawingCollection && m_drawingCollection->drawGL(visibleContentRect))
returnFlags |= uirenderer::DrawGlInfo::kStatusDraw;
ALOGV("returnFlags %d, m_paintingCollection %d ", returnFlags, m_paintingCollection);
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
index 125bf02..be4fbca 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
@@ -50,7 +50,7 @@ public:
void updateScrollableLayer(int layerId, int x, int y);
int drawGL(double currentTime, IntRect& viewRect,
- SkRect& visibleRect, float scale,
+ SkRect& visibleContentRect, float scale,
bool enterFastSwapMode, bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr,
TexturesResult* texturesResultPtr, bool shouldDraw);
diff --git a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp
index bee42ae..7680fc9 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp
@@ -135,7 +135,7 @@ IntRect TileGrid::computeTilesArea(const IntRect& contentArea, float scale)
}
void TileGrid::prepareGL(GLWebViewState* state, float scale,
- const IntRect& prepareArea, const IntRect& unclippedArea,
+ const IntRect& prepareArea, const IntRect& fullContentArea,
TilePainter* painter, int regionFlags, bool isLowResPrefetch,
bool updateWithBlit)
{
@@ -193,7 +193,7 @@ void TileGrid::prepareGL(GLWebViewState* state, float scale,
}
if (regionFlags & ExpandedRegion) {
- IntRect fullArea = computeTilesArea(unclippedArea, scale);
+ IntRect fullArea = computeTilesArea(fullContentArea, scale);
IntRect expandedArea = m_area;
// on systems reporting highEndGfx=true and useMinimalMemory not set, use expanded bounds
@@ -285,11 +285,11 @@ int TileGrid::nbTextures(IntRect& area, float scale)
return numberTextures;
}
-void TileGrid::drawGL(const IntRect& visibleArea, float opacity,
+void TileGrid::drawGL(const IntRect& visibleContentArea, float opacity,
const TransformationMatrix* transform,
const Color* background)
{
- m_area = computeTilesArea(visibleArea, m_scale);
+ m_area = computeTilesArea(visibleContentArea, m_scale);
if (m_area.width() == 0 || m_area.height() == 0)
return;
@@ -311,10 +311,10 @@ void TileGrid::drawGL(const IntRect& visibleArea, float opacity,
bool usePointSampling =
TilesManager::instance()->shader()->usePointSampling(m_scale, transform);
- float minTileX = visibleArea.x() / tileWidth;
- float minTileY = visibleArea.y() / tileWidth;
- float maxTileWidth = visibleArea.maxX() / tileWidth;
- float maxTileHeight = visibleArea.maxY() / tileWidth;
+ float minTileX = visibleContentArea.x() / tileWidth;
+ float minTileY = visibleContentArea.y() / tileWidth;
+ float maxTileWidth = visibleContentArea.maxX() / tileWidth;
+ float maxTileHeight = visibleContentArea.maxY() / tileWidth;
ALOGV("minTileX, minTileY, maxTileWidth, maxTileHeight %f, %f, %f %f",
minTileX, minTileY, maxTileWidth, maxTileHeight);
for (unsigned int i = 0; i < m_tiles.size(); i++) {
diff --git a/Source/WebCore/platform/graphics/android/rendering/TileGrid.h b/Source/WebCore/platform/graphics/android/rendering/TileGrid.h
index e412979..b480419 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TileGrid.h
+++ b/Source/WebCore/platform/graphics/android/rendering/TileGrid.h
@@ -49,11 +49,11 @@ public:
static IntRect computeTilesArea(const IntRect& contentArea, float scale);
void prepareGL(GLWebViewState* state, float scale,
- const IntRect& prepareArea, const IntRect& unclippedArea,
+ const IntRect& prepareArea, const IntRect& fullContentArea,
TilePainter* painter, int regionFlags = StandardRegion,
bool isLowResPrefetch = false, bool updateWithBlit = false);
void swapTiles();
- void drawGL(const IntRect& visibleArea, float opacity,
+ void drawGL(const IntRect& visibleContentArea, float opacity,
const TransformationMatrix* transform, const Color* background = 0);
void markAsDirty(const SkRegion& dirtyArea);