summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp35
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ImageTexture.h1
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp37
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TransferQueue.h5
-rw-r--r--Source/WebKit/android/jni/PicturePile.cpp8
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp79
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h10
8 files changed, 135 insertions, 46 deletions
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index feb2d99..4a6bcbe 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -133,11 +133,13 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
m_replicatedLayerPosition = layer.m_replicatedLayerPosition;
+#ifdef ABSOLUTE_POSITION
// If we have absolute elements, we may need to reorder them if they
// are followed by another layer that is not also absolutely positioned.
// (as absolutely positioned elements are out of the normal flow)
bool hasAbsoluteChildren = false;
bool hasOnlyAbsoluteFollowers = true;
+
for (int i = 0; i < layer.countChildren(); i++) {
if (layer.getChild(i)->isPositionAbsolute()) {
hasAbsoluteChildren = true;
@@ -169,6 +171,10 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
for (int i = 0; i < layer.countChildren(); i++)
addChild(layer.getChild(i)->copy())->unref();
}
+#else
+ for (int i = 0; i < layer.countChildren(); i++)
+ addChild(layer.getChild(i)->copy())->unref();
+#endif
KeyframesMap::const_iterator end = layer.m_animations.end();
for (KeyframesMap::const_iterator it = layer.m_animations.begin(); it != end; ++it) {
diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
index 2819baa..6ff71d9 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
@@ -198,11 +198,12 @@ const TransformationMatrix* ImageTexture::transform()
if (!m_layer)
return 0;
- IntRect layerArea = m_layer->fullContentArea();
- float scaleW = static_cast<float>(layerArea.width()) / static_cast<float>(m_image->width());
- float scaleH = static_cast<float>(layerArea.height()) / static_cast<float>(m_image->height());
TransformationMatrix d = *(m_layer->drawTransform());
TransformationMatrix m;
+ float scaleW = 1.0f;
+ float scaleH = 1.0f;
+ getImageToLayerScale(&scaleW, &scaleH);
+
m.scaleNonUniform(scaleW, scaleH);
m_layerMatrix = d.multiply(m);
return &m_layerMatrix;
@@ -228,6 +229,24 @@ bool ImageTexture::paint(SkCanvas* canvas)
return true;
}
+void ImageTexture::getImageToLayerScale(float* scaleW, float* scaleH) const
+{
+ if (!scaleW || !scaleH)
+ return;
+
+
+ IntRect layerArea = m_layer->fullContentArea();
+
+ if (layerArea.width() == 0 || layerArea.height() == 0)
+ return;
+
+ // calculate X, Y scale difference between image pixel coordinates and layer
+ // content coordinates
+
+ *scaleW = static_cast<float>(layerArea.width()) / static_cast<float>(m_image->width());
+ *scaleH = static_cast<float>(layerArea.height()) / static_cast<float>(m_image->height());
+}
+
void ImageTexture::drawGL(LayerAndroid* layer,
float opacity, FloatPoint* offset)
{
@@ -242,6 +261,16 @@ void ImageTexture::drawGL(LayerAndroid* layer,
if (m_tileGrid) {
bool force3dContentVisible = true;
IntRect visibleContentArea = m_layer->visibleContentArea(force3dContentVisible);
+
+ // transform visibleContentArea size to image size
+ float scaleW = 1.0f;
+ float scaleH = 1.0f;
+ getImageToLayerScale(&scaleW, &scaleH);
+ visibleContentArea.setX(visibleContentArea.x() / scaleW);
+ visibleContentArea.setWidth(visibleContentArea.width() / scaleW);
+ visibleContentArea.setY(visibleContentArea.y() / scaleH);
+ visibleContentArea.setHeight(visibleContentArea.height() / scaleH);
+
const TransformationMatrix* transformation = transform();
if (offset)
m_layerMatrix.translate(offset->x(), offset->y());
diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
index 0571b83..99bec90 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
@@ -95,6 +95,7 @@ public:
private:
const TransformationMatrix* transform();
+ void getImageToLayerScale(float* scaleW, float* scaleH) const;
SkBitmapRef* m_imageRef;
SkBitmap* m_image;
diff --git a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
index 41d6709..f273091 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
@@ -265,9 +265,9 @@ void TransferQueue::setHasGLContext(bool hasContext)
void TransferQueue::emptyAndAbandonQueue()
{
for (int i = 0 ; i < m_transferQueueSize; i++)
- m_transferQueue[i].status = emptyItem;
+ clearItemInTranferQueue(i);
m_emptyItemCount = m_transferQueueSize;
- m_pureColorTileQueue.clear();
+ clearPureColorQueue();
if (m_sharedSurfaceTexture.get()) {
m_sharedSurfaceTexture->abandon();
@@ -295,7 +295,7 @@ void TransferQueue::setPendingDiscard()
if (m_transferQueue[i].status == pendingBlit)
m_transferQueue[i].status = pendingDiscard;
- m_pureColorTileQueue.clear();
+ clearPureColorQueue();
bool GLContextExisted = getHasGLContext();
// Unblock the Tex Gen thread first before Tile Page deletion.
@@ -307,6 +307,15 @@ void TransferQueue::setPendingDiscard()
m_transferQueueItemCond.signal();
}
+void TransferQueue::clearPureColorQueue()
+{
+ for (unsigned int i = 0 ; i < m_pureColorTileQueue.size(); i++) {
+ SkSafeUnref(m_pureColorTileQueue[i].savedTilePainter);
+ m_pureColorTileQueue[i].savedTilePainter = 0;
+ }
+ m_pureColorTileQueue.clear();
+}
+
void TransferQueue::updatePureColorTiles()
{
for (unsigned int i = 0 ; i < m_pureColorTileQueue.size(); i++) {
@@ -324,7 +333,7 @@ void TransferQueue::updatePureColorTiles()
ALOGV("Warning: Don't expect an emptyItem here.");
}
}
- m_pureColorTileQueue.clear();
+ clearPureColorQueue();
}
// Call on UI thread to copy from the shared Surface Texture to the Tile's texture.
@@ -363,8 +372,7 @@ void TransferQueue::updateDirtyTiles()
if (result != OK)
ALOGE("unexpected error: updateTexImage return %d", result);
}
- m_transferQueue[index].savedTilePtr = 0;
- m_transferQueue[index].status = emptyItem;
+
if (obsoleteTile) {
ALOGV("Warning: the texture is obsolete for this baseTile");
index = (index + 1) % m_transferQueueSize;
@@ -391,7 +399,7 @@ void TransferQueue::updateDirtyTiles()
destTexture->setPure(false);
destTexture->transferComplete();
-
+ clearItemInTranferQueue(index);
ALOGV("Blit tile x, y %d %d with dest texture %p to destTexture->m_ownTextureId %d",
m_transferQueue[index].savedTilePtr,
destTexture,
@@ -469,6 +477,14 @@ void TransferQueue::addItemInPureColorQueue(const TileRenderInfo* renderInfo)
m_pureColorTileQueue.append(data);
}
+void TransferQueue::clearItemInTranferQueue(int index)
+{
+ m_transferQueue[index].savedTilePtr = 0;
+ SkSafeUnref(m_transferQueue[index].savedTilePainter);
+ m_transferQueue[index].savedTilePainter = 0;
+ m_transferQueue[index].status = emptyItem;
+}
+
// Translates the info from TileRenderInfo and others to TileTransferData.
// This is used by pure color tiles and normal tiles.
void TransferQueue::addItemCommon(const TileRenderInfo* renderInfo,
@@ -476,6 +492,8 @@ void TransferQueue::addItemCommon(const TileRenderInfo* renderInfo,
TileTransferData* data)
{
data->savedTileTexturePtr = renderInfo->baseTile->backTexture();
+ data->savedTilePainter = renderInfo->tilePainter;
+ SkSafeRef(data->savedTilePainter);
data->savedTilePtr = renderInfo->baseTile;
data->status = pendingBlit;
data->uploadType = type;
@@ -552,10 +570,7 @@ void TransferQueue::cleanupPendingDiscard()
tile->discardBackTexture();
ALOGV("transfer queue discarded tile %p, removed texture", tile);
}
-
- m_transferQueue[index].savedTilePtr = 0;
- m_transferQueue[index].savedTileTexturePtr = 0;
- m_transferQueue[index].status = emptyItem;
+ clearItemInTranferQueue(index);
}
index = (index + 1) % m_transferQueueSize;
}
diff --git a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h
index 44d3c37..9d33ff5 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h
+++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h
@@ -37,6 +37,7 @@
namespace WebCore {
class Tile;
+class TilePainter;
class TileTexture;
struct GLState {
@@ -75,6 +76,7 @@ public:
TileTransferData()
: status(emptyItem)
, savedTilePtr(0)
+ , savedTilePainter(0)
, savedTileTexturePtr(0)
, uploadType(DEFAULT_UPLOAD_TYPE)
, bitmap(0)
@@ -90,6 +92,7 @@ public:
TransferItemStatus status;
Tile* savedTilePtr;
+ TilePainter* savedTilePainter; // Ref count the tilePainter to keep the tile alive.
TileTexture* savedTileTexturePtr;
TextureUploadType uploadType;
// This is only useful in Cpu upload code path, so it will be dynamically
@@ -178,10 +181,12 @@ private:
GLuint srcTexId, GLenum srcTexTarget,
int index);
+ void clearItemInTranferQueue(int index);
void addItemCommon(const TileRenderInfo* renderInfo,
TextureUploadType type, TileTransferData* data);
void updatePureColorTiles();
+ void clearPureColorQueue();
// Note that the m_transferQueueIndex only changed in the TexGen thread
// where we are going to move on to update the next item in the queue.
int m_transferQueueIndex;
diff --git a/Source/WebKit/android/jni/PicturePile.cpp b/Source/WebKit/android/jni/PicturePile.cpp
index f3e46ac..ccdfa59 100644
--- a/Source/WebKit/android/jni/PicturePile.cpp
+++ b/Source/WebKit/android/jni/PicturePile.cpp
@@ -144,9 +144,11 @@ void PicturePile::setSize(const IntSize& size)
// TODO: See above about just adding invals for new content
m_pile.clear();
m_webkitInvals.clear();
- IntRect area(0, 0, size.width(), size.height());
- m_webkitInvals.append(area);
- m_pile.append(area);
+ if (!size.isEmpty()) {
+ IntRect area(0, 0, size.width(), size.height());
+ m_webkitInvals.append(area);
+ m_pile.append(area);
+ }
}
void PicturePile::updatePicturesIfNeeded(PicturePainter* painter)
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index af76daa..dc4f70c 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -617,7 +617,7 @@ WebCore::Node* WebViewCore::currentFocus()
return focusedFrame()->document()->focusedNode();
}
-void WebViewCore::recordPicturePile()
+void WebViewCore::layout()
{
TRACE_METHOD();
@@ -631,9 +631,7 @@ void WebViewCore::recordPicturePile()
// it's fine for layout to gather invalidates, but defeat sending a message
// back to java to call webkitDraw, since we're already in the middle of
// doing that
- m_skipContentDraw = true;
bool success = layoutIfNeededRecursive(m_mainFrame);
- m_skipContentDraw = false;
// We may be mid-layout and thus cannot draw.
if (!success)
@@ -699,16 +697,16 @@ void WebViewCore::recordPicturePile()
view->forceLayout();
// Relayout similar to above
- m_skipContentDraw = true;
- bool success = layoutIfNeededRecursive(m_mainFrame);
- m_skipContentDraw = false;
- if (!success)
- return;
-
- // Set the computed content width
- width = view->contentsWidth();
- height = view->contentsHeight();
+ layoutIfNeededRecursive(m_mainFrame);
}
+}
+
+void WebViewCore::recordPicturePile()
+{
+ // if the webkit page dimensions changed, discard the pictureset and redraw.
+ WebCore::FrameView* view = m_mainFrame->view();
+ int width = view ? view->contentsWidth() : 0;
+ int height = view ? view->contentsHeight() : 0;
m_content.setSize(IntSize(width, height));
@@ -732,6 +730,11 @@ bool WebViewCore::focusBoundsChanged()
void WebViewCore::paintContents(WebCore::GraphicsContext* gc, WebCore::IntRect& dirty)
{
WebCore::FrameView* view = m_mainFrame->view();
+ if (!view) {
+ gc->setFillColor(WebCore::Color::white, WebCore::ColorSpaceDeviceRGB);
+ gc->fillColor();
+ return;
+ }
IntPoint origin = view->minimumScrollPosition();
IntRect drawArea = dirty;
@@ -813,7 +816,7 @@ void WebViewCore::notifyAnimationStarted()
}
-BaseLayerAndroid* WebViewCore::createBaseLayer()
+BaseLayerAndroid* WebViewCore::createBaseLayer(GraphicsLayerAndroid* root)
{
// We set the background color
Color background = Color::white;
@@ -878,15 +881,7 @@ BaseLayerAndroid* WebViewCore::createBaseLayer()
SkSafeUnref(content);
- m_skipContentDraw = true;
- bool layoutSucceeded = layoutIfNeededRecursive(m_mainFrame);
- m_skipContentDraw = false;
- // Layout only fails if called during a layout.
- ALOG_ASSERT(layoutSucceeded, "Can never be called recursively");
-
// We update the layers
- ChromeClientAndroid* chromeC = static_cast<ChromeClientAndroid*>(m_mainFrame->page()->chrome()->client());
- GraphicsLayerAndroid* root = static_cast<GraphicsLayerAndroid*>(chromeC->layersSync());
if (root) {
LayerAndroid* copyLayer = new LayerAndroid(*root->contentLayer());
base->addChild(copyLayer);
@@ -899,9 +894,14 @@ BaseLayerAndroid* WebViewCore::createBaseLayer()
BaseLayerAndroid* WebViewCore::recordContent(SkIPoint* point)
{
+ m_skipContentDraw = true;
+ layout();
+ ChromeClientAndroid* chromeC = static_cast<ChromeClientAndroid*>(m_mainFrame->page()->chrome()->client());
+ GraphicsLayerAndroid* root = static_cast<GraphicsLayerAndroid*>(chromeC->layersSync());
+ m_skipContentDraw = false;
recordPicturePile();
- BaseLayerAndroid* baseLayer = createBaseLayer();
+ BaseLayerAndroid* baseLayer = createBaseLayer(root);
baseLayer->markAsDirty(m_content.dirtyRegion());
m_content.dirtyRegion().setEmpty();
@@ -1686,6 +1686,35 @@ IntPoint WebViewCore::convertGlobalContentToFrameContent(const IntPoint& point,
return IntPoint(point.x() + frameOffset.x(), point.y() + frameOffset.y());
}
+Position WebViewCore::trimSelectionPosition(const Position &start, const Position& stop)
+{
+ int direction = comparePositions(start, stop);
+ if (direction == 0)
+ return start;
+ bool forward = direction < 0;
+ EAffinity affinity = forward ? DOWNSTREAM : UPSTREAM;
+ bool move;
+ Position pos = start;
+ bool movedTooFar = false;
+ do {
+ move = true;
+ Node* node = pos.anchorNode();
+ if (node && node->isTextNode() && node->renderer()) {
+ RenderText *textRenderer = toRenderText(node->renderer());
+ move = !textRenderer->textLength();
+ }
+ if (move) {
+ Position nextPos = forward ? pos.next() : pos.previous();
+ movedTooFar = nextPos.isNull() || pos == nextPos
+ || ((comparePositions(nextPos, stop) < 0) != forward);
+ pos = nextPos;
+ }
+ } while (move && !movedTooFar);
+ if (movedTooFar)
+ pos = stop;
+ return pos;
+}
+
void WebViewCore::selectText(int startX, int startY, int endX, int endY)
{
SelectionController* sc = focusedFrame()->selection();
@@ -1722,7 +1751,11 @@ void WebViewCore::selectText(int startX, int startY, int endX, int endY)
endPosition = prevEndPosition;
}
- VisibleSelection selection(startPosition, endPosition);
+ Position start = startPosition.deepEquivalent();
+ Position end = endPosition.deepEquivalent();
+ start = trimSelectionPosition(start, end);
+ end = trimSelectionPosition(end, start);
+ VisibleSelection selection(start, end);
// Only allow changes between caret positions or to text selection.
bool selectChangeAllowed = (!selection.isCaret() || sc->isCaret());
if (selectChangeAllowed && sc->shouldChangeSelection(selection))
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index a3c1e7c..c6b26c6 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -161,11 +161,6 @@ namespace android {
*/
void contentDraw();
- /**
- * copy the layers to the UI side
- */
- void layersDraw();
-
#if USE(ACCELERATED_COMPOSITING)
WebCore::GraphicsLayerAndroid* graphicsRootLayer() const;
#endif
@@ -517,7 +512,7 @@ namespace android {
// This creates a new BaseLayerAndroid by copying the current m_content
// and doing a copy of the layers. The layers' content may be updated
// as we are calling layersSync().
- WebCore::BaseLayerAndroid* createBaseLayer();
+ WebCore::BaseLayerAndroid* createBaseLayer(GraphicsLayerAndroid* root);
bool updateLayers(WebCore::LayerAndroid*);
void notifyAnimationStarted();
@@ -618,6 +613,7 @@ namespace android {
};
WebCore::Node* currentFocus();
+ void layout();
// Create a set of pictures to represent the drawn DOM, driven by
// the invalidated region and the time required to draw (used to draw)
void recordPicturePile();
@@ -738,6 +734,8 @@ namespace android {
static WebCore::IntRect positionToTextRect(const WebCore::Position& position,
WebCore::EAffinity affinity);
static bool isLtr(const WebCore::Position& position);
+ static WebCore::Position trimSelectionPosition(
+ const WebCore::Position& start, const WebCore::Position& stop);
// called from constructor, to add this to a global list
static void addInstance(WebViewCore*);