summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-03-14 16:43:27 -0700
committerTeng-Hui Zhu <ztenghui@google.com>2012-03-22 16:01:22 -0700
commit885e650b12d781be054b31ae6221925a0184dc33 (patch)
tree506c80fd82f092a9c0601702230909c4a7ef6c95
parent6aea92fd5ffd5a43b1c13769be9a16202f498b59 (diff)
downloadexternal_webkit-885e650b12d781be054b31ae6221925a0184dc33.zip
external_webkit-885e650b12d781be054b31ae6221925a0184dc33.tar.gz
external_webkit-885e650b12d781be054b31ae6221925a0184dc33.tar.bz2
reimplement BaseLayerAndroid as a LayerAndroid subclass
Breaks low res tiling, and expanded rendering bounds. Change-Id: Iec3ba2adceb6bd95399594d29fd8c0b18c1122ce
-rw-r--r--Source/WebCore/Android.mk2
-rw-r--r--Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp269
-rw-r--r--Source/WebCore/platform/graphics/android/BaseLayerAndroid.h59
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.h12
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.cpp15
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.h1
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp200
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h46
-rw-r--r--Source/WebCore/platform/graphics/android/ImageTexture.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/Layer.cpp5
-rw-r--r--Source/WebCore/platform/graphics/android/Layer.h2
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp33
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h15
-rw-r--r--Source/WebCore/platform/graphics/android/LayerContent.h5
-rw-r--r--Source/WebCore/platform/graphics/android/LayerGroup.cpp44
-rw-r--r--Source/WebCore/platform/graphics/android/LayerGroup.h4
-rw-r--r--Source/WebCore/platform/graphics/android/PaintTileOperation.cpp23
-rw-r--r--Source/WebCore/platform/graphics/android/PaintTileOperation.h3
-rw-r--r--Source/WebCore/platform/graphics/android/PictureLayerContent.cpp1
-rw-r--r--Source/WebCore/platform/graphics/android/PictureSetLayerContent.cpp7
-rw-r--r--Source/WebCore/platform/graphics/android/QueuedOperation.h22
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/SurfaceCollection.cpp143
-rw-r--r--Source/WebCore/platform/graphics/android/SurfaceCollection.h13
-rw-r--r--Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp50
-rw-r--r--Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h5
-rw-r--r--Source/WebCore/platform/graphics/android/TextureOwner.h3
-rw-r--r--Source/WebCore/platform/graphics/android/TexturesGenerator.cpp15
-rw-r--r--Source/WebCore/platform/graphics/android/TexturesGenerator.h11
-rw-r--r--Source/WebCore/platform/graphics/android/TiledPage.cpp382
-rw-r--r--Source/WebCore/platform/graphics/android/TiledPage.h133
-rw-r--r--Source/WebCore/platform/graphics/android/TiledTexture.cpp37
-rw-r--r--Source/WebCore/platform/graphics/android/TiledTexture.h10
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp5
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h14
-rw-r--r--Source/WebCore/platform/graphics/android/TilesProfiler.cpp16
-rw-r--r--Source/WebCore/platform/graphics/android/TilesProfiler.h6
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.h1
-rw-r--r--Source/WebCore/platform/graphics/android/ZoomManager.cpp185
-rw-r--r--Source/WebCore/platform/graphics/android/ZoomManager.h118
-rw-r--r--Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp7
-rw-r--r--Source/WebKit/android/jni/ViewStateSerializer.cpp9
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp7
-rw-r--r--Source/WebKit/android/nav/DrawExtra.h1
-rw-r--r--Source/WebKit/android/nav/WebView.cpp116
47 files changed, 311 insertions, 1756 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index f5d987d..6ddf965 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -685,7 +685,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/TexturesGenerator.cpp \
platform/graphics/android/TilesManager.cpp \
platform/graphics/android/TilesProfiler.cpp \
- platform/graphics/android/TiledPage.cpp \
platform/graphics/android/TiledTexture.cpp \
platform/graphics/android/TransferQueue.cpp \
platform/graphics/android/SurfaceCollection.cpp \
@@ -693,7 +692,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/VerticalTextMap.cpp \
platform/graphics/android/VideoLayerAndroid.cpp \
platform/graphics/android/VideoLayerManager.cpp \
- platform/graphics/android/ZoomManager.cpp \
ifeq ($(ENABLE_SVG), true)
LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 7e0a719..7bb632f 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2010, The Android Open Source Project
+ * Copyright 2012, The Android Open Source Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,269 +30,28 @@
#include "BaseLayerAndroid.h"
#include "AndroidLog.h"
-#include "ClassTracker.h"
-#include "GLUtils.h"
-#include "LayerGroup.h"
-#include "ShaderProgram.h"
-#include "SkCanvas.h"
-#include "TilesManager.h"
-#include <GLES2/gl2.h>
-
-// TODO: dynamically determine based on DPI
-#define PREFETCH_SCALE_MODIFIER 0.3
-#define PREFETCH_OPACITY 1
-#define PREFETCH_X_DIST 0
-#define PREFETCH_Y_DIST 1
+#include "GLWebViewState.h"
+#include "LayerContent.h"
namespace WebCore {
-using namespace android;
-
-BaseLayerAndroid::BaseLayerAndroid()
-#if USE(ACCELERATED_COMPOSITING)
- : m_color(Color::white)
- , m_content(0)
- , m_scrollState(NotScrolling)
-#endif
-{
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->increment("BaseLayerAndroid");
-#endif
-}
-
-BaseLayerAndroid::~BaseLayerAndroid()
-{
- SkSafeUnref(m_content);
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->decrement("BaseLayerAndroid");
-#endif
-}
-
-void BaseLayerAndroid::setContent(LayerContent* content)
-{
- SkSafeRef(content);
- SkSafeUnref(m_content);
- m_content = content;
- // FIXME: We cannot set the size of the base layer because it will screw up
- // the matrix used. We need to fix matrix computation for the base layer
- // and then we can set the size.
- // setSize(src.width(), src.height());
-}
-
-bool BaseLayerAndroid::drawCanvas(SkCanvas* canvas)
-{
- android::Mutex::Autolock lock(m_drawLock);
- if (m_content && !m_content->isEmpty())
- m_content->draw(canvas);
- return true;
-}
-
-#if USE(ACCELERATED_COMPOSITING)
-
-void BaseLayerAndroid::prefetchBasePicture(const SkRect& viewport, float currentScale,
- TiledPage* prefetchTiledPage, bool draw)
-{
- SkIRect bounds;
- float prefetchScale = currentScale * PREFETCH_SCALE_MODIFIER;
-
- float invTileWidth = (prefetchScale)
- / TilesManager::instance()->tileWidth();
- float invTileHeight = (prefetchScale)
- / TilesManager::instance()->tileHeight();
- bool goingDown = m_state->goingDown();
- bool goingLeft = m_state->goingLeft();
-
-
- ALOGV("fetch rect %f %f %f %f, scale %f",
- viewport.fLeft,
- viewport.fTop,
- viewport.fRight,
- viewport.fBottom,
- currentScale);
-
- bounds.fLeft = static_cast<int>(floorf(viewport.fLeft * invTileWidth)) - PREFETCH_X_DIST;
- bounds.fTop = static_cast<int>(floorf(viewport.fTop * invTileHeight)) - PREFETCH_Y_DIST;
- bounds.fRight = static_cast<int>(ceilf(viewport.fRight * invTileWidth)) + PREFETCH_X_DIST;
- bounds.fBottom = static_cast<int>(ceilf(viewport.fBottom * invTileHeight)) + PREFETCH_Y_DIST;
-
- ALOGV("prefetch rect %d %d %d %d, scale %f, preparing page %p",
- bounds.fLeft, bounds.fTop,
- bounds.fRight, bounds.fBottom,
- prefetchScale,
- prefetchTiledPage);
-
- prefetchTiledPage->setScale(prefetchScale);
- prefetchTiledPage->updateTileDirtiness();
- prefetchTiledPage->prepare(goingDown, goingLeft, bounds,
- TiledPage::ExpandedBounds);
- prefetchTiledPage->swapBuffersIfReady(bounds,
- prefetchScale);
- if (draw)
- prefetchTiledPage->prepareForDrawGL(PREFETCH_OPACITY, bounds);
-}
-
-bool BaseLayerAndroid::isReady()
-{
- ZoomManager* zoomManager = m_state->zoomManager();
- if (ZoomManager::kNoScaleRequest != zoomManager->scaleRequestState()) {
- ALOGV("base layer not ready, still zooming");
- return false; // still zooming
- }
-
- if (!m_state->frontPage()->isReady(m_state->preZoomBounds())) {
- ALOGV("base layer not ready, front page not done painting");
- return false;
- }
-
- return true;
-}
-
-void BaseLayerAndroid::swapTiles()
-{
- m_state->frontPage()->swapBuffersIfReady(m_state->preZoomBounds(),
- m_state->zoomManager()->currentScale());
-
- m_state->backPage()->swapBuffersIfReady(m_state->preZoomBounds(),
- m_state->zoomManager()->currentScale());
-}
-
-void BaseLayerAndroid::setIsPainting()
-{
- ALOGV("BLA %p setIsPainting, dirty %d", this, isDirty());
- m_state->invalRegion(m_dirtyRegion);
- m_dirtyRegion.setEmpty();
-}
-void BaseLayerAndroid::mergeInvalsInto(BaseLayerAndroid* replacementLayer)
-{
- replacementLayer->markAsDirty(m_dirtyRegion);
-}
+// Note: this must match the use of ID 0 specifying the base layer in DrawExtra
+#define BASE_UNIQUE_ID 0
-void BaseLayerAndroid::prepareGL(const SkRect& viewport, float scale, double currentTime)
+BaseLayerAndroid::BaseLayerAndroid(LayerContent* content)
+ : LayerAndroid((RenderLayer*)0)
+ , m_color(Color::white)
{
- ALOGV("prepareGL BLA %p, m_state %p", this, m_state);
-
- ZoomManager* zoomManager = m_state->zoomManager();
-
- bool goingDown = m_state->goingDown();
- bool goingLeft = m_state->goingLeft();
-
- const SkIRect& viewportTileBounds = m_state->viewportTileBounds();
- ALOGV("drawBasePicture, TX: %d, TY: %d scale %.2f", viewportTileBounds.fLeft,
- viewportTileBounds.fTop, scale);
-
- // Query the resulting state from the zoom manager
- bool prepareNextTiledPage = zoomManager->needPrepareNextTiledPage();
-
- // Display the current page
- TiledPage* tiledPage = m_state->frontPage();
- TiledPage* nextTiledPage = m_state->backPage();
- tiledPage->setScale(zoomManager->currentScale());
-
- // Let's prepare the page if needed so that it will start painting
- if (prepareNextTiledPage) {
- nextTiledPage->setScale(scale);
- m_state->setFutureViewport(viewportTileBounds);
-
- nextTiledPage->updateTileDirtiness();
-
- nextTiledPage->prepare(goingDown, goingLeft, viewportTileBounds,
- TiledPage::VisibleBounds);
- // Cancel pending paints for the foreground page
- TilesManager::instance()->removePaintOperationsForPage(tiledPage, false);
- }
-
- // If we fired a request, let's check if it's ready to use
- if (zoomManager->didFireRequest()) {
- if (nextTiledPage->swapBuffersIfReady(viewportTileBounds,
- zoomManager->futureScale()))
- zoomManager->setReceivedRequest(); // transition to received request state
- }
-
- float transparency = 1;
- bool doZoomPageSwap = false;
-
- // If the page is ready, display it. We do a short transition between
- // the two pages (current one and future one with the new scale factor)
- if (zoomManager->didReceivedRequest()) {
- float nextTiledPageTransparency = 1;
- m_state->resetFrameworkInval();
- zoomManager->processTransition(currentTime, scale, &doZoomPageSwap,
- &nextTiledPageTransparency, &transparency);
- nextTiledPage->prepareForDrawGL(nextTiledPageTransparency, viewportTileBounds);
- }
-
- const SkIRect& preZoomBounds = m_state->preZoomBounds();
-
- bool zooming = ZoomManager::kNoScaleRequest != zoomManager->scaleRequestState();
-
- if (doZoomPageSwap) {
- zoomManager->setCurrentScale(scale);
- m_state->swapPages();
- }
-
- tiledPage->updateTileDirtiness();
-
- // paint what's needed unless we're zooming, since the new tiles won't
- // be relevant soon anyway
- if (!zooming)
- tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
- TiledPage::ExpandedBounds);
-
- ALOGV("scrollState %d, zooming %d", m_scrollState, zooming);
-
- // prefetch in the nextTiledPage if unused by zooming (even if not scrolling
- // since we want the tiles to be ready before they're needed)
- bool usePrefetchPage = !zooming;
- nextTiledPage->setIsPrefetchPage(usePrefetchPage);
- if (usePrefetchPage) {
- // if the non-prefetch page isn't missing tiles, don't bother drawing
- // prefetch page
- bool drawPrefetchPage = tiledPage->hasMissingContent(preZoomBounds);
- prefetchBasePicture(viewport, scale, nextTiledPage, drawPrefetchPage);
- }
-
- tiledPage->prepareForDrawGL(transparency, preZoomBounds);
-}
-
-void BaseLayerAndroid::drawBasePictureInGL()
-{
- m_state->backPage()->drawGL();
- m_state->frontPage()->drawGL();
-}
-
-void BaseLayerAndroid::updateLayerPositions(const SkRect& visibleRect)
-{
- LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
- if (!compositedRoot)
- return;
- TransformationMatrix ident;
- compositedRoot->updateLayerPositions(visibleRect);
- FloatRect clip(0, 0, content()->width(), content()->height());
-
- // Note that this function may be called (and should still work) with no m_state in SW mode
- // TODO: is this the best thing to do in software rendering
- float scale = m_state ? m_state->scale() : 1.0f;
- compositedRoot->updateGLPositionsAndScale(ident, clip, 1, scale);
-
-#ifdef DEBUG
- compositedRoot->showLayer(0);
- ALOGV("We have %d layers, %d textured",
- compositedRoot->nbLayers(),
- compositedRoot->nbTexturedLayers());
-#endif
+ setContent(content);
+ setSize(content->width(), content->height());
+ m_uniqueId = BASE_UNIQUE_ID;
}
-#endif // USE(ACCELERATED_COMPOSITING)
-
-void BaseLayerAndroid::drawGL(float scale)
+void BaseLayerAndroid::getLocalTransform(SkMatrix* matrix) const
{
- ALOGV("drawGL BLA %p", this);
-
- // TODO: consider moving drawBackground outside of prepare (into tree manager)
- m_state->drawBackground(m_color);
- drawBasePictureInGL();
- m_state->glExtras()->drawGL(0);
+ // base layer doesn't use size in transform calculation
+ matrix->preConcat(getMatrix());
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h
index 5560f58..0ef39c8 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2010, The Android Open Source Project
+ * Copyright 2012, The Android Open Source Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,67 +26,34 @@
#ifndef BaseLayerAndroid_h
#define BaseLayerAndroid_h
-#include <utils/threads.h>
-
#include "Color.h"
-#include "Layer.h"
-#include "PictureSet.h"
-#include "LayerContent.h"
+#include "LayerAndroid.h"
namespace WebCore {
-class TiledPage;
+class RenderLayerCompositor;
-class BaseLayerAndroid : public Layer {
+class BaseLayerAndroid : public LayerAndroid {
public:
- enum ScrollState {
- NotScrolling = 0,
- Scrolling = 1,
- ScrollingFinishPaint = 2
- };
+ BaseLayerAndroid(LayerContent* content);
+
+ virtual ~BaseLayerAndroid() {};
- BaseLayerAndroid();
- virtual ~BaseLayerAndroid();
+ virtual SubclassType subclassType() { return LayerAndroid::BaseLayer; }
+ virtual bool needsTexture() { return true; }
-#if USE(ACCELERATED_COMPOSITING)
void setBackgroundColor(Color& color) { m_color = color; }
Color getBackgroundColor() { return m_color; }
-#endif
- void setContent(LayerContent* content);
- LayerContent* content() { return m_content; }
-
- // This method will paint using the current PictureSet onto
- // the passed canvas. We used it to paint the GL tiles as well as
- // WebView::copyBaseContentToPicture(), so a lock is necessary as
- // we are running in different threads.
- virtual bool drawCanvas(SkCanvas* canvas);
- void updateLayerPositions(const SkRect& visibleRect);
- void prepareGL(const SkRect& visibleRect, float scale, double currentTime);
- void drawGL(float scale);
-
- // rendering asset management
- void swapTiles();
- void setIsDrawing(bool isDrawing);
- void setIsPainting();
- void mergeInvalsInto(BaseLayerAndroid* replacementLayer);
- bool isReady();
+ virtual void getLocalTransform(SkMatrix* matrix) const;
+ virtual const TransformationMatrix* drawTransform() const { return 0; }
private:
-#if USE(ACCELERATED_COMPOSITING)
- void prefetchBasePicture(const SkRect& viewport, float currentScale,
- TiledPage* prefetchTiledPage, bool draw);
- void drawBasePictureInGL();
-
- android::Mutex m_drawLock;
+ // TODO: move to SurfaceCollection.
Color m_color;
-#endif
- LayerContent* m_content;
-
- ScrollState m_scrollState;
};
} // namespace WebCore
-#endif // BaseLayerAndroid_h
+#endif //BaseLayerAndroid_h
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp
index ac8f78c..7243031 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp
@@ -47,10 +47,8 @@
namespace WebCore {
BaseTile::BaseTile(bool isLayerTile)
- : m_glWebViewState(0)
- , m_x(-1)
+ : m_x(-1)
, m_y(-1)
- , m_page(0)
, m_frontTexture(0)
, m_backTexture(0)
, m_scale(1)
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h
index ab16dc9..afb1db2 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.h
+++ b/Source/WebCore/platform/graphics/android/BaseTile.h
@@ -39,7 +39,6 @@
namespace WebCore {
class TextureInfo;
-class TiledPage;
class BaseTileTexture;
class GLWebViewState;
@@ -95,7 +94,6 @@ public:
bool isLayerTile() { return m_isLayerTile; }
void setContents(int x, int y, float scale);
- void setPage(TiledPage* page) { m_page = page; }
void reserveTexture();
@@ -114,7 +112,7 @@ public:
void markAsDirty(const SkRegion& dirtyArea);
bool isDirty();
- bool isRepaintPending();
+ virtual bool isRepaintPending();
void setRepaintPending(bool pending);
float scale() const { return m_scale; }
TextureState textureState() const { return m_state; }
@@ -132,23 +130,15 @@ public:
void backTextureTransfer();
void backTextureTransferFail();
- void setGLWebViewState(GLWebViewState* state) { m_glWebViewState = state; }
-
// TextureOwner implementation
virtual bool removeTexture(BaseTileTexture* texture);
- virtual TiledPage* page() { return m_page; }
- virtual GLWebViewState* state() { return m_glWebViewState; }
private:
void validatePaint();
- GLWebViewState* m_glWebViewState;
-
int m_x;
int m_y;
- TiledPage* m_page;
-
// The remaining variables can be updated throughout the lifetime of the object
BaseTileTexture* m_frontTexture;
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
index ec1fac2..f7f9370 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
@@ -131,7 +131,7 @@ void BaseTileTexture::drawGL(bool isLayer, const SkRect& rect, float opacity,
if (isPureColor())
shader->drawQuad(rect, 0, opacity, pureColor());
else
- shader->drawQuad(rect, m_ownTextureId, opacity);
+ shader->drawQuad(rect, m_ownTextureId, opacity);
}
}
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.cpp b/Source/WebCore/platform/graphics/android/GLUtils.cpp
index be56f92..68ce717 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.cpp
+++ b/Source/WebCore/platform/graphics/android/GLUtils.cpp
@@ -638,6 +638,21 @@ void GLUtils::convertToTransformationMatrix(const float* matrix, TransformationM
matrix[12], matrix[13], matrix[14], matrix[15]);
}
+void GLUtils::drawBackground(Color& backgroundColor)
+{
+ if (TilesManager::instance()->invertedScreen()) {
+ float color = 1.0 - ((((float) backgroundColor.red() / 255.0) +
+ ((float) backgroundColor.green() / 255.0) +
+ ((float) backgroundColor.blue() / 255.0)) / 3.0);
+ glClearColor(color, color, color, 1);
+ } else {
+ glClearColor((float)backgroundColor.red() / 255.0,
+ (float)backgroundColor.green() / 255.0,
+ (float)backgroundColor.blue() / 255.0, 1);
+ }
+ glClear(GL_COLOR_BUFFER_BIT);
+}
+
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.h b/Source/WebCore/platform/graphics/android/GLUtils.h
index 966f674..bfc55d0 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.h
+++ b/Source/WebCore/platform/graphics/android/GLUtils.h
@@ -86,6 +86,7 @@ public:
static bool isPureColorBitmap(const SkBitmap& bitmap, Color& pureColor);
static bool skipTransferForPureColor(const TileRenderInfo* renderInfo,
const SkBitmap& bitmap);
+ static void drawBackground(Color& backgroundColor);
static bool allowGLLog();
static double m_previousLogTime;
static int m_currentLogCounter;
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 730081b..1dfc496 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -66,27 +66,16 @@ namespace WebCore {
using namespace android;
GLWebViewState::GLWebViewState()
- : m_zoomManager(this)
- , m_usePageA(true)
- , m_frameworkInval(0, 0, 0, 0)
- , m_frameworkLayersInval(0, 0, 0, 0)
+ : m_frameworkLayersInval(0, 0, 0, 0)
, m_isScrolling(false)
, m_isViewportScrolling(false)
, m_goingDown(true)
, m_goingLeft(false)
- , m_expandedTileBoundsX(0)
- , m_expandedTileBoundsY(0)
, m_scale(1)
, m_layersRenderingMode(kAllTextures)
, m_surfaceCollectionManager(this)
{
m_viewport.setEmpty();
- m_futureViewportTileBounds.setEmpty();
- m_viewportTileBounds.setEmpty();
- m_preZoomBounds.setEmpty();
-
- m_tiledPageA = new TiledPage(FIRST_TILED_PAGE_ID, this);
- m_tiledPageB = new TiledPage(SECOND_TILED_PAGE_ID, this);
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("GLWebViewState");
@@ -100,14 +89,6 @@ GLWebViewState::GLWebViewState()
GLWebViewState::~GLWebViewState()
{
- // We have to destroy the two tiled pages first as their destructor
- // may depend on the existence of this GLWebViewState and some of its
- // instance variables in order to complete.
- // Explicitely, currently we need to have the m_paintingBaseLayer around
- // in order to complete any pending paint operations (the tiled pages
- // will remove any pending operations, and wait if one is underway).
- delete m_tiledPageA;
- delete m_tiledPageB;
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("GLWebViewState");
#endif
@@ -117,15 +98,11 @@ GLWebViewState::~GLWebViewState()
bool GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndicator,
bool isPictureAfterFirstLayout)
{
- if (!layer || isPictureAfterFirstLayout) {
- // TODO: move this into SurfaceCollectionManager
- m_zoomManager.swapPages(); // reset zoom state
- m_tiledPageA->discardTextures();
- m_tiledPageB->discardTextures();
+ if (!layer || isPictureAfterFirstLayout)
m_layersRenderingMode = kAllTextures;
- }
+
if (layer) {
- ALOGV("new base layer %p, with child %p", layer, layer->getChild(0));
+ ALOGV("layer tree %p, with child %p", layer, layer->getChild(0));
layer->setState(this);
}
bool queueFull = m_surfaceCollectionManager.updateWithSurfaceCollection(
@@ -145,85 +122,6 @@ bool GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndica
void GLWebViewState::scrollLayer(int layerId, int x, int y)
{
m_surfaceCollectionManager.updateScrollableLayer(layerId, x, y);
-
- // TODO: only inval the area of the scrolled layer instead of
- // doing a fullInval()
- if (m_layersRenderingMode == kSingleSurfaceRendering)
- fullInval();
-}
-
-void GLWebViewState::invalRegion(const SkRegion& region)
-{
- if (m_layersRenderingMode == kSingleSurfaceRendering) {
- // TODO: do the union of both layer trees to compute
- // the minimum inval instead of doing a fullInval()
- fullInval();
- return;
- }
- SkRegion::Iterator iterator(region);
- while (!iterator.done()) {
- SkIRect r = iterator.rect();
- IntRect ir(r.fLeft, r.fTop, r.width(), r.height());
- inval(ir);
- iterator.next();
- }
-}
-
-void GLWebViewState::inval(const IntRect& rect)
-{
- if (!rect.isEmpty()) {
- // find which tiles fall within the invalRect and mark them as dirty
- m_tiledPageA->invalidateRect(rect);
- m_tiledPageB->invalidateRect(rect);
- if (m_frameworkInval.isEmpty())
- m_frameworkInval = rect;
- else
- m_frameworkInval.unite(rect);
- ALOGV("intermediate invalRect(%d, %d, %d, %d) after unite with rect %d %d %d %d", m_frameworkInval.x(),
- m_frameworkInval.y(), m_frameworkInval.width(), m_frameworkInval.height(),
- rect.x(), rect.y(), rect.width(), rect.height());
- }
- TilesManager::instance()->getProfiler()->nextInval(rect, zoomManager()->currentScale());
-}
-
-void GLWebViewState::paintBaseLayerContent(SkCanvas* canvas)
-{
- m_surfaceCollectionManager.drawCanvas(canvas, m_layersRenderingMode == kSingleSurfaceRendering);
-}
-
-TiledPage* GLWebViewState::sibling(TiledPage* page)
-{
- return (page == m_tiledPageA) ? m_tiledPageB : m_tiledPageA;
-}
-
-TiledPage* GLWebViewState::frontPage()
-{
- android::Mutex::Autolock lock(m_tiledPageLock);
- return m_usePageA ? m_tiledPageA : m_tiledPageB;
-}
-
-TiledPage* GLWebViewState::backPage()
-{
- android::Mutex::Autolock lock(m_tiledPageLock);
- return m_usePageA ? m_tiledPageB : m_tiledPageA;
-}
-
-void GLWebViewState::swapPages()
-{
- android::Mutex::Autolock lock(m_tiledPageLock);
- m_usePageA ^= true;
- TiledPage* oldPage = m_usePageA ? m_tiledPageB : m_tiledPageA;
- zoomManager()->swapPages();
- oldPage->discardTextures();
-}
-
-int GLWebViewState::baseContentWidth()
-{
- return m_surfaceCollectionManager.baseContentWidth();
-}
-int GLWebViewState::baseContentHeight()
-{
- return m_surfaceCollectionManager.baseContentHeight();
}
void GLWebViewState::setViewport(const SkRect& viewport, float scale)
@@ -236,19 +134,18 @@ void GLWebViewState::setViewport(const SkRect& viewport, float scale)
int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1;
TilesManager* manager = TilesManager::instance();
- int maxTextureCount = (viewMaxTileX + m_expandedTileBoundsX * 2) *
- (viewMaxTileY + m_expandedTileBoundsY * 2) * (manager->highEndGfx() ? 4 : 2);
+ int maxTextureCount = viewMaxTileX * viewMaxTileY * (manager->highEndGfx() ? 4 : 2);
manager->setMaxTextureCount(maxTextureCount);
- m_tiledPageA->updateBaseTileSize();
- m_tiledPageB->updateBaseTileSize();
+ // TODO: investigate whether we can move this return earlier.
if ((m_viewport == viewport)
- && (zoomManager()->futureScale() == scale)) {
+ && (m_scale == scale)) {
// everything below will stay the same, early return.
m_isViewportScrolling = false;
return;
}
+ m_scale = scale;
m_goingDown = m_viewport.fTop - viewport.fTop <= 0;
m_goingLeft = m_viewport.fLeft - viewport.fLeft >= 0;
@@ -261,12 +158,6 @@ void GLWebViewState::setViewport(const SkRect& viewport, float scale)
m_viewport.fLeft, m_viewport.fTop, m_viewport.fRight, m_viewport.fBottom,
m_viewport.width(), m_viewport.height(), scale,
zoomManager()->currentScale(), zoomManager()->futureScale());
-
- m_viewportTileBounds.set(
- static_cast<int>(floorf(viewport.fLeft * invTileContentWidth)),
- static_cast<int>(floorf(viewport.fTop * invTileContentHeight)),
- static_cast<int>(ceilf(viewport.fRight * invTileContentWidth)),
- static_cast<int>(ceilf(viewport.fBottom * invTileContentHeight)));
}
#ifdef MEASURES_PERF
@@ -282,14 +173,6 @@ void GLWebViewState::dumpMeasures()
}
#endif // MEASURES_PERF
-void GLWebViewState::resetFrameworkInval()
-{
- m_frameworkInval.setX(0);
- m_frameworkInval.setY(0);
- m_frameworkInval.setWidth(0);
- m_frameworkInval.setHeight(0);
-}
-
void GLWebViewState::addDirtyArea(const IntRect& rect)
{
if (rect.isEmpty())
@@ -311,21 +194,6 @@ void GLWebViewState::resetLayersDirtyArea()
m_frameworkLayersInval.setHeight(0);
}
-void GLWebViewState::drawBackground(Color& backgroundColor)
-{
- if (TilesManager::instance()->invertedScreen()) {
- float color = 1.0 - ((((float) backgroundColor.red() / 255.0) +
- ((float) backgroundColor.green() / 255.0) +
- ((float) backgroundColor.blue() / 255.0)) / 3.0);
- glClearColor(color, color, color, 1);
- } else {
- glClearColor((float)backgroundColor.red() / 255.0,
- (float)backgroundColor.green() / 255.0,
- (float)backgroundColor.blue() / 255.0, 1);
- }
- glClear(GL_COLOR_BUFFER_BIT);
-}
-
double GLWebViewState::setupDrawing(const IntRect& viewRect, const SkRect& visibleRect,
const IntRect& webViewRect, int titleBarHeight,
const IntRect& screenClip, float scale)
@@ -363,7 +231,6 @@ double GLWebViewState::setupDrawing(const IntRect& viewRect, const SkRect& visib
double currentTime = WTF::currentTime();
setViewport(visibleRect, scale);
- m_zoomManager.processNewScale(currentTime, scale);
return currentTime;
}
@@ -429,21 +296,8 @@ bool GLWebViewState::setLayersRenderingMode(TexturesResult& nbTexturesNeeded)
m_layersRenderingMode = kSingleSurfaceRendering;
// update the base surface if needed
- if (m_layersRenderingMode != layersRenderingMode
- && invalBase) {
- m_tiledPageA->discardTextures();
- m_tiledPageB->discardTextures();
- fullInval();
- return true;
- }
- return false;
-}
-
-void GLWebViewState::fullInval()
-{
- // TODO -- use base layer's size.
- IntRect ir(0, 0, 1E6, 1E6);
- inval(ir);
+ // TODO: inval base layergroup when going into single surface mode
+ return (m_layersRenderingMode != layersRenderingMode && invalBase);
}
bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
@@ -452,20 +306,11 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr)
{
TilesManager* tilesManager = TilesManager::instance();
- m_scale = scale;
tilesManager->getProfiler()->nextFrame(viewport.fLeft, viewport.fTop,
viewport.fRight, viewport.fBottom,
scale);
tilesManager->incDrawGLCount();
- float viewWidth = (viewport.fRight - viewport.fLeft) * TILE_PREFETCH_RATIO;
- float viewHeight = (viewport.fBottom - viewport.fTop) * TILE_PREFETCH_RATIO;
- bool noPrefetch = tilesManager->useMinimalMemory() || !tilesManager->highEndGfx();
- bool useHorzPrefetch = noPrefetch ? 0 : viewWidth < baseContentWidth();
- bool useVertPrefetch = noPrefetch ? 0 : viewHeight < baseContentHeight();
- m_expandedTileBoundsX = (useHorzPrefetch) ? TILE_PREFETCH_DISTANCE : 0;
- m_expandedTileBoundsY = (useVertPrefetch) ? TILE_PREFETCH_DISTANCE : 0;
-
ALOGV("drawGL, rect(%d, %d, %d, %d), viewport(%.2f, %.2f, %.2f, %.2f)",
rect.x(), rect.y(), rect.width(), rect.height(),
viewport.fLeft, viewport.fTop, viewport.fRight, viewport.fBottom);
@@ -497,7 +342,7 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
}
// gather the textures we can use
- tilesManager->gatherLayerTextures();
+ tilesManager->gatherTextures();
double currentTime = setupDrawing(rect, viewport, webViewRect, titleBarHeight, clip, scale);
@@ -509,8 +354,6 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
scale, fastSwap,
collectionsSwappedPtr, newCollectionHasAnimPtr,
&nbTexturesNeeded);
- if (!ret)
- resetFrameworkInval();
int nbTexturesForImages = ImagesManager::instance()->nbTextures();
ALOGV("*** We have %d textures for images, %d full, %d clipped, total %d / %d",
@@ -530,22 +373,15 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
// ret==true && 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_frameworkInval.isEmpty();
+ bool fullScreenInval = m_frameworkLayersInval.isEmpty();
if (!fullScreenInval) {
- FloatRect frameworkInval = tilesManager->shader()->rectInInvScreenCoord(
- m_frameworkInval);
- // Inflate the invalidate rect to avoid precision lost.
- frameworkInval.inflate(1);
- IntRect inval(frameworkInval.x(), frameworkInval.y(),
- frameworkInval.width(), frameworkInval.height());
-
- inval.unite(m_frameworkLayersInval);
+ m_frameworkLayersInval.inflate(1);
- invalRect->setX(inval.x());
- invalRect->setY(inval.y());
- invalRect->setWidth(inval.width());
- invalRect->setHeight(inval.height());
+ invalRect->setX(m_frameworkLayersInval.x());
+ invalRect->setY(m_frameworkLayersInval.y());
+ invalRect->setWidth(m_frameworkLayersInval.width());
+ invalRect->setHeight(m_frameworkLayersInval.height());
ALOGV("invalRect(%d, %d, %d, %d)", inval.x(),
inval.y(), inval.width(), inval.height());
@@ -562,8 +398,6 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
invalRect->setWidth(0);
invalRect->setHeight(0);
}
- } else {
- resetFrameworkInval();
}
showFrameInfo(rect, *collectionsSwappedPtr);
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h
index fcdd07c..85c90fd 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -35,9 +35,7 @@
#include "SkCanvas.h"
#include "SkRect.h"
#include "SkRegion.h"
-#include "TiledPage.h"
#include "SurfaceCollectionManager.h"
-#include "ZoomManager.h"
#include <utils/threads.h>
// Performance measurements probe
@@ -171,39 +169,16 @@ public:
GLWebViewState();
~GLWebViewState();
- ZoomManager* zoomManager() { return &m_zoomManager; }
- const SkIRect& futureViewport() const { return m_futureViewportTileBounds; }
- void setFutureViewport(const SkIRect& viewport) { m_futureViewportTileBounds = viewport; }
-
- void paintBaseLayerContent(SkCanvas* canvas);
bool setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndicator,
bool isPictureAfterFirstLayout);
void paintExtras();
GLExtras* glExtras() { return &m_glExtras; }
- TiledPage* sibling(TiledPage* page);
- TiledPage* frontPage();
- TiledPage* backPage();
- void swapPages();
-
- // dimensions of the current base layer
- int baseContentWidth();
- int baseContentHeight();
-
- // a rect containing the coordinates of all tiles in the current viewport
- const SkIRect& viewportTileBounds() const { return m_viewportTileBounds; }
- // a rect containing the viewportTileBounds before there was a scale change
- const SkIRect& preZoomBounds() const { return m_preZoomBounds; }
- void setPreZoomBounds(const SkIRect& bounds) { m_preZoomBounds = bounds; }
-
void setIsScrolling(bool isScrolling) { m_isScrolling = isScrolling; }
bool isScrolling() { return m_isScrolling || m_isViewportScrolling; }
- void drawBackground(Color& backgroundColor);
-
bool setLayersRenderingMode(TexturesResult&);
- void fullInval();
bool drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
IntRect& webViewRect, int titleBarHeight,
@@ -214,7 +189,6 @@ public:
void dumpMeasures();
#endif
- void resetFrameworkInval();
void addDirtyArea(const IntRect& rect);
void resetLayersDirtyArea();
@@ -225,9 +199,6 @@ public:
m_goingLeft = goingLeft;
}
- int expandedTileBoundsX() { return m_expandedTileBoundsX; }
- int expandedTileBoundsY() { return m_expandedTileBoundsY; }
-
float scale() { return m_scale; }
enum LayersRenderingMode {
@@ -242,10 +213,7 @@ public:
LayersRenderingMode layersRenderingMode() { return m_layersRenderingMode; }
void scrollLayer(int layerId, int x, int y);
- void invalRegion(const SkRegion& region);
-
private:
- void inval(const IntRect& rect);
void setViewport(const SkRect& viewport, float scale);
double setupDrawing(const IntRect& viewRect, const SkRect& visibleRect,
const IntRect& webViewRect, int titleBarHeight,
@@ -255,18 +223,7 @@ private:
float b, float a);
double m_prevDrawTime;
- ZoomManager m_zoomManager;
- android::Mutex m_tiledPageLock;
SkRect m_viewport;
- SkIRect m_viewportTileBounds;
- SkIRect m_futureViewportTileBounds;
- SkIRect m_preZoomBounds;
-
- bool m_usePageA;
- TiledPage* m_tiledPageA;
- TiledPage* m_tiledPageB;
- IntRect m_lastInval;
- IntRect m_frameworkInval;
IntRect m_frameworkLayersInval;
#ifdef MEASURES_PERF
@@ -282,9 +239,6 @@ private:
bool m_goingDown;
bool m_goingLeft;
- int m_expandedTileBoundsX;
- int m_expandedTileBoundsY;
-
float m_scale;
LayersRenderingMode m_layersRenderingMode;
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
index e42d075..11a449a 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
@@ -173,7 +173,8 @@ bool ImageTexture::prepareGL(GLWebViewState* state)
return false;
if (!m_texture && m_picture) {
- m_texture = new TiledTexture();
+ bool isLayerTile = true;
+ m_texture = new TiledTexture(isLayerTile);
SkRegion region;
region.setRect(0, 0, m_image->width(), m_image->height());
m_texture->markAsDirty(region);
diff --git a/Source/WebCore/platform/graphics/android/Layer.cpp b/Source/WebCore/platform/graphics/android/Layer.cpp
index 7453a24..48e36fc 100644
--- a/Source/WebCore/platform/graphics/android/Layer.cpp
+++ b/Source/WebCore/platform/graphics/android/Layer.cpp
@@ -1,5 +1,10 @@
+#define LOG_TAG "Layer"
+#define LOG_NDEBUG 1
+
#include "config.h"
#include "Layer.h"
+
+#include "AndroidLog.h"
#include "SkCanvas.h"
//#define DEBUG_DRAW_LAYER_BOUNDS
diff --git a/Source/WebCore/platform/graphics/android/Layer.h b/Source/WebCore/platform/graphics/android/Layer.h
index e872278..996547b 100644
--- a/Source/WebCore/platform/graphics/android/Layer.h
+++ b/Source/WebCore/platform/graphics/android/Layer.h
@@ -120,7 +120,7 @@ public:
This does not include the childrenMatrix, since that is only applied
after this layer draws (but before its children draw).
*/
- void getLocalTransform(SkMatrix* matrix) const;
+ virtual void getLocalTransform(SkMatrix* matrix) const;
/** Return, in matrix, the concatenation of transforms that are applied
from this layer's root parent to the layer itself.
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 6d8dc34..167f7e7 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -54,6 +54,7 @@ private:
///////////////////////////////////////////////////////////////////////////////
LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(),
+ m_uniqueId(++gUniqueId),
m_haveClip(false),
m_backfaceVisibility(true),
m_visible(true),
@@ -62,7 +63,6 @@ LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(),
m_isPositionAbsolute(false),
m_fixedPosition(0),
m_zValue(0),
- m_uniqueId(++gUniqueId),
m_content(0),
m_imageCRC(0),
m_scale(1),
@@ -83,11 +83,11 @@ LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(),
}
LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
+ m_uniqueId(layer.m_uniqueId),
m_haveClip(layer.m_haveClip),
m_isPositionAbsolute(layer.m_isPositionAbsolute),
m_fixedPosition(0),
m_zValue(layer.m_zValue),
- m_uniqueId(layer.m_uniqueId),
m_owningLayer(layer.m_owningLayer),
m_type(LayerAndroid::UILayer),
m_intrinsicallyComposited(layer.m_intrinsicallyComposited),
@@ -169,28 +169,6 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
#endif
}
-LayerAndroid::LayerAndroid(SkPicture* picture) : Layer(),
- m_haveClip(false),
- m_fixedPosition(0),
- m_zValue(0),
- m_uniqueId(++gUniqueId),
- m_imageCRC(0),
- m_scale(1),
- m_lastComputeTextureSize(0),
- m_owningLayer(0),
- m_type(LayerAndroid::NavCacheLayer),
- m_intrinsicallyComposited(true),
- m_layerGroup(0)
-{
- m_backgroundColor = 0;
- m_content = new PictureLayerContent(picture);
- m_dirtyRegion.setEmpty();
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->increment("LayerAndroid - from picture");
- ClassTracker::instance()->add(this);
-#endif
-}
-
LayerAndroid::~LayerAndroid()
{
if (m_imageCRC)
@@ -207,8 +185,6 @@ LayerAndroid::~LayerAndroid()
ClassTracker::instance()->decrement("LayerAndroid");
else if (m_type == LayerAndroid::UILayer)
ClassTracker::instance()->decrement("LayerAndroid - recopy (UI)");
- else if (m_type == LayerAndroid::NavCacheLayer)
- ClassTracker::instance()->decrement("LayerAndroid - from picture");
#endif
}
@@ -483,6 +459,9 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
} else {
setDrawClip(clipping);
}
+ 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());
if (!m_backfaceVisibility
&& m_drawTransform.inverse().m33() < 0) {
@@ -681,7 +660,7 @@ static inline bool compareLayerZ(const LayerAndroid* a, const LayerAndroid* b)
bool LayerAndroid::canJoinGroup(LayerGroup* group)
{
-#if DISABLE_LAYER_MERGE
+#ifdef DISABLE_LAYER_MERGE
return false;
#else
// returns true if the layer can be merged onto the layergroup
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index 43b4ff9..c7028c5 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -71,7 +71,6 @@ class GLWebViewState;
class IFrameLayerAndroid;
class LayerMergeState;
class RenderLayer;
-class TiledPage;
class PaintedSurface;
class TexturesResult {
@@ -91,10 +90,10 @@ public:
class TEST_EXPORT LayerAndroid : public Layer {
public:
- typedef enum { UndefinedLayer, WebCoreLayer, UILayer, NavCacheLayer } LayerType;
+ typedef enum { UndefinedLayer, WebCoreLayer, UILayer } LayerType;
typedef enum { StandardLayer, ScrollableLayer,
IFrameLayer, IFrameContentLayer,
- CanvasLayer } SubclassType;
+ CanvasLayer, BaseLayer } SubclassType;
typedef enum { InvalidateNone = 0, InvalidateLayers } InvalidateFlags;
String subclassName()
@@ -110,17 +109,16 @@ public:
return "IFrameContentLayer";
case LayerAndroid::CanvasLayer:
return "CanvasLayer";
+ case LayerAndroid::BaseLayer:
+ return "BaseLayer";
}
return "Undefined";
}
LayerAndroid(RenderLayer* owner);
LayerAndroid(const LayerAndroid& layer);
- LayerAndroid(SkPicture*);
virtual ~LayerAndroid();
- virtual TiledPage* page() { return 0; }
-
void setBackfaceVisibility(bool value) { m_backfaceVisibility = value; }
void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; }
FloatPoint translation() const;
@@ -160,7 +158,7 @@ public:
void setAnchorPointZ(float z) { m_anchorPointZ = z; }
float anchorPointZ() { return m_anchorPointZ; }
void setDrawTransform(const TransformationMatrix& transform) { m_drawTransform = transform; }
- const TransformationMatrix* drawTransform() const { return &m_drawTransform; }
+ virtual const TransformationMatrix* drawTransform() const { return &m_drawTransform; }
void setChildrenTransform(const TransformationMatrix& t) { m_childrenTransform = t; }
void setDrawClip(const FloatRect& rect) { m_clippingRect = rect; }
const FloatRect& drawClip() { return m_clippingRect; }
@@ -288,6 +286,7 @@ protected:
virtual InvalidateFlags onSetHwAccelerated(bool hwAccelerated) { return InvalidateNone; }
IntPoint m_offset;
TransformationMatrix m_drawTransform;
+ int m_uniqueId;
private:
#if DUMP_NAV_CACHE
@@ -331,8 +330,6 @@ private:
FloatRect m_clippingRect;
- int m_uniqueId;
-
// Note that m_content and m_imageCRC are mutually exclusive;
// m_content is used when WebKit is asked to paint the layer's
// content, while m_imageCRC references an image that we directly
diff --git a/Source/WebCore/platform/graphics/android/LayerContent.h b/Source/WebCore/platform/graphics/android/LayerContent.h
index 32108ec..97bc32a 100644
--- a/Source/WebCore/platform/graphics/android/LayerContent.h
+++ b/Source/WebCore/platform/graphics/android/LayerContent.h
@@ -27,6 +27,7 @@
#define LayerContent_h
#include "SkRefCnt.h"
+#include <utils/threads.h>
class SkCanvas;
class SkPicture;
@@ -44,6 +45,10 @@ public:
virtual void draw(SkCanvas* canvas) = 0;
virtual void serialize(SkWStream* stream) = 0;
+
+protected:
+ // used to prevent parallel draws, as both SkPicture and PictureSet don't support them
+ android::Mutex m_drawLock;
};
} // WebCore
diff --git a/Source/WebCore/platform/graphics/android/LayerGroup.cpp b/Source/WebCore/platform/graphics/android/LayerGroup.cpp
index f360919..d0138cc 100644
--- a/Source/WebCore/platform/graphics/android/LayerGroup.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerGroup.cpp
@@ -158,17 +158,18 @@ IntRect LayerGroup::visibleArea()
void LayerGroup::prepareGL(bool layerTilesDisabled)
{
+ bool tilesDisabled = layerTilesDisabled && !isBase();
if (!m_dualTiledTexture) {
ALOGV("prepareGL on LG %p, no DTT, needsTexture? %d",
this, m_dualTiledTexture, needsTexture());
- if (needsTexture())
- m_dualTiledTexture = new DualTiledTexture();
- else
+ if (!needsTexture())
return;
+
+ m_dualTiledTexture = new DualTiledTexture(isBase());
}
- if (layerTilesDisabled) {
+ if (tilesDisabled) {
m_dualTiledTexture->discardTextures();
} else {
bool allowZoom = hasText(); // only allow for scale > 1 if painting vectors
@@ -183,15 +184,19 @@ void LayerGroup::prepareGL(bool layerTilesDisabled)
bool LayerGroup::drawGL(bool layerTilesDisabled)
{
+ bool tilesDisabled = layerTilesDisabled && !isBase();
if (!getFirstLayer()->visible())
return false;
- FloatRect drawClip = getFirstLayer()->drawClip();
- FloatRect clippingRect = TilesManager::instance()->shader()->rectInScreenCoord(drawClip);
- TilesManager::instance()->shader()->clip(clippingRect);
+ if (!isBase()) {
+ // TODO: why are clipping regions wrong for base layer?
+ FloatRect drawClip = getFirstLayer()->drawClip();
+ FloatRect clippingRect = TilesManager::instance()->shader()->rectInScreenCoord(drawClip);
+ TilesManager::instance()->shader()->clip(clippingRect);
+ }
bool askRedraw = false;
- if (m_dualTiledTexture && !layerTilesDisabled) {
+ if (m_dualTiledTexture && !tilesDisabled) {
ALOGV("drawGL on LG %p with DTT %p", this, m_dualTiledTexture);
IntRect drawArea = visibleArea();
@@ -200,7 +205,7 @@ bool LayerGroup::drawGL(bool layerTilesDisabled)
// draw member layers (draws image textures, glextras)
for (unsigned int i = 0; i < m_layers.size(); i++)
- askRedraw |= m_layers[i]->drawGL(layerTilesDisabled);
+ askRedraw |= m_layers[i]->drawGL(tilesDisabled);
return askRedraw;
}
@@ -225,6 +230,7 @@ IntRect LayerGroup::computePrepareArea() {
IntRect area;
if (!getFirstLayer()->contentIsScrollable()
+ && !isBase()
&& getFirstLayer()->state()->layersRenderingMode() == GLWebViewState::kAllTextures) {
area = singleLayer() ? getFirstLayer()->unclippedArea() : m_unclippedArea;
@@ -241,16 +247,34 @@ IntRect LayerGroup::computePrepareArea() {
void LayerGroup::computeTexturesAmount(TexturesResult* result)
{
- if (!m_dualTiledTexture)
+ if (!m_dualTiledTexture || isBase())
return;
m_dualTiledTexture->computeTexturesAmount(result, getFirstLayer());
}
+bool LayerGroup::isBase()
+{
+ // base layer group
+ // - doesn't use layer tiles (disables blending, doesn't compute textures amount)
+ // - ignores clip rects
+ // - only prepares clippedArea
+ return getFirstLayer()->subclassType() == LayerAndroid::BaseLayer;
+}
+
bool LayerGroup::paint(BaseTile* tile, SkCanvas* canvas)
{
if (singleLayer()) {
getFirstLayer()->contentDraw(canvas, Layer::UnmergedLayers);
+
+ // TODO: double buffer by disabling SurfaceCollection swaps and position
+ // updates until painting complete
+
+ // In single surface mode, draw layer content onto the base layer
+ if (isBase()
+ && getFirstLayer()->countChildren()
+ && getFirstLayer()->state()->layersRenderingMode() > GLWebViewState::kClippedTextures)
+ getFirstLayer()->getChild(0)->drawCanvas(canvas, true, Layer::FlattenedLayers);
} else {
SkAutoCanvasRestore acr(canvas, true);
SkMatrix matrix;
diff --git a/Source/WebCore/platform/graphics/android/LayerGroup.h b/Source/WebCore/platform/graphics/android/LayerGroup.h
index 90001a5..edfb30d 100644
--- a/Source/WebCore/platform/graphics/android/LayerGroup.h
+++ b/Source/WebCore/platform/graphics/android/LayerGroup.h
@@ -37,8 +37,8 @@ namespace WebCore {
class BaseTile;
class DualTiledTexture;
-class TexturesResult;
class LayerAndroid;
+class TexturesResult;
class LayerGroup : public TilePainter {
public:
@@ -47,7 +47,6 @@ public:
bool tryUpdateLayerGroup(LayerGroup* oldLayerGroup);
-
void addLayer(LayerAndroid* layer, const TransformationMatrix& transform);
IntRect visibleArea();
void prepareGL(bool layerTilesDisabled);
@@ -62,6 +61,7 @@ public:
bool singleLayer() { return m_layers.size() == 1; }
bool needsTexture() { return m_needsTexture; }
bool hasText() { return m_hasText; }
+ bool isBase();
// TilePainter methods
virtual bool paint(BaseTile* tile, SkCanvas* canvas);
diff --git a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp
index 1fcb765..910ba21 100644
--- a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp
+++ b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp
@@ -23,20 +23,24 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define LOG_TAG "PaintTileOperation"
+#define LOG_NDEBUG 1
+
#include "config.h"
#include "PaintTileOperation.h"
+
+#include "AndroidLog.h"
#include "ImageTexture.h"
#include "ImagesManager.h"
#include "LayerAndroid.h"
-#include "TiledPage.h"
#include "TilesManager.h"
namespace WebCore {
-PaintTileOperation::PaintTileOperation(BaseTile* tile, TilePainter* painter)
- : QueuedOperation(tile->page())
- , m_tile(tile)
+PaintTileOperation::PaintTileOperation(BaseTile* tile, TilePainter* painter, GLWebViewState* state)
+ : m_tile(tile)
, m_painter(painter)
+ , m_state(state)
{
if (m_tile)
m_tile->setRepaintPending(true);
@@ -80,15 +84,6 @@ int PaintTileOperation::priority()
int priority = 200000;
- // if scrolling, prioritize the prefetch page, otherwise deprioritize
- TiledPage* page = m_tile->page();
- if (page && page->isPrefetchPage()) {
- if (page->glWebViewState()->isScrolling())
- priority = 0;
- else
- priority = 400000;
- }
-
// prioritize higher draw count
unsigned long long currentDraw = TilesManager::instance()->getDrawGLCount();
unsigned long long drawDelta = currentDraw - m_tile->drawCount();
@@ -100,7 +95,7 @@ int PaintTileOperation::priority()
// for base tiles, prioritize based on position
if (!m_tile->isLayerTile()) {
- bool goingDown = m_tile->page()->scrollingDown();
+ bool goingDown = m_state->goingDown();
priority += m_tile->x();
if (goingDown)
diff --git a/Source/WebCore/platform/graphics/android/PaintTileOperation.h b/Source/WebCore/platform/graphics/android/PaintTileOperation.h
index 05825e2..468f6d2 100644
--- a/Source/WebCore/platform/graphics/android/PaintTileOperation.h
+++ b/Source/WebCore/platform/graphics/android/PaintTileOperation.h
@@ -38,7 +38,7 @@ class ImageTexture;
class PaintTileOperation : public QueuedOperation {
public:
- PaintTileOperation(BaseTile* tile, TilePainter* painter);
+ PaintTileOperation(BaseTile* tile, TilePainter* painter, GLWebViewState* state);
virtual ~PaintTileOperation();
virtual bool operator==(const QueuedOperation* operation);
virtual void run();
@@ -50,6 +50,7 @@ public:
private:
BaseTile* m_tile;
TilePainter* m_painter;
+ GLWebViewState* m_state;
};
class ScaleFilter : public OperationFilter {
diff --git a/Source/WebCore/platform/graphics/android/PictureLayerContent.cpp b/Source/WebCore/platform/graphics/android/PictureLayerContent.cpp
index cf2e569..6beed16 100644
--- a/Source/WebCore/platform/graphics/android/PictureLayerContent.cpp
+++ b/Source/WebCore/platform/graphics/android/PictureLayerContent.cpp
@@ -90,6 +90,7 @@ void PictureLayerContent::draw(SkCanvas* canvas)
if (!m_picture)
return;
+ android::Mutex::Autolock lock(m_drawLock);
canvas->drawPicture(*m_picture);
}
diff --git a/Source/WebCore/platform/graphics/android/PictureSetLayerContent.cpp b/Source/WebCore/platform/graphics/android/PictureSetLayerContent.cpp
index bc024eb..c2c008b 100644
--- a/Source/WebCore/platform/graphics/android/PictureSetLayerContent.cpp
+++ b/Source/WebCore/platform/graphics/android/PictureSetLayerContent.cpp
@@ -17,8 +17,11 @@ PictureSetLayerContent::~PictureSetLayerContent()
void PictureSetLayerContent::draw(SkCanvas* canvas)
{
- if (!m_pictureSet.isEmpty())
- m_pictureSet.draw(canvas);
+ if (m_pictureSet.isEmpty())
+ return;
+
+ android::Mutex::Autolock lock(m_drawLock);
+ m_pictureSet.draw(canvas);
}
void PictureSetLayerContent::serialize(SkWStream* stream)
diff --git a/Source/WebCore/platform/graphics/android/QueuedOperation.h b/Source/WebCore/platform/graphics/android/QueuedOperation.h
index 2f36547..f98efcd 100644
--- a/Source/WebCore/platform/graphics/android/QueuedOperation.h
+++ b/Source/WebCore/platform/graphics/android/QueuedOperation.h
@@ -28,19 +28,12 @@
namespace WebCore {
-class TiledPage;
-
class QueuedOperation {
public:
- QueuedOperation(TiledPage* page)
- : m_page(page) {}
virtual ~QueuedOperation() {}
virtual void run() = 0;
virtual bool operator==(const QueuedOperation* operation) = 0;
- virtual int priority() { return -1; }
- TiledPage* page() const { return m_page; }
-private:
- TiledPage* m_page;
+ virtual int priority() = 0;
};
class OperationFilter {
@@ -49,19 +42,6 @@ public:
virtual bool check(QueuedOperation* operation) = 0;
};
-class PageFilter : public OperationFilter {
-public:
- PageFilter(TiledPage* page) : m_page(page) {}
- virtual bool check(QueuedOperation* operation)
- {
- if (operation->page() == m_page)
- return true;
- return false;
- }
-private:
- TiledPage* m_page;
-};
-
}
#endif // QueuedOperation_h
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
index 33829e3..d1b70f7 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -559,6 +559,9 @@ void ShaderProgram::clip(const FloatRect& clip)
if (clip == m_clipRect)
return;
+ ALOGV("--clipping rect %f %f, %f x %f",
+ clip.x(), clip.y(), clip.width(), clip.height());
+
// we should only call glScissor in this function, so that we can easily
// track the current clipping rect.
diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp
index a4c0ac8..1110c29 100644
--- a/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp
+++ b/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp
@@ -44,34 +44,29 @@ namespace WebCore {
// TILED PAINTING / GROUPS //
////////////////////////////////////////////////////////////////////////////////
-SurfaceCollection::SurfaceCollection(BaseLayerAndroid* baseLayer)
- : m_baseLayer(baseLayer)
- , m_compositedRoot(0)
+SurfaceCollection::SurfaceCollection(LayerAndroid* layer)
+ : m_compositedRoot(layer)
{
- if (!m_baseLayer)
+ if (!m_compositedRoot)
return;
- SkSafeRef(m_baseLayer);
- if (m_baseLayer->countChildren()) {
- m_compositedRoot = static_cast<LayerAndroid*>(m_baseLayer->getChild(0));
+ SkSafeRef(m_compositedRoot);
- // calculate draw transforms and z values
- SkRect visibleRect = SkRect::MakeLTRB(0, 0, 1, 1);
- m_baseLayer->updateLayerPositions(visibleRect);
+ // calculate draw transforms and z values
+ SkRect visibleRect = SkRect::MakeLTRB(0, 0, 1, 1);
+ m_compositedRoot->updateLayerPositions(visibleRect);
+ // TODO: updateGLPositionsAndScale?
- // allocate groups for layers, merging where possible
- ALOGV("new tree, allocating groups for tree %p", m_baseLayer);
+ // allocate groups for layers, merging where possible
+ ALOGV("new tree, allocating groups for tree %p", m_baseLayer);
- LayerMergeState layerMergeState(&m_layerGroups);
- m_compositedRoot->assignGroups(&layerMergeState);
- }
+ LayerMergeState layerMergeState(&m_layerGroups);
+ m_compositedRoot->assignGroups(&layerMergeState);
// set the layergroups' and tiledpages' update count, to be drawn on painted tiles
unsigned int updateCount = TilesManager::instance()->incWebkitContentUpdates();
for (unsigned int i = 0; i < m_layerGroups.size(); i++)
m_layerGroups[i]->setUpdateCount(updateCount);
- m_baseLayer->state()->frontPage()->setUpdateCount(updateCount);
- m_baseLayer->state()->backPage()->setUpdateCount(updateCount);
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("SurfaceCollection");
@@ -80,7 +75,7 @@ SurfaceCollection::SurfaceCollection(BaseLayerAndroid* baseLayer)
SurfaceCollection::~SurfaceCollection()
{
- SkSafeUnref(m_baseLayer);
+ SkSafeUnref(m_compositedRoot);
for (unsigned int i = 0; i < m_layerGroups.size(); i++)
SkSafeUnref(m_layerGroups[i]);
m_layerGroups.clear();
@@ -90,15 +85,10 @@ SurfaceCollection::~SurfaceCollection()
#endif
}
-void SurfaceCollection::prepareGL(const SkRect& visibleRect, float scale, double currentTime)
+void SurfaceCollection::prepareGL(const SkRect& visibleRect)
{
- if (!m_baseLayer)
- return;
-
- m_baseLayer->prepareGL(visibleRect, scale, currentTime);
-
if (m_compositedRoot) {
- m_baseLayer->updateLayerPositions(visibleRect);
+ updateLayerPositions(visibleRect);
bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
> GLWebViewState::kClippedTextures;
for (unsigned int i = 0; i < m_layerGroups.size(); i++)
@@ -106,20 +96,15 @@ void SurfaceCollection::prepareGL(const SkRect& visibleRect, float scale, double
}
}
-bool SurfaceCollection::drawGL(const SkRect& visibleRect, float scale)
+bool SurfaceCollection::drawGL(const SkRect& visibleRect)
{
#ifdef DEBUG_COUNT
ClassTracker::instance()->show();
#endif
- if (!m_baseLayer)
- return false;
-
- m_baseLayer->drawGL(scale);
-
bool needsRedraw = false;
if (m_compositedRoot) {
- m_baseLayer->updateLayerPositions(visibleRect);
+ updateLayerPositions(visibleRect);
bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
> GLWebViewState::kClippedTextures;
for (unsigned int i = 0; i < m_layerGroups.size(); i++)
@@ -129,25 +114,22 @@ bool SurfaceCollection::drawGL(const SkRect& visibleRect, float scale)
return needsRedraw;
}
-void SurfaceCollection::swapTiles()
+void SurfaceCollection::drawBackground()
{
- if (!m_baseLayer)
- return;
-
- m_baseLayer->swapTiles();
+ Color background = Color::white;
+ if (m_compositedRoot)
+ background = static_cast<BaseLayerAndroid*>(m_compositedRoot)->getBackgroundColor();
+ GLUtils::drawBackground(background);
+}
+void SurfaceCollection::swapTiles()
+{
for (unsigned int i = 0; i < m_layerGroups.size(); i++)
m_layerGroups[i]->swapTiles();
}
bool SurfaceCollection::isReady()
{
- if (!m_baseLayer)
- return true;
-
- if (!m_baseLayer->isReady())
- return false;
-
if (!m_compositedRoot)
return true;
@@ -172,32 +154,13 @@ void SurfaceCollection::computeTexturesAmount(TexturesResult* result)
m_layerGroups[i]->computeTexturesAmount(result);
}
-void SurfaceCollection::drawCanvas(SkCanvas* canvas, bool drawLayers)
-{
- // TODO: move this functionality out!
- if (!m_baseLayer)
- return;
-
- m_baseLayer->drawCanvas(canvas);
-
- // draw the layers onto the same canvas (for single surface mode)
- if (drawLayers && m_compositedRoot)
- m_compositedRoot->drawCanvas(canvas, true, Layer::FlattenedLayers);
-}
-
-
////////////////////////////////////////////////////////////////////////////////
// RECURSIVE ANIMATION / INVALS / LAYERS //
////////////////////////////////////////////////////////////////////////////////
void SurfaceCollection::setIsPainting(SurfaceCollection* drawingSurface)
{
- if (!m_baseLayer)
- return;
-
- m_baseLayer->setIsPainting();
-
- if (!drawingSurface)
+ if (!m_compositedRoot || !drawingSurface)
return;
for (unsigned int i = 0; i < m_layerGroups.size(); i++) {
@@ -215,25 +178,24 @@ void SurfaceCollection::setIsPainting(SurfaceCollection* drawingSurface)
void SurfaceCollection::setIsDrawing()
{
- if (m_compositedRoot)
- m_compositedRoot->initAnimations();
+ if (!m_compositedRoot)
+ return;
+
+ m_compositedRoot->initAnimations();
}
void SurfaceCollection::mergeInvalsInto(SurfaceCollection* replacementSurface)
{
- if (!m_baseLayer)
- return;
-
- m_baseLayer->mergeInvalsInto(replacementSurface->m_baseLayer);
-
if (m_compositedRoot && replacementSurface->m_compositedRoot)
m_compositedRoot->mergeInvalsInto(replacementSurface->m_compositedRoot);
}
void SurfaceCollection::evaluateAnimations(double currentTime)
{
- if (m_compositedRoot)
- m_compositedRoot->evaluateAnimations(currentTime);
+ if (!m_compositedRoot)
+ return;
+
+ m_compositedRoot->evaluateAnimations(currentTime);
}
bool SurfaceCollection::hasCompositedLayers()
@@ -246,25 +208,34 @@ bool SurfaceCollection::hasCompositedAnimations()
return m_compositedRoot != 0 && m_compositedRoot->hasAnimations();
}
-int SurfaceCollection::baseContentWidth()
+void SurfaceCollection::updateScrollableLayer(int layerId, int x, int y)
{
- // TODO: move this functionality out!
- return m_baseLayer ? m_baseLayer->content()->width() : 0;
-}
+ if (!m_compositedRoot)
+ return;
-int SurfaceCollection::baseContentHeight()
-{
- // TODO: move this functionality out!
- return m_baseLayer ? m_baseLayer->content()->height() : 0;
+ LayerAndroid* layer = m_compositedRoot->findById(layerId);
+ if (layer && layer->contentIsScrollable())
+ static_cast<ScrollableLayerAndroid*>(layer)->scrollTo(x, y);
}
-void SurfaceCollection::updateScrollableLayer(int layerId, int x, int y)
+void SurfaceCollection::updateLayerPositions(const SkRect& visibleRect)
{
- if (m_compositedRoot) {
- LayerAndroid* layer = m_compositedRoot->findById(layerId);
- if (layer && layer->contentIsScrollable())
- static_cast<ScrollableLayerAndroid*>(layer)->scrollTo(x, y);
- }
+ if (!m_compositedRoot)
+ return;
+
+ TransformationMatrix ident;
+ m_compositedRoot->updateLayerPositions(visibleRect);
+ FloatRect clip(0, 0, 1e10, 1e10);
+ m_compositedRoot->updateGLPositionsAndScale(
+ ident, clip, 1, m_compositedRoot->state()->scale());
+
+#ifdef DEBUG
+ m_compositedRoot->showLayer(0);
+ ALOGV("We have %d layers, %d textured",
+ m_compositedRoot->nbLayers(),
+ m_compositedRoot->nbTexturedLayers());
+#endif
}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollection.h b/Source/WebCore/platform/graphics/android/SurfaceCollection.h
index 921929b..61a523c 100644
--- a/Source/WebCore/platform/graphics/android/SurfaceCollection.h
+++ b/Source/WebCore/platform/graphics/android/SurfaceCollection.h
@@ -35,7 +35,6 @@ class SkRegion;
namespace WebCore {
-class BaseLayerAndroid;
class LayerAndroid;
class LayerGroup;
class TexturesResult;
@@ -43,16 +42,16 @@ class TexturesResult;
class SurfaceCollection : public SkRefCnt {
// TODO: investigate webkit threadsafe ref counting
public:
- SurfaceCollection(BaseLayerAndroid* baseLayer);
+ SurfaceCollection(LayerAndroid* compositedRoot);
virtual ~SurfaceCollection();
// Tiled painting methods (executed on groups)
- void prepareGL(const SkRect& visibleRect, float scale, double currentTime);
- bool drawGL(const SkRect& visibleRect, float scale);
+ void prepareGL(const SkRect& visibleRect);
+ bool drawGL(const SkRect& visibleRect);
+ void drawBackground();
void swapTiles();
bool isReady();
void computeTexturesAmount(TexturesResult* result);
- void drawCanvas(SkCanvas* canvas, bool drawLayers);
// Recursive tree methods (animations, invals, etc)
void setIsPainting(SurfaceCollection* drawingSurfaceCollection);
@@ -62,12 +61,10 @@ public:
bool hasCompositedLayers();
bool hasCompositedAnimations();
- int baseContentWidth();
- int baseContentHeight();
void updateScrollableLayer(int layerId, int x, int y);
private:
- BaseLayerAndroid* m_baseLayer;
+ void updateLayerPositions(const SkRect& visibleRect);
LayerAndroid* m_compositedRoot;
Vector<LayerGroup*> m_layerGroups;
};
diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp
index 633651d..8f2b7bd 100644
--- a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp
+++ b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.cpp
@@ -30,7 +30,6 @@
#include "SurfaceCollectionManager.h"
#include "AndroidLog.h"
-#include "BaseLayerAndroid.h"
#include "LayerGroup.h"
#include "TilesManager.h"
#include "SurfaceCollection.h"
@@ -179,7 +178,7 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
m_paintingCollection->evaluateAnimations(currentTime);
- m_paintingCollection->prepareGL(visibleRect, scale, currentTime);
+ m_paintingCollection->prepareGL(visibleRect);
m_paintingCollection->computeTexturesAmount(texturesResultPtr);
if (!TilesManager::instance()->useDoubleBuffering() || m_paintingCollection->isReady()) {
@@ -194,7 +193,7 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
}
} else if (m_drawingCollection) {
ALOGV("preparing drawing collection %p", m_drawingCollection);
- m_drawingCollection->prepareGL(visibleRect, scale, currentTime);
+ m_drawingCollection->prepareGL(visibleRect);
m_drawingCollection->computeTexturesAmount(texturesResultPtr);
}
@@ -217,12 +216,17 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
}
m_drawingCollection->evaluateAnimations(currentTime);
+
ALOGV("drawing collection %p", m_drawingCollection);
- ret |= m_drawingCollection->drawGL(visibleRect, scale);
+ m_drawingCollection->drawBackground();
+ ret |= m_drawingCollection->drawGL(visibleRect);
+ } else if (m_paintingCollection) {
+ // Draw background color while tiles are being painted.
+ m_paintingCollection->drawBackground();
} else {
// Dont have a drawing collection, draw white background
Color defaultBackground = Color::white;
- m_state->drawBackground(defaultBackground);
+ GLUtils::drawBackground(defaultBackground);
}
if (m_paintingCollection) {
@@ -233,40 +237,4 @@ bool SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
return ret;
}
-// draw for base tile - called on TextureGeneration thread
-void SurfaceCollectionManager::drawCanvas(SkCanvas* canvas, bool drawLayers)
-{
- SurfaceCollection* paintingCollection = 0;
- m_paintSwapLock.lock();
- paintingCollection = m_paintingCollection ? m_paintingCollection : m_drawingCollection;
- SkSafeRef(paintingCollection);
- m_paintSwapLock.unlock();
-
- if (!paintingCollection)
- return;
-
- paintingCollection->drawCanvas(canvas, drawLayers);
-
- SkSafeUnref(paintingCollection);
-}
-
-// TODO: refactor this functionality elsewhere
-int SurfaceCollectionManager::baseContentWidth()
-{
- if (m_paintingCollection)
- return m_paintingCollection->baseContentWidth();
- else if (m_drawingCollection)
- return m_drawingCollection->baseContentWidth();
- return 0;
-}
-
-int SurfaceCollectionManager::baseContentHeight()
-{
- if (m_paintingCollection)
- return m_paintingCollection->baseContentHeight();
- else if (m_drawingCollection)
- return m_drawingCollection->baseContentHeight();
- return 0;
-}
-
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h
index 76e5e9e..304d57f 100644
--- a/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h
+++ b/Source/WebCore/platform/graphics/android/SurfaceCollectionManager.h
@@ -54,11 +54,6 @@ public:
bool enterFastSwapMode, bool* collectionsSwappedPtr, bool* newCollectionHasAnimPtr,
TexturesResult* texturesResultPtr);
- void drawCanvas(SkCanvas* canvas, bool drawLayers);
-
- int baseContentWidth();
- int baseContentHeight();
-
private:
void swap();
void clearCollections();
diff --git a/Source/WebCore/platform/graphics/android/TextureOwner.h b/Source/WebCore/platform/graphics/android/TextureOwner.h
index 5434dbf..4f9e6ef 100644
--- a/Source/WebCore/platform/graphics/android/TextureOwner.h
+++ b/Source/WebCore/platform/graphics/android/TextureOwner.h
@@ -31,7 +31,6 @@ class Layer;
namespace WebCore {
-class TiledPage;
class BaseTileTexture;
class GLWebViewState;
@@ -39,8 +38,6 @@ class TextureOwner {
public:
virtual ~TextureOwner() { }
virtual bool removeTexture(BaseTileTexture* texture) = 0;
- virtual TiledPage* page() = 0;
- virtual GLWebViewState* state() = 0;
virtual bool samePageAs(Layer* root) { return false; }
virtual bool isRepaintPending() = 0;
virtual unsigned long long drawCount() = 0;
diff --git a/Source/WebCore/platform/graphics/android/TexturesGenerator.cpp b/Source/WebCore/platform/graphics/android/TexturesGenerator.cpp
index 81a404f..83e04dc 100644
--- a/Source/WebCore/platform/graphics/android/TexturesGenerator.cpp
+++ b/Source/WebCore/platform/graphics/android/TexturesGenerator.cpp
@@ -47,21 +47,6 @@ void TexturesGenerator::scheduleOperation(QueuedOperation* operation)
mRequestedOperationsCond.signal();
}
-void TexturesGenerator::removeOperationsForPage(TiledPage* page)
-{
- removeOperationsForFilter(new PageFilter(page));
-}
-
-void TexturesGenerator::removePaintOperationsForPage(TiledPage* page, bool waitForRunning)
-{
- removeOperationsForFilter(new PageFilter(page), waitForRunning);
-}
-
-void TexturesGenerator::removeOperationsForFilter(OperationFilter* filter)
-{
- removeOperationsForFilter(filter, true);
-}
-
void TexturesGenerator::removeOperationsForFilter(OperationFilter* filter, bool waitForRunning)
{
if (!filter)
diff --git a/Source/WebCore/platform/graphics/android/TexturesGenerator.h b/Source/WebCore/platform/graphics/android/TexturesGenerator.h
index 2e3b6b4..b79baa7 100644
--- a/Source/WebCore/platform/graphics/android/TexturesGenerator.h
+++ b/Source/WebCore/platform/graphics/android/TexturesGenerator.h
@@ -29,17 +29,15 @@
#if USE(ACCELERATED_COMPOSITING)
#include "QueuedOperation.h"
-#include "TiledPage.h"
#include "TilePainter.h"
+#include "Vector.h"
+
#include <utils/threads.h>
namespace WebCore {
using namespace android;
-class BaseLayerAndroid;
-class LayerAndroid;
-
class TexturesGenerator : public Thread {
public:
TexturesGenerator() : Thread(false)
@@ -48,10 +46,7 @@ public:
virtual ~TexturesGenerator() { }
virtual status_t readyToRun();
- void removeOperationsForPage(TiledPage* page);
- void removePaintOperationsForPage(TiledPage* page, bool waitForRunning);
- void removeOperationsForFilter(OperationFilter* filter);
- void removeOperationsForFilter(OperationFilter* filter, bool waitForRunning);
+ void removeOperationsForFilter(OperationFilter* filter, bool waitForRunning = true);
void scheduleOperation(QueuedOperation* operation);
diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp
deleted file mode 100644
index afa2014..0000000
--- a/Source/WebCore/platform/graphics/android/TiledPage.cpp
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define LOG_TAG "TiledPage"
-#define LOG_NDEBUG 1
-
-#include "config.h"
-#include "TiledPage.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "AndroidLog.h"
-#include "GLUtils.h"
-#include "IntRect.h"
-#include "PaintTileOperation.h"
-#include "SkPaint.h"
-#include "SkPaintFlagsDrawFilter.h"
-#include "TilesManager.h"
-
-namespace WebCore {
-
-using namespace android;
-
-TiledPage::TiledPage(int id, GLWebViewState* state)
- : m_baseTiles(0)
- , m_baseTileSize(0)
- , m_id(id)
- , m_scale(1)
- , m_invScale(1)
- , m_glWebViewState(state)
- , m_prepare(false)
- , m_isPrefetchPage(false)
- , m_willDraw(false)
-{
- m_baseTiles = new BaseTile[TilesManager::getMaxTextureAllocation() + 1];
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->increment("TiledPage");
-#endif
-}
-
-void TiledPage::updateBaseTileSize()
-{
- // This value must be at least 1 greater than the max number of allowed
- // textures. This is because prepare() asks for a tile before it reserves
- // a texture for that tile. If all textures are currently in use by the
- // page then there will be no available tile and having the extra tile
- // ensures that this does not happen. After claiming the extra tile the call
- // to reserveTexture() will cause some other tile in the page to lose it's
- // texture and become available, thus ensuring that we always have at least
- // one tile that is available.
- int baseTileSize = TilesManager::instance()->maxTextureCount() + 1;
- if (baseTileSize > m_baseTileSize)
- m_baseTileSize = baseTileSize;
-}
-
-TiledPage::~TiledPage()
-{
- TilesManager* tilesManager = TilesManager::instance();
- // In order to delete the page we must ensure that none of its BaseTiles are
- // currently painting or scheduled to be painted by the TextureGenerator
- tilesManager->removeOperationsForPage(this);
- // Discard the transfer queue after the removal operation to make sure
- // no tiles for this page will be left in the transfer queue.
- tilesManager->transferQueue()->setPendingDiscardWithLock();
- delete[] m_baseTiles;
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->decrement("TiledPage");
-#endif
-}
-
-BaseTile* TiledPage::getBaseTile(int x, int y) const
-{
- // TODO: replace loop over array with HashMap indexing
- for (int j = 0; j < m_baseTileSize; j++) {
- BaseTile& tile = m_baseTiles[j];
- if (tile.x() == x && tile.y() == y)
- return &tile;
- }
- return 0;
-}
-
-void TiledPage::discardTextures()
-{
- for (int j = 0; j < m_baseTileSize; j++) {
- BaseTile& tile = m_baseTiles[j];
- tile.discardTextures();
- }
- return;
-}
-
-void TiledPage::invalidateRect(const IntRect& inval)
-{
-#ifdef DEBUG
- // Given the current scale level we need to mark the appropriate tiles as dirty
- const float invTileContentWidth = m_scale / TilesManager::tileWidth();
- const float invTileContentHeight = m_scale / TilesManager::tileHeight();
-
- const int firstDirtyTileX = static_cast<int>(floorf(inval.x() * invTileContentWidth));
- const int firstDirtyTileY = static_cast<int>(floorf(inval.y() * invTileContentHeight));
- const int lastDirtyTileX = static_cast<int>(ceilf(inval.maxX() * invTileContentWidth));
- const int lastDirtyTileY = static_cast<int>(ceilf(inval.maxY() * invTileContentHeight));
-
- ALOGV("Marking X %d-%d and Y %d-%d dirty",
- firstDirtyTileX, lastDirtyTileX, firstDirtyTileY, lastDirtyTileY);
-#endif
- // We defer marking the tile as dirty until the next time we need to prepare
- // to draw.
- m_invalRegion.op(inval.x(), inval.y(), inval.maxX(), inval.maxY(), SkRegion::kUnion_Op);
-}
-
-void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y, const SkIRect& tileBounds)
-{
- for (int i = 0; i < tilesInRow; i++) {
- int x = firstTileX;
-
- // If we are goingLeft, we want to schedule the tiles starting from the
- // right (and to the left if not). This is because tiles are appended to
- // the list and the texture uploader goes through the set front to back.
- if (goingLeft)
- x += (tilesInRow - 1) - i;
- else
- x += i;
-
- BaseTile* currentTile = 0;
- BaseTile* availableTile = 0;
- for (int j = 0; j < m_baseTileSize; j++) {
- BaseTile& tile = m_baseTiles[j];
- if (tile.x() == x && tile.y() == y) {
- currentTile = &tile;
- break;
- }
-
- if (!availableTile || (tile.drawCount() < availableTile->drawCount()))
- availableTile = &tile;
- }
-
- if (!currentTile && availableTile) {
- ALOGV("STEALING tile %d, %d (draw count %llu) for tile %d, %d",
- availableTile->x(), availableTile->y(), availableTile->drawCount(), x, y);
- availableTile->discardTextures(); // don't wait for textures to be stolen
- currentTile = availableTile;
- }
-
- if (!currentTile) {
- ALOGV("ERROR: No tile available for tile %d %d", x, y);
- }
-
- if (currentTile) {
- currentTile->setGLWebViewState(m_glWebViewState);
- currentTile->setPage(this);
-
- currentTile->setContents(x, y, m_scale);
-
- // TODO: move below (which is largely the same for layers / tiled
- // page) into prepare() function
-
- // ensure there is a texture associated with the tile and then check to
- // see if the texture is dirty and in need of repainting
- if (currentTile->isDirty() || !currentTile->frontTexture())
- currentTile->reserveTexture();
- if (currentTile->backTexture()
- && currentTile->isDirty()
- && !currentTile->isRepaintPending()) {
- PaintTileOperation *operation = new PaintTileOperation(currentTile, this);
- TilesManager::instance()->scheduleOperation(operation);
- }
- }
- }
-}
-
-void TiledPage::updateTileDirtiness()
-{
- if (!m_glWebViewState || m_invalRegion.isEmpty())
- return;
-
- for (int x = 0; x < m_baseTileSize; x++)
- m_baseTiles[x].markAsDirty(m_invalRegion);
-
- // clear the invalidated region as all tiles within that region have now
- // been marked as dirty.
- m_invalRegion.setEmpty();
-}
-
-void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBounds, PrepareBounds bounds)
-{
- if (!m_glWebViewState)
- return;
-
- TilesManager::instance()->gatherTextures();
- m_scrollingDown = goingDown;
-
- int firstTileX = tileBounds.fLeft;
- int firstTileY = tileBounds.fTop;
- int nbTilesWidth = tileBounds.width();
- int nbTilesHeight = tileBounds.height();
-
- if (bounds == ExpandedBounds) {
- // prepare tiles outside of the visible bounds
- int expandX = m_glWebViewState->expandedTileBoundsX();
- int expandY = m_glWebViewState->expandedTileBoundsY();
-
- firstTileX -= expandX;
- nbTilesWidth += expandX * 2;
-
- firstTileY -= expandY;
- nbTilesHeight += expandY * 2;
- }
-
- // crop the tile bounds in each dimension to the larger of the base layer or viewport
- float maxBaseX = m_glWebViewState->baseContentWidth() * m_scale / TilesManager::tileWidth();
- float maxBaseY = m_glWebViewState->baseContentHeight() * m_scale / TilesManager::tileHeight();
- int maxX = std::max(static_cast<int>(ceilf(maxBaseX)),
- m_glWebViewState->viewportTileBounds().width());
- int maxY = std::max(static_cast<int>(ceilf(maxBaseY)),
- m_glWebViewState->viewportTileBounds().height());
-
- // adjust perimeter to not go outside cropped region
- if (firstTileX < 0) {
- nbTilesWidth += firstTileX;
- firstTileX = 0;
- }
- if (firstTileY < 0) {
- nbTilesHeight += firstTileY;
- firstTileY = 0;
- }
- nbTilesWidth = std::min(nbTilesWidth, maxX - firstTileX + 1);
- nbTilesHeight = std::min(nbTilesHeight, maxY - firstTileY + 1);
-
- // check against corrupted scale values giving bad height/width (use float to avoid overflow)
- float numTiles = static_cast<float>(nbTilesHeight) * static_cast<float>(nbTilesWidth);
- if (numTiles > TilesManager::getMaxTextureAllocation() || nbTilesHeight < 1 || nbTilesWidth < 1)
- {
- ALOGE("ERROR: We don't have enough tiles for this page!"
- " nbTilesHeight %d nbTilesWidth %d", nbTilesHeight, nbTilesWidth);
- return;
- }
- for (int i = 0; i < nbTilesHeight; i++)
- prepareRow(goingLeft, nbTilesWidth, firstTileX, firstTileY + i, tileBounds);
-
- m_prepare = true;
-}
-
-bool TiledPage::hasMissingContent(const SkIRect& tileBounds)
-{
- int neededTiles = tileBounds.width() * tileBounds.height();
- for (int j = 0; j < m_baseTileSize; j++) {
- BaseTile& tile = m_baseTiles[j];
- if (tileBounds.contains(tile.x(), tile.y())) {
- if (tile.frontTexture())
- neededTiles--;
- }
- }
- return neededTiles > 0;
-}
-
-bool TiledPage::isReady(const SkIRect& tileBounds)
-{
- int neededTiles = tileBounds.width() * tileBounds.height();
- ALOGV("tiled page %p needs %d ready tiles", this, neededTiles);
- for (int j = 0; j < m_baseTileSize; j++) {
- BaseTile& tile = m_baseTiles[j];
- if (tileBounds.contains(tile.x(), tile.y())) {
- if (tile.isTileReady())
- neededTiles--;
- }
- }
- ALOGV("tiled page %p still needs %d ready tiles", this, neededTiles);
- return neededTiles == 0;
-}
-
-bool TiledPage::swapBuffersIfReady(const SkIRect& tileBounds, float scale)
-{
- if (!m_glWebViewState)
- return false;
-
- if (!m_invalRegion.isEmpty() && !m_prepare)
- return false;
-
- if (m_scale != scale)
- return false;
-
- int swaps = 0;
- bool fullSwap = true;
- for (int x = tileBounds.fLeft; x < tileBounds.fRight; x++) {
- for (int y = tileBounds.fTop; y < tileBounds.fBottom; y++) {
- BaseTile* t = getBaseTile(x, y);
- if (!t || !t->isTileReady())
- fullSwap = false;
- }
- }
-
- // swap every tile on page (even if off screen)
- for (int j = 0; j < m_baseTileSize; j++) {
- BaseTile& tile = m_baseTiles[j];
- if (tile.swapTexturesIfNeeded())
- swaps++;
- }
-
- ALOGV("%p greedy swapped %d textures, returning %d", this, swaps, fullSwap);
- return fullSwap;
-}
-
-void TiledPage::prepareForDrawGL(float opacity, const SkIRect& tileBounds)
-{
- m_willDraw = true;
- m_opacity = opacity;
- m_tileBounds = tileBounds;
-}
-
-void TiledPage::drawGL()
-{
- if (!m_glWebViewState || m_opacity == 0 || !m_willDraw)
- return;
-
- const float tileWidth = TilesManager::tileWidth() * m_invScale;
- const float tileHeight = TilesManager::tileHeight() * m_invScale;
-
- for (int j = 0; j < m_baseTileSize; j++) {
- BaseTile& tile = m_baseTiles[j];
- bool tileInView = m_tileBounds.contains(tile.x(), tile.y());
- if (tileInView) {
- SkRect rect;
- rect.fLeft = tile.x() * tileWidth;
- rect.fTop = tile.y() * tileHeight;
- rect.fRight = rect.fLeft + tileWidth;
- rect.fBottom = rect.fTop + tileHeight;
-
- tile.drawGL(m_opacity, rect, m_scale, 0);
- }
-
- TilesManager::instance()->getProfiler()->nextTile(tile, m_invScale, tileInView);
- }
- m_willDraw = false; // don't redraw until re-prepared
-}
-
-bool TiledPage::paint(BaseTile* tile, SkCanvas* canvas)
-{
- static SkPaintFlagsDrawFilter prefetchFilter(SkPaint::kAllFlags,
- SkPaint::kAntiAlias_Flag);
-
- if (!m_glWebViewState)
- return false;
-
- if (isPrefetchPage())
- canvas->setDrawFilter(&prefetchFilter);
-
- m_glWebViewState->paintBaseLayerContent(canvas);
- return true;
-}
-
-TiledPage* TiledPage::sibling()
-{
- if (!m_glWebViewState)
- return 0;
- return m_glWebViewState->sibling(this);
-}
-
-} // namespace WebCore
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/android/TiledPage.h b/Source/WebCore/platform/graphics/android/TiledPage.h
deleted file mode 100644
index 5587618..0000000
--- a/Source/WebCore/platform/graphics/android/TiledPage.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TiledPage_h
-#define TiledPage_h
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "BaseTile.h"
-#include "SkCanvas.h"
-#include "SkRegion.h"
-
-#include "TilePainter.h"
-
-namespace WebCore {
-
-class GLWebViewState;
-class IntRect;
-
-/**
- * The TiledPage represents a map of BaseTiles covering the viewport. Each
- * GLWebViewState contains two TiledPages, one to display the page at the
- * current scale factor, and another in the background that we use to paint the
- * page at a different scale factor. For instance, when we zoom using one
- * TiledPage its tiles are scaled in hardware and therefore are subject to a
- * loss of quality. To address this when the user finishes zooming we paint the
- * background TilePage at the new scale factor. When the background TilePage is
- * ready, we swap it with the currently displaying TiledPage.
- */
-class TiledPage : public TilePainter {
-public:
- enum PrepareBounds {
- ExpandedBounds = 0,
- VisibleBounds = 1
- };
-
- TiledPage(int id, GLWebViewState* state);
- ~TiledPage();
-
- // returns the other TiledPage who shares the same GLWebViewState
- TiledPage* sibling();
-
- // prepare the page for display on the screen
- void prepare(bool goingDown, bool goingLeft, const SkIRect& tileBounds, PrepareBounds bounds);
-
- // update tiles with inval information
- void updateTileDirtiness();
-
- // returns true if the page can't draw the entire region (may still be stale)
- bool hasMissingContent(const SkIRect& tileBounds);
-
- bool isReady(const SkIRect& tileBounds);
-
- // swap 'buffers' by swapping each modified texture
- bool swapBuffersIfReady(const SkIRect& tileBounds, float scale);
- // save the opacity and bounds to be drawn in drawGL()
- void prepareForDrawGL(float opacity, const SkIRect& tileBounds);
- // draw the page on the screen
- void drawGL();
-
- // TilePainter implementation
- // used by individual tiles to generate the bitmap for their tile
- bool paint(BaseTile* tile, SkCanvas* canvas);
-
- // used by individual tiles to get the information about the current picture
- GLWebViewState* glWebViewState() { return m_glWebViewState; }
-
- float scale() const { return m_scale; }
-
- //TODO: clear all textures if this is called with a new value
- void setScale(float scale) { m_scale = scale; m_invScale = 1 / scale; }
-
- void invalidateRect(const IntRect& invalRect);
- void discardTextures();
- void updateBaseTileSize();
- bool scrollingDown() { return m_scrollingDown; }
- bool isPrefetchPage() { return m_isPrefetchPage; }
- void setIsPrefetchPage(bool isPrefetch) { m_isPrefetchPage = isPrefetch; }
-
-private:
- void prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y, const SkIRect& tileBounds);
-
- BaseTile* getBaseTile(int x, int y) const;
-
- // array of tiles used to compose a page. The tiles are allocated in the
- // constructor to prevent them from potentially being allocated on the stack
- BaseTile* m_baseTiles;
- // stores the number of tiles in the m_baseTiles array. This enables us to
- // quickly iterate over the array without have to check it's size
- int m_baseTileSize;
- int m_id;
- float m_scale;
- float m_invScale;
- GLWebViewState* m_glWebViewState;
-
-
- SkRegion m_invalRegion; // in content coordinates
- bool m_prepare;
- bool m_scrollingDown;
- bool m_isPrefetchPage;
-
- // info saved in prepare, used in drawGL()
- bool m_willDraw;
- SkIRect m_tileBounds;
- float m_opacity;
-};
-
-} // namespace WebCore
-
-#endif // USE(ACCELERATED_COMPOSITING)
-#endif // TiledPage_h
diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.cpp b/Source/WebCore/platform/graphics/android/TiledTexture.cpp
index 039e28c..51e9b35 100644
--- a/Source/WebCore/platform/graphics/android/TiledTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/TiledTexture.cpp
@@ -130,7 +130,7 @@ void TiledTexture::prepareGL(GLWebViewState* state, float scale,
m_prevTileY = m_area.y();
if (scale != m_scale)
- TilesManager::instance()->removeOperationsForFilter(new ScaleFilter(painter, scale));
+ TilesManager::instance()->removeOperationsForFilter(new ScaleFilter(painter, m_scale));
m_scale = scale;
@@ -138,16 +138,26 @@ void TiledTexture::prepareGL(GLWebViewState* state, float scale,
if (!m_dirtyRegion.isEmpty()) {
for (unsigned int i = 0; i < m_tiles.size(); i++)
m_tiles[i]->markAsDirty(m_dirtyRegion);
+
+ // log inval region for the base surface
+ if (m_isBaseSurface && TilesManager::instance()->getProfiler()->enabled()) {
+ SkRegion::Iterator iterator(m_dirtyRegion);
+ while (!iterator.done()) {
+ SkIRect r = iterator.rect();
+ TilesManager::instance()->getProfiler()->nextInval(r, scale);
+ iterator.next();
+ }
+ }
m_dirtyRegion.setEmpty();
}
for (int i = 0; i < m_area.width(); i++) {
if (goingDown) {
for (int j = 0; j < m_area.height(); j++)
- prepareTile(m_area.x() + i, m_area.y() + j, painter);
+ prepareTile(m_area.x() + i, m_area.y() + j, painter, state);
} else {
for (int j = m_area.height() - 1; j >= 0; j--)
- prepareTile(m_area.x() + i, m_area.y() + j, painter);
+ prepareTile(m_area.x() + i, m_area.y() + j, painter, state);
}
}
}
@@ -159,11 +169,12 @@ void TiledTexture::markAsDirty(const SkRegion& invalRegion)
m_dirtyRegion.op(invalRegion, SkRegion::kUnion_Op);
}
-void TiledTexture::prepareTile(int x, int y, TilePainter* painter)
+void TiledTexture::prepareTile(int x, int y, TilePainter* painter, GLWebViewState* state)
{
BaseTile* tile = getTile(x, y);
if (!tile) {
- tile = new BaseTile(true);
+ bool isLayerTile = !m_isBaseSurface;
+ tile = new BaseTile(isLayerTile);
m_tiles.append(tile);
}
@@ -178,7 +189,7 @@ void TiledTexture::prepareTile(int x, int y, TilePainter* painter)
if (tile->backTexture() && tile->isDirty() && !tile->isRepaintPending()) {
ALOGV("painting TT %p's tile %d %d for LG %p", this, x, y, painter);
- PaintTileOperation *operation = new PaintTileOperation(tile, painter);
+ PaintTileOperation *operation = new PaintTileOperation(tile, painter, state);
TilesManager::instance()->scheduleOperation(operation);
}
}
@@ -226,7 +237,8 @@ bool TiledTexture::drawGL(const IntRect& visibleArea, float opacity,
for (unsigned int i = 0; i < m_tiles.size(); i++) {
BaseTile* tile = m_tiles[i];
- if (tile->isTileVisible(m_area)) {
+ bool tileInView = tile->isTileVisible(m_area);
+ if (tileInView) {
askRedraw |= !tile->isTileReady();
SkRect rect;
rect.fLeft = tile->x() * tileWidth;
@@ -240,6 +252,9 @@ bool TiledTexture::drawGL(const IntRect& visibleArea, float opacity,
if (tile->frontTexture())
drawn++;
}
+
+ if (m_isBaseSurface)
+ TilesManager::instance()->getProfiler()->nextTile(tile, m_invScale, tileInView);
}
ALOGV("TT %p drew %d tiles, redraw due to notready %d, scale %f",
this, drawn, askRedraw, m_scale);
@@ -275,10 +290,10 @@ bool TiledTexture::owns(BaseTileTexture* texture)
return false;
}
-DualTiledTexture::DualTiledTexture()
+DualTiledTexture::DualTiledTexture(bool isBaseSurface)
{
- m_textureA = new TiledTexture();
- m_textureB = new TiledTexture();
+ m_textureA = new TiledTexture(isBaseSurface);
+ m_textureB = new TiledTexture(isBaseSurface);
m_frontTexture = m_textureA;
m_backTexture = m_textureB;
m_scale = -1;
@@ -319,7 +334,7 @@ void DualTiledTexture::prepareGL(GLWebViewState* state, bool allowZoom,
this, scale, m_scale, m_futureScale, m_zooming,
m_frontTexture, m_backTexture);
- if (m_scale > 0)
+ if (m_scale > 0 && !m_zooming)
m_frontTexture->prepareGL(state, m_scale, m_preZoomPrepareArea, painter);
// If we had a scheduled update
diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.h b/Source/WebCore/platform/graphics/android/TiledTexture.h
index cf7c77c..b879d54 100644
--- a/Source/WebCore/platform/graphics/android/TiledTexture.h
+++ b/Source/WebCore/platform/graphics/android/TiledTexture.h
@@ -42,11 +42,11 @@ namespace WebCore {
class TiledTexture {
public:
- TiledTexture()
+ TiledTexture(bool isBaseSurface)
: m_prevTileX(0)
, m_prevTileY(0)
, m_scale(1)
- , m_swapWhateverIsReady(false)
+ , m_isBaseSurface(isBaseSurface)
{
m_dirtyRegion.setEmpty();
#ifdef DEBUG_COUNT
@@ -63,7 +63,7 @@ public:
void swapTiles();
bool drawGL(const IntRect& visibleArea, float opacity, const TransformationMatrix* transform);
- void prepareTile(int x, int y, TilePainter* painter);
+ void prepareTile(int x, int y, TilePainter* painter, GLWebViewState* state);
void markAsDirty(const SkRegion& dirtyArea);
BaseTile* getTile(int x, int y);
@@ -91,13 +91,13 @@ private:
int m_prevTileY;
float m_scale;
- bool m_swapWhateverIsReady;
+ bool m_isBaseSurface;
};
class DualTiledTexture : public SkRefCnt {
// TODO: investigate webkit threadsafe ref counting
public:
- DualTiledTexture();
+ DualTiledTexture(bool isBaseSurface);
~DualTiledTexture();
void prepareGL(GLWebViewState* state, bool allowZoom,
const IntRect& prepareArea, TilePainter* painter);
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 5112e5b..e6577c6 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -249,11 +249,6 @@ void TilesManager::gatherTextures()
{
android::Mutex::Autolock lock(m_texturesLock);
m_availableTextures = m_textures;
-}
-
-void TilesManager::gatherLayerTextures()
-{
- android::Mutex::Autolock lock(m_texturesLock);
m_availableTilesTextures = m_tilesTextures;
m_layerTexturesRemain = true;
}
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index 01d2b3e..0640825 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -35,7 +35,6 @@
#include "ShaderProgram.h"
#include "SkBitmapRef.h"
#include "TexturesGenerator.h"
-#include "TiledPage.h"
#include "TilesProfiler.h"
#include "TransferQueue.h"
#include "VideoLayerManager.h"
@@ -60,16 +59,6 @@ public:
m_pixmapsGenerationThread->removeOperationsForFilter(filter, waitForRunning);
}
- void removeOperationsForPage(TiledPage* page)
- {
- m_pixmapsGenerationThread->removeOperationsForPage(page);
- }
-
- void removePaintOperationsForPage(TiledPage* page, bool waitForCompletion)
- {
- m_pixmapsGenerationThread->removePaintOperationsForPage(page, waitForCompletion);
- }
-
void scheduleOperation(QueuedOperation* operation)
{
m_pixmapsGenerationThread->scheduleOperation(operation);
@@ -79,7 +68,6 @@ public:
TransferQueue* transferQueue();
VideoLayerManager* videoLayerManager() { return &m_videoLayerManager; }
- void gatherLayerTextures();
void gatherTextures();
bool layerTexturesRemain() { return m_layerTexturesRemain; }
void gatherTexturesNumbers(int* nbTextures, int* nbAllocatedTextures,
@@ -98,8 +86,6 @@ public:
void printTextures();
- void resetTextureUsage(TiledPage* page);
-
// m_highEndGfx is written/read only on UI thread, no need for a lock.
void setHighEndGfx(bool highEnd);
bool highEndGfx();
diff --git a/Source/WebCore/platform/graphics/android/TilesProfiler.cpp b/Source/WebCore/platform/graphics/android/TilesProfiler.cpp
index a113514..2cc6873 100644
--- a/Source/WebCore/platform/graphics/android/TilesProfiler.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesProfiler.cpp
@@ -92,14 +92,14 @@ void TilesProfiler::nextFrame(int left, int top, int right, int bottom, float sc
scale, true, (int)(timeDelta * 1000)));
}
-void TilesProfiler::nextTile(BaseTile& tile, float scale, bool inView)
+void TilesProfiler::nextTile(BaseTile* tile, float scale, bool inView)
{
if (!m_enabled || (m_records.size() > MAX_PROF_FRAMES) || (m_records.size() == 0))
return;
- bool isReady = tile.isTileReady();
- int left = tile.x() * TilesManager::tileWidth();
- int top = tile.y() * TilesManager::tileWidth();
+ bool isReady = tile->isTileReady();
+ int left = tile->x() * TilesManager::tileWidth();
+ int top = tile->y() * TilesManager::tileWidth();
int right = left + TilesManager::tileWidth();
int bottom = top + TilesManager::tileWidth();
@@ -111,20 +111,20 @@ void TilesProfiler::nextTile(BaseTile& tile, float scale, bool inView)
}
m_records.last().append(TileProfileRecord(
left, top, right, bottom,
- scale, isReady, (int)tile.drawCount()));
+ scale, isReady, (int)tile->drawCount()));
ALOGV("adding tile %d %d %d %d, scale %f", left, top, right, bottom, scale);
}
-void TilesProfiler::nextInval(const IntRect& rect, float scale)
+void TilesProfiler::nextInval(const SkIRect& rect, float scale)
{
if (!m_enabled || (m_records.size() > MAX_PROF_FRAMES) || (m_records.size() == 0))
return;
m_records.last().append(TileProfileRecord(
rect.x(), rect.y(),
- rect.maxX(), rect.maxY(), scale, false, INVAL_CODE));
+ rect.right(), rect.bottom(), scale, false, INVAL_CODE));
ALOGV("adding inval region %d %d %d %d, scale %f", rect.x(), rect.y(),
- rect.maxX(), rect.maxY(), scale);
+ rect.right(), rect.bottom(), scale);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TilesProfiler.h b/Source/WebCore/platform/graphics/android/TilesProfiler.h
index 286d350..a13d471 100644
--- a/Source/WebCore/platform/graphics/android/TilesProfiler.h
+++ b/Source/WebCore/platform/graphics/android/TilesProfiler.h
@@ -58,8 +58,8 @@ public:
float stop();
void clear();
void nextFrame(int left, int top, int right, int bottom, float scale);
- void nextTile(BaseTile& tile, float scale, bool inView);
- void nextInval(const IntRect& rect, float scale);
+ void nextTile(BaseTile* tile, float scale, bool inView);
+ void nextInval(const SkIRect& rect, float scale);
int numFrames() {
return m_records.size();
};
@@ -72,6 +72,8 @@ public:
return &m_records[frame][tile];
}
+ bool enabled() { return m_enabled; }
+
private:
bool m_enabled;
unsigned int m_goodTiles;
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.h b/Source/WebCore/platform/graphics/android/TransferQueue.h
index 8bc5c19..b00ea17 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.h
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.h
@@ -31,7 +31,6 @@
#include "BaseTile.h"
#include "BaseTileTexture.h"
#include "ShaderProgram.h"
-#include "TiledPage.h"
#include <EGL/eglext.h>
namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/android/ZoomManager.cpp b/Source/WebCore/platform/graphics/android/ZoomManager.cpp
deleted file mode 100644
index 35100ae..0000000
--- a/Source/WebCore/platform/graphics/android/ZoomManager.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright 2011, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define LOG_TAG "ZoomManager"
-#define LOG_NDEBUG 1
-
-#include "config.h"
-#include "ZoomManager.h"
-
-#include "AndroidLog.h"
-#include "GLWebViewState.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-namespace WebCore {
-
-using namespace android;
-
-ZoomManager::ZoomManager(GLWebViewState* state)
- : m_scaleRequestState(kNoScaleRequest)
- , m_currentScale(-1)
- , m_futureScale(-1)
- , m_layersScale(-1)
- , m_updateTime(-1)
- , m_transitionTime(-1)
- , m_glWebViewState(state)
-{
-}
-
-void ZoomManager::scheduleUpdate(const double& currentTime,
- const SkIRect& viewport, float scale)
-{
- // if no update time, set it
- if (updateTime() == -1) {
- m_scaleRequestState = kWillScheduleRequest;
- setUpdateTime(currentTime + s_updateInitialDelay);
- setFutureScale(scale);
- m_glWebViewState->setFutureViewport(viewport);
- return;
- }
-
- if (currentTime < updateTime())
- return;
-
- // we reached the scheduled update time, check if we can update
- if (futureScale() == scale) {
- // we are still with the previous scale, let's go
- // with the update
- m_scaleRequestState = kRequestNewScale;
- setUpdateTime(-1);
- } else {
- // we reached the update time, but the planned update was for
- // a different scale factor -- meaning the user is still probably
- // in the process of zooming. Let's push the update time a bit.
- setUpdateTime(currentTime + s_updateDelay);
- setFutureScale(scale);
- m_glWebViewState->setFutureViewport(viewport);
- }
-}
-
-double ZoomManager::zoomInTransitionTime(double currentTime)
-{
- if (m_transitionTime == -1)
- m_transitionTime = currentTime + s_zoomInTransitionDelay;
- return m_transitionTime;
-}
-
-double ZoomManager::zoomOutTransitionTime(double currentTime)
-{
- if (m_transitionTime == -1)
- m_transitionTime = currentTime + s_zoomOutTransitionDelay;
- return m_transitionTime;
-}
-
-float ZoomManager::zoomInTransparency(double currentTime)
-{
- float t = zoomInTransitionTime(currentTime) - currentTime;
- t *= s_invZoomInTransitionDelay;
- return fmin(1, fmax(0, t));
-}
-
-float ZoomManager::zoomOutTransparency(double currentTime)
-{
- float t = zoomOutTransitionTime(currentTime) - currentTime;
- t *= s_invZoomOutTransitionDelay;
- return fmin(1, fmax(0, t));
-}
-
-bool ZoomManager::swapPages()
-{
- bool reset = m_scaleRequestState != kNoScaleRequest;
- m_scaleRequestState = kNoScaleRequest;
- return reset;
-}
-
-void ZoomManager::processNewScale(double currentTime, float scale)
-{
- m_prepareNextTiledPage = false;
- m_zooming = false;
- const SkIRect& viewportTileBounds = m_glWebViewState->viewportTileBounds();
-
- if (scale == m_currentScale
- || m_glWebViewState->preZoomBounds().isEmpty())
- m_glWebViewState->setPreZoomBounds(viewportTileBounds);
-
- // If we have a different scale than the current one, we have to
- // decide what to do. The current behaviour is to delay an update,
- // so that we do not slow down zooming unnecessarily.
- if ((m_currentScale != scale
- && (m_scaleRequestState == ZoomManager::kNoScaleRequest
- || m_futureScale != scale))
- || m_scaleRequestState == ZoomManager::kWillScheduleRequest) {
-
- // schedule the new Zoom request
- scheduleUpdate(currentTime, viewportTileBounds, scale);
-
- // If it's a new request, we will have to prepare the page.
- if (m_scaleRequestState == ZoomManager::kRequestNewScale)
- m_prepareNextTiledPage = true;
- }
-
- // If the viewport has changed since we scheduled the request, we also need
- // to prepare.
- if ((m_scaleRequestState == ZoomManager::kRequestNewScale
- || m_scaleRequestState == ZoomManager::kReceivedNewScale)
- && m_glWebViewState->futureViewport() != viewportTileBounds)
- m_prepareNextTiledPage = true;
-
- // Checking if we are zooming...
- if (m_scaleRequestState != ZoomManager::kNoScaleRequest) {
- m_prepareNextTiledPage = true;
- m_zooming = true;
- }
-
- // Get the current scale; if we are zooming, we don't change the scale
- // factor immediately (see BaseLayerAndroid::drawBasePictureInGL()), but
- // we change the scaleRequestState. When the state is kReceivedNewScale
- // (see setReceivedRequest()), we can use the future scale instead of
- // the current scale to request new textures. After a transition time,
- // the scaleRequestState will be reset and the current scale will be set
- // to the future scale.
- m_layersScale = m_currentScale;
-}
-
-void ZoomManager::processTransition(double currentTime, float scale,
- bool* doSwap, float* backPageTransparency,
- float* frontPageTransparency)
-{
- if (scale < m_currentScale)
- *backPageTransparency = 1 - zoomOutTransparency(currentTime);
- else
- *frontPageTransparency = zoomInTransparency(currentTime);
-
- // The transition between the two page is finished
- if (currentTime > transitionTime(currentTime, scale)) {
- resetTransitionTime();
- *doSwap = true;
- }
-}
-
-} // namespace WebCore
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/android/ZoomManager.h b/Source/WebCore/platform/graphics/android/ZoomManager.h
deleted file mode 100644
index dd04c5d..0000000
--- a/Source/WebCore/platform/graphics/android/ZoomManager.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2011, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ZoomManager_h
-#define ZoomManager_h
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "SkRect.h"
-
-namespace WebCore {
-
-class GLWebViewState;
-
-class ZoomManager {
-public:
- enum GLScaleStates {
- kNoScaleRequest = 0,
- kWillScheduleRequest = 1,
- kRequestNewScale = 2,
- kReceivedNewScale = 3
- };
- typedef int32_t GLScaleState;
-
- ZoomManager(GLWebViewState* state);
-
- void scheduleUpdate(const double& currentTime, const SkIRect& viewport, float scale);
-
- GLScaleState scaleRequestState() const { return m_scaleRequestState; }
- void setScaleRequestState(GLScaleState state) { m_scaleRequestState = state; }
- float currentScale() const { return m_currentScale; }
- void setCurrentScale(float scale) { m_currentScale = scale; }
- float futureScale() const { return m_futureScale; }
- void setFutureScale(float scale) { m_futureScale = scale; }
- float layersScale() const { return m_layersScale; }
- double zoomInTransitionTime(double currentTime);
- double zoomOutTransitionTime(double currentTime);
- float zoomInTransparency(double currentTime);
- float zoomOutTransparency(double currentTime);
- void resetTransitionTime() { m_transitionTime = -1; }
- double updateTime() const { return m_updateTime; }
- void setUpdateTime(double value) { m_updateTime = value; }
-
- // state used by BaseLayerAndroid
- bool needPrepareNextTiledPage() { return m_prepareNextTiledPage; }
- bool zooming() { return m_zooming; }
-
- bool didFireRequest() { return m_scaleRequestState == ZoomManager::kRequestNewScale; }
- void setReceivedRequest() {
- m_scaleRequestState = ZoomManager::kReceivedNewScale;
- m_layersScale = m_futureScale;
- }
- bool didReceivedRequest() { return m_scaleRequestState == ZoomManager::kReceivedNewScale; }
-
- double transitionTime(double currentTime, float scale) {
- return (scale < m_currentScale) ? zoomOutTransitionTime(currentTime)
- : zoomInTransitionTime(currentTime);
- }
- void processTransition(double currentTime, float scale, bool* doSwap,
- float* backPageTransparency, float* frontPageTransparency);
-
- bool swapPages();
-
- void processNewScale(double currentTime, float scale);
-
-private:
- // Delay between scheduling a new page when the scale
- // factor changes (i.e. zooming in or out)
- static const double s_updateInitialDelay = 0.3; // 300 ms
- // If the scale factor continued to change and we completed
- // the original delay, we push back the update by this value
- static const double s_updateDelay = 0.1; // 100 ms
-
- // Delay for the transition between the two pages
- static const double s_zoomInTransitionDelay = 0.1; // 100 ms
- static const double s_invZoomInTransitionDelay = 10;
- static const double s_zoomOutTransitionDelay = 0.2; // 200 ms
- static const double s_invZoomOutTransitionDelay = 5;
-
- GLScaleState m_scaleRequestState;
- float m_currentScale;
- float m_futureScale;
- float m_layersScale;
- double m_updateTime;
- double m_transitionTime;
-
- bool m_prepareNextTiledPage;
- bool m_zooming;
-
- GLWebViewState* m_glWebViewState;
-};
-
-} // namespace WebCore
-
-#endif // USE(ACCELERATED_COMPOSITING)
-#endif // ZoomManager_h
diff --git a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
index fea45de..95ced96 100644
--- a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
+++ b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
@@ -611,14 +611,9 @@ static bool SendSurfaceTexture(JNIEnv* env, jobject obj, jobject surfTex,
BaseLayerAndroid* layerImpl = reinterpret_cast<BaseLayerAndroid*>(baseLayer);
if (!layerImpl)
return false;
- if (!layerImpl->countChildren())
- return false;
- LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(layerImpl->getChild(0));
- if (!compositedRoot)
- return false;
VideoLayerAndroid* videoLayer =
- static_cast<VideoLayerAndroid*>(compositedRoot->findById(videoLayerId));
+ static_cast<VideoLayerAndroid*>(layerImpl->findById(videoLayerId));
if (!videoLayer)
return false;
diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp
index 2be3ecb..bfce349 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -92,14 +92,13 @@ static BaseLayerAndroid* nativeDeserializeViewState(JNIEnv* env, jobject, jint v
SkStream* stream = CreateJavaInputStreamAdaptor(env, jstream, jstorage);
if (!stream)
return 0;
- BaseLayerAndroid* layer = new BaseLayerAndroid();
Color color = stream->readU32();
-#if USE(ACCELERATED_COMPOSITING)
- layer->setBackgroundColor(color);
-#endif
SkPicture* picture = new SkPicture(stream);
PictureLayerContent* content = new PictureLayerContent(picture);
- layer->setContent(content);
+
+ BaseLayerAndroid* layer = new BaseLayerAndroid(content);
+ layer->setBackgroundColor(color);
+
SkSafeUnref(content);
SkSafeUnref(picture);
int childCount = stream->readS32();
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index f323838..bb76c80 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -31,7 +31,6 @@
#include "AccessibilityObject.h"
#include "AndroidHitTestResult.h"
#include "Attribute.h"
-#include "BaseLayerAndroid.h"
#include "content/address_detector.h"
#include "Chrome.h"
#include "ChromeClientAndroid.h"
@@ -160,6 +159,8 @@ FILE* gDomTreeFile = 0;
FILE* gRenderTreeFile = 0;
#endif
+#include "BaseLayerAndroid.h"
+
#if USE(ACCELERATED_COMPOSITING)
#include "GraphicsLayerAndroid.h"
#include "RenderLayerCompositor.h"
@@ -861,10 +862,8 @@ void WebViewCore::notifyAnimationStarted()
BaseLayerAndroid* WebViewCore::createBaseLayer(SkRegion* region)
{
- BaseLayerAndroid* base = new BaseLayerAndroid();
-
PictureSetLayerContent* content = new PictureSetLayerContent(m_content);
- base->setContent(content);
+ BaseLayerAndroid* base = new BaseLayerAndroid(content);
SkSafeUnref(content);
m_skipContentDraw = true;
diff --git a/Source/WebKit/android/nav/DrawExtra.h b/Source/WebKit/android/nav/DrawExtra.h
index 83e7dcd..cc94476 100644
--- a/Source/WebKit/android/nav/DrawExtra.h
+++ b/Source/WebKit/android/nav/DrawExtra.h
@@ -54,7 +54,6 @@ namespace android {
class DrawExtra {
public:
virtual ~DrawExtra() {}
- virtual void drawLegacy(SkCanvas* , LayerAndroid* , IntRect* ) {}
virtual void draw(SkCanvas*, LayerAndroid*) {}
virtual void drawGL(GLExtras*, const LayerAndroid*) {}
};
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index 7d1ff75..ddb9bcb 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -37,6 +37,7 @@
#include "IntPoint.h"
#include "IntRect.h"
#include "LayerAndroid.h"
+#include "LayerContent.h"
#include "Node.h"
#include "utils/Functor.h"
#include "private/hwui/DrawGlInfo.h"
@@ -246,14 +247,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect,
if (!m_glWebViewState) {
TilesManager::instance()->setHighEndGfx(m_isHighEndGfx);
m_glWebViewState = new GLWebViewState();
- if (m_baseLayer->content()) {
- SkRegion region;
- SkIRect rect;
- rect.set(0, 0, m_baseLayer->content()->width(), m_baseLayer->content()->height());
- region.setRect(rect);
- m_baseLayer->markAsDirty(region);
- m_glWebViewState->setBaseLayer(m_baseLayer, false, true);
- }
+ m_glWebViewState->setBaseLayer(m_baseLayer, false, true);
}
DrawExtra* extra = getDrawExtra((DrawExtras) extras);
@@ -295,37 +289,24 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, DrawExtras extras, bool spli
// draw the content of the base layer first
LayerContent* content = m_baseLayer->content();
-
int sc = canvas->save(SkCanvas::kClip_SaveFlag);
canvas->clipRect(SkRect::MakeLTRB(0, 0, content->width(),
content->height()), SkRegion::kDifference_Op);
canvas->drawColor(bgColor);
canvas->restoreToCount(sc);
- content->draw(canvas);
- DrawExtra* extra = getDrawExtra(extras);
- if (extra)
- extra->draw(canvas, 0);
+ // call this to be sure we've adjusted for any scrolling or animations
+ // before we actually draw
+ m_baseLayer->updateLayerPositions(m_visibleRect);
+ m_baseLayer->updatePositions();
+
+ // We have to set the canvas' matrix on the base layer
+ // (to have fixed layers work as intended)
+ SkAutoCanvasRestore restore(canvas, true);
+ m_baseLayer->setMatrix(canvas->getTotalMatrix());
+ canvas->resetMatrix();
+ m_baseLayer->draw(canvas, getDrawExtra(extras));
-#if USE(ACCELERATED_COMPOSITING)
- LayerAndroid* compositeLayer = compositeRoot();
- if (compositeLayer) {
- // call this to be sure we've adjusted for any scrolling or animations
- // before we actually draw
- compositeLayer->updateLayerPositions(m_visibleRect);
- compositeLayer->updatePositions();
- // We have to set the canvas' matrix on the base layer
- // (to have fixed layers work as intended)
- SkAutoCanvasRestore restore(canvas, true);
- m_baseLayer->setMatrix(canvas->getTotalMatrix());
- canvas->resetMatrix();
- m_baseLayer->draw(canvas, extra);
- }
- if (extra) {
- IntRect dummy; // inval area, unused for now
- extra->drawLegacy(canvas, compositeLayer, &dummy);
- }
-#endif
return ret;
}
@@ -415,11 +396,9 @@ static const ScrollableLayerAndroid* findScrollableLayer(
int scrollableLayer(int x, int y, SkIRect* layerRect, SkIRect* bounds)
{
#if USE(ACCELERATED_COMPOSITING)
- const LayerAndroid* layerRoot = compositeRoot();
- if (!layerRoot)
+ if (!m_baseLayer)
return 0;
- const ScrollableLayerAndroid* result = findScrollableLayer(layerRoot, x, y,
- bounds);
+ const ScrollableLayerAndroid* result = findScrollableLayer(m_baseLayer, x, y, bounds);
if (result) {
result->getScrollRect(layerRect);
return result->uniqueId();
@@ -500,16 +479,6 @@ void postInvalidateDelayed(int64_t delay, const WebCore::IntRect& bounds)
checkException(env);
}
-LayerAndroid* compositeRoot() const
-{
- ALOG_ASSERT(!m_baseLayer || m_baseLayer->countChildren() == 1,
- "base layer can't have more than one child %s", __FUNCTION__);
- if (m_baseLayer && m_baseLayer->countChildren() == 1)
- return static_cast<LayerAndroid*>(m_baseLayer->getChild(0));
- else
- return 0;
-}
-
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
static void copyScrollPositionRecursive(const LayerAndroid* from,
LayerAndroid* root)
@@ -529,28 +498,30 @@ static void copyScrollPositionRecursive(const LayerAndroid* from,
}
#endif
-bool setBaseLayer(BaseLayerAndroid* layer, SkRegion& inval, bool showVisualIndicator,
+BaseLayerAndroid* getBaseLayer() const { return m_baseLayer; }
+
+bool setBaseLayer(BaseLayerAndroid* newBaseLayer, SkRegion& inval, bool showVisualIndicator,
bool isPictureAfterFirstLayout)
{
bool queueFull = false;
#if USE(ACCELERATED_COMPOSITING)
if (m_glWebViewState) {
- if (layer)
- layer->markAsDirty(inval);
- queueFull = m_glWebViewState->setBaseLayer(layer, showVisualIndicator,
+ // TODO: mark as inval on webkit side
+ if (newBaseLayer)
+ newBaseLayer->markAsDirty(inval);
+ queueFull = m_glWebViewState->setBaseLayer(newBaseLayer, showVisualIndicator,
isPictureAfterFirstLayout);
}
#endif
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
- if (layer) {
- // TODO: the below tree copies are only necessary in software rendering
- LayerAndroid* newCompositeRoot = static_cast<LayerAndroid*>(layer->getChild(0));
- copyScrollPositionRecursive(compositeRoot(), newCompositeRoot);
+ if (newBaseLayer) {
+ // TODO: the below tree position copies are only necessary in software rendering
+ copyScrollPositionRecursive(m_baseLayer, newBaseLayer);
}
#endif
SkSafeUnref(m_baseLayer);
- m_baseLayer = layer;
+ m_baseLayer = newBaseLayer;
return queueFull;
}
@@ -568,8 +539,8 @@ void copyBaseContentToPicture(SkPicture* picture)
if (!m_baseLayer)
return;
LayerContent* content = m_baseLayer->content();
- m_baseLayer->drawCanvas(picture->beginRecording(content->width(), content->height(),
- SkPicture::kUsePathBoundsForClip_RecordingFlag));
+ content->draw(picture->beginRecording(content->width(), content->height(),
+ SkPicture::kUsePathBoundsForClip_RecordingFlag));
picture->endRecording();
}
@@ -588,10 +559,6 @@ Functor* getFunctor() {
return m_glDrawFunctor;
}
-BaseLayerAndroid* getBaseLayer() {
- return m_baseLayer;
-}
-
void setVisibleRect(SkRect& visibleRect) {
m_visibleRect = visibleRect;
}
@@ -621,7 +588,7 @@ int getHandleLayerId(SelectText::HandleId handleId, SkIRect& cursorRect) {
// We need to make sure the drawTransform is up to date as this is
// called before a draw() or drawGL()
m_baseLayer->updateLayerPositions(m_visibleRect);
- LayerAndroid* root = compositeRoot();
+ LayerAndroid* root = m_baseLayer;
LayerAndroid* layer = root ? root->findById(layerId) : 0;
if (layer && layer->drawTransform()) {
const TransformationMatrix* transform = layer->drawTransform();
@@ -644,8 +611,7 @@ void mapLayerRect(int layerId, SkIRect& rect) {
// We need to make sure the drawTransform is up to date as this is
// called before a draw() or drawGL()
m_baseLayer->updateLayerPositions(m_visibleRect);
- LayerAndroid* root = compositeRoot();
- LayerAndroid* layer = root ? root->findById(layerId) : 0;
+ LayerAndroid* layer = m_baseLayer ? m_baseLayer->findById(layerId) : 0;
if (layer && layer->drawTransform())
rect = layer->drawTransform()->mapRect(rect);
}
@@ -656,7 +622,7 @@ void mapLayerRect(int layerId, SkIRect& rect) {
int setHwAccelerated(bool hwAccelerated) {
if (!m_glWebViewState)
return 0;
- LayerAndroid* root = compositeRoot();
+ LayerAndroid* root = m_baseLayer;
if (root)
return root->setHwAccelerated(hwAccelerated);
return 0;
@@ -844,10 +810,10 @@ static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint native
{
// only call in software rendering, initialize and evaluate animations
#if USE(ACCELERATED_COMPOSITING)
- LayerAndroid* root = ((WebView*)nativeView)->compositeRoot();
- if (root) {
- root->initAnimations();
- return root->evaluateAnimations();
+ BaseLayerAndroid* baseLayer = ((WebView*)nativeView)->getBaseLayer();
+ if (baseLayer) {
+ baseLayer->initAnimations();
+ return baseLayer->evaluateAnimations();
}
#endif
return false;
@@ -1089,11 +1055,11 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
fclose(file);
}
#if USE(ACCELERATED_COMPOSITING)
- const LayerAndroid* rootLayer = view->compositeRoot();
- if (rootLayer) {
+ const LayerAndroid* baseLayer = view->getBaseLayer();
+ if (baseLayer) {
FILE* file = fopen(LAYERS_TREE_LOG_FILE,"w");
if (file) {
- rootLayer->dumpLayers(file, 0);
+ baseLayer->dumpLayers(file, 0);
fclose(file);
}
}
@@ -1124,10 +1090,10 @@ static bool nativeScrollLayer(JNIEnv* env, jobject obj, jint layerId, jint x,
view->scrollLayer(layerId, x, y);
//TODO: the below only needed for the SW rendering path
- LayerAndroid* root = view->compositeRoot();
- if (!root)
+ LayerAndroid* baseLayer = view->getBaseLayer();
+ if (!baseLayer)
return false;
- LayerAndroid* layer = root->findById(layerId);
+ LayerAndroid* layer = baseLayer->findById(layerId);
if (!layer || !layer->contentIsScrollable())
return false;
return static_cast<ScrollableLayerAndroid*>(layer)->scrollTo(x, y);