summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform')
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp44
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.h3
-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/Surface.cpp13
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.h2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h3
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp37
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/TransferQueue.h5
13 files changed, 119 insertions, 48 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index a6bf6af..3975545 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -531,8 +531,8 @@ void GraphicsLayerAndroid::updateScrollingLayers()
if (layerNeedsOverflow) {
ASSERT(!m_foregroundLayer && !m_foregroundClipLayer);
m_foregroundLayer = new ScrollableLayerAndroid(layer);
+ m_foregroundLayer->setIntrinsicallyComposited(true);
- // TODO: can clip layer be set to not intrinsically composited?
m_foregroundClipLayer = new LayerAndroid(layer);
m_foregroundClipLayer->setMasksToBounds(true);
m_foregroundClipLayer->addChild(m_foregroundLayer);
diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
index 62a5824..3241a61 100644
--- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
@@ -79,8 +79,10 @@ void BaseLayerAndroid::updatePositionsRecursive(const SkRect& visibleContentRect
{
updateLayerPositions(visibleContentRect);
TransformationMatrix ident;
- FloatRect clip(0, 0, 1e10, 1e10);
- updateGLPositionsAndScale(ident, clip, 1, state()->scale());
+ FloatRect clip(0, 0, getWidth(), getHeight());
+
+ float scale = state() ? state()->scale() : 1.0f;
+ updateGLPositionsAndScale(ident, clip, 1, scale);
}
ForegroundBaseLayerAndroid::ForegroundBaseLayerAndroid(LayerContent* content)
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index feb2d99..7a25e7f 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) {
@@ -572,9 +578,9 @@ void LayerAndroid::showLayer(int indent)
IntRect visible = visibleContentArea();
IntRect clip(m_clippingRect.x(), m_clippingRect.y(),
m_clippingRect.width(), m_clippingRect.height());
- ALOGD("%s %s %s (%d) [%d:%x - 0x%x] - %s %s - area (%d, %d, %d, %d) - visible (%d, %d, %d, %d) "
+ ALOGD("%s s:%x %s %s (%d) [%d:%x - 0x%x] - %s %s - area (%d, %d, %d, %d) - visible (%d, %d, %d, %d) "
"clip (%d, %d, %d, %d) %s %s m_content(%x), pic w: %d h: %d originalLayer: %x %d",
- spaces, m_haveClip ? "CLIP LAYER" : "", subclassName().ascii().data(),
+ spaces, m_surface, m_haveClip ? "CLIP LAYER" : "", subclassName().ascii().data(),
subclassType(), uniqueId(), this, m_owningLayer,
needsTexture() ? "needsTexture" : "",
m_imageCRC ? "hasImage" : "",
@@ -620,19 +626,8 @@ bool LayerAndroid::canJoinSurface(Surface* surface)
LayerAndroid* lastLayer = surface->getFirstLayer();
- // isolate non-tiled layers
- // TODO: remove this check so that multiple tiled layers with a invisible
- // one inbetween can be merged
- if (!needsTexture() || !lastLayer->needsTexture())
- return false;
-
- // isolate clipped layers
- // TODO: paint correctly with clip when merged
- if (m_haveClip || lastLayer->m_haveClip)
- return false;
-
// isolate intrinsically composited layers
- if (m_intrinsicallyComposited || lastLayer->m_intrinsicallyComposited)
+ if (needsIsolatedSurface() || lastLayer->needsIsolatedSurface())
return false;
// TODO: investigate potential for combining transformed layers
@@ -640,11 +635,6 @@ bool LayerAndroid::canJoinSurface(Surface* surface)
|| !lastLayer->m_drawTransform.isIdentityOrTranslation())
return false;
- // currently, we don't surface zoomable with non-zoomable layers (unless the
- // surface or the layer doesn't need a texture)
- if (surface->needsTexture() && needsTexture() && m_content->hasText() != surface->hasText())
- return false;
-
// TODO: compare other layer properties - fixed? overscroll? transformed?
return true;
#endif
@@ -664,24 +654,26 @@ void LayerAndroid::assignSurfaces(LayerMergeState* mergeState)
}
#ifdef LAYER_MERGING_DEBUG
- ALOGD("%*slayer %p(%d) rl %p %s surface %p, fixed %d, anim %d, intCom %d, haveClip %d scroll %d",
+ ALOGD("%*slayer %p(%d) rl %p %s surface %p lvl: %d, fixed %d, anim %d, intCom %d, haveClip %d scroll %d hasText (layer: %d surface: %d) hasContent %d size %.2f x %.2f",
4*mergeState->depth, "", this, m_uniqueId, m_owningLayer,
needNewSurface ? "NEW" : "joins", mergeState->currentSurface,
+ mergeState->nonMergeNestedLevel,
isPositionFixed(), m_animations.size() != 0,
m_intrinsicallyComposited,
m_haveClip,
- contentIsScrollable());
+ contentIsScrollable(), m_content ? m_content->hasText() : -1,
+ mergeState->currentSurface ? mergeState->currentSurface->hasText() : -1,
+ needsTexture(), getWidth(), getHeight());
#endif
mergeState->currentSurface->addLayer(this, m_drawTransform);
m_surface = mergeState->currentSurface;
- if (m_haveClip || contentIsScrollable() || isPositionFixed()) {
+ if (contentIsScrollable() || isPositionFixed()) {
// disable layer merging within the children of these layer types
mergeState->nonMergeNestedLevel++;
}
-
// pass the surface through children in drawing order, so that they may
// attach themselves (and paint on it) if possible, or ignore it and create
// a new one if not
@@ -699,13 +691,17 @@ void LayerAndroid::assignSurfaces(LayerMergeState* mergeState)
mergeState->depth--;
}
- if (m_haveClip || contentIsScrollable() || isPositionFixed()) {
+ if (contentIsScrollable() || isPositionFixed()) {
// re-enable joining
mergeState->nonMergeNestedLevel--;
// disallow layers painting after to join with this surface
mergeState->currentSurface = 0;
}
+
+ if (needsIsolatedSurface())
+ mergeState->currentSurface = 0;
+
}
// We call this in WebViewCore, when copying the tree of layers.
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
index c7c795f..52df0cf 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
@@ -281,6 +281,9 @@ public:
Surface* surface() { return m_surface; }
void setIntrinsicallyComposited(bool intCom) { m_intrinsicallyComposited = intCom; }
+ bool needsIsolatedSurface() {
+ return (needsTexture() && m_intrinsicallyComposited) || m_animations.size();
+ }
int setHwAccelerated(bool hwAccelerated);
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/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
index 2ec2659..7e4e918 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
@@ -226,19 +226,20 @@ void Surface::prepareGL(bool layerTilesDisabled, bool updateWithBlit)
bool Surface::drawGL(bool layerTilesDisabled)
{
bool tilesDisabled = layerTilesDisabled && !isBase();
- if (!getFirstLayer()->visible())
+ if (singleLayer() && !getFirstLayer()->visible())
return false;
bool isBaseLayer = isBase()
|| getFirstLayer()->subclassType() == LayerAndroid::FixedBackgroundImageLayer
|| getFirstLayer()->subclassType() == LayerAndroid::ForegroundBaseLayer;
- if (!isBaseLayer) {
- // TODO: why are clipping regions wrong for base layer?
- FloatRect drawClip = getFirstLayer()->drawClip();
- FloatRect clippingRect = TilesManager::instance()->shader()->rectInInvViewCoord(drawClip);
- TilesManager::instance()->shader()->clip(clippingRect);
+ FloatRect drawClip = getFirstLayer()->drawClip();
+ if (!singleLayer()) {
+ for (unsigned int i = 1; i < m_layers.size(); i++)
+ drawClip.unite(m_layers[i]->drawClip());
}
+ FloatRect clippingRect = TilesManager::instance()->shader()->rectInInvViewCoord(drawClip);
+ TilesManager::instance()->shader()->clip(clippingRect);
bool askRedraw = false;
if (m_surfaceBacking && !tilesDisabled) {
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h
index a79a286..7100125 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.h
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h
@@ -93,7 +93,7 @@ public:
LayerMergeState(Vector<Surface*>* const allGroups)
: surfaceList(allGroups)
, currentSurface(0)
- , nonMergeNestedLevel(-1) // start at -1 to ignore first LayerAndroid's clipping
+ , nonMergeNestedLevel(0)
, depth(0)
{}
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
index 558d720..f3415af 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
@@ -245,4 +245,14 @@ void SurfaceCollection::updateLayerPositions(const SkRect& visibleContentRect)
#endif
}
+int SurfaceCollection::backedSize()
+{
+ int count = 0;
+ for (unsigned int i = 0; i < m_surfaces.size(); i++) {
+ if (m_surfaces[i]->needsTexture())
+ count++;
+ }
+ return count;
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
index 8debd6a..b502142 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
@@ -67,6 +67,9 @@ public:
bool hasCompositedAnimations();
void updateScrollableLayer(int layerId, int x, int y);
+ int size() { return m_surfaces.size(); }
+ int backedSize();
+
private:
void updateLayerPositions(const SkRect& visibleContentRect);
BaseLayerAndroid* m_compositedRoot;
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
index 8f2dcba..b4fd699 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
@@ -296,6 +296,12 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
GLUtils::clearBackgroundIfOpaque(&background);
}
+#ifdef DEBUG
+ ALOGV("Drawing %d / %d surfaces",
+ m_drawingCollection ? m_drawingCollection->backedSize() : -1,
+ m_drawingCollection ? m_drawingCollection->size() : -1);
+#endif
+
if (m_drawingCollection && m_drawingCollection->drawGL(visibleContentRect))
returnFlags |= DrawGlInfo::kStatusDraw;
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;