diff options
Diffstat (limited to 'Source/WebCore')
5 files changed, 70 insertions, 14 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; |