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/fonts/FontAndroid.cpp13
-rw-r--r--Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h3
-rw-r--r--Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp8
-rw-r--r--Source/WebCore/platform/graphics/android/layers/IFrameContentLayerAndroid.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp17
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.h6
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.cpp44
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp16
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h3
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp33
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h2
12 files changed, 94 insertions, 57 deletions
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
index e26fa9e..7bed5bb 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp
@@ -63,6 +63,7 @@ using namespace android;
namespace WebCore {
typedef std::pair<int, float> FallbackFontKey;
+
typedef HashMap<FallbackFontKey, FontPlatformData*> FallbackHash;
static void updateForFont(SkPaint* paint, const SimpleFontData* font) {
@@ -696,7 +697,17 @@ const FontPlatformData* TextRunWalker::setupComplexFont(
{
static FallbackHash fallbackPlatformData;
- FallbackFontKey key(script, platformData.size());
+ // generate scriptStyleIndex - we need unique hash IDs for each style
+ // of each script - normal, bold, italic, bolditalic. the first set of
+ // NUM_SCRIPTS are the normal style version, followed by bold, then
+ // italic, then bold italic. additional fake style bits can be added.
+ int scriptStyleIndex = script;
+ if (platformData.isFakeBold())
+ scriptStyleIndex += NUM_SCRIPTS;
+ if (platformData.isFakeItalic())
+ scriptStyleIndex += NUM_SCRIPTS << 1;
+
+ FallbackFontKey key(scriptStyleIndex, platformData.size());
FontPlatformData* newPlatformData = 0;
if (!fallbackPlatformData.contains(key)) {
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp b/Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp
index 5696a46..4bb388c 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/fonts/FontCacheAndroid.cpp
@@ -175,7 +175,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
}
result = new FontPlatformData(tf, fontDescription.computedSize(),
- (style & SkTypeface::kBold) && !tf->isBold(),
+ (style & SkTypeface::kBold),
(style & SkTypeface::kItalic) && !tf->isItalic(),
fontDescription.orientation(),
fontDescription.textOrientation());
diff --git a/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h b/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
index 1e46971..02a0cea 100644
--- a/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
+++ b/Source/WebCore/platform/graphics/android/fonts/FontPlatformData.h
@@ -92,6 +92,9 @@ public:
HB_FaceRec_* harfbuzzFace() const;
SkTypeface* typeface() const { return mTypeface; }
+ bool isFakeBold() const { return mFakeBold; }
+ bool isFakeItalic() const { return mFakeItalic; }
+
private:
class RefCountedHarfbuzzFace : public RefCounted<RefCountedHarfbuzzFace> {
public:
diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
index fa1cb41..87d6486 100644
--- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
@@ -84,7 +84,13 @@ void BaseLayerAndroid::updatePositionsRecursive(const SkRect& visibleContentRect
updateLayerPositions(visibleContentRect);
TransformationMatrix ident;
- FloatRect clip(0, 0, getWidth(), getHeight());
+
+ // Start with an unnecessarily large clip, since the base layer can
+ // dynamically increase in size to cover the viewport, and we cache its draw
+ // clip. This way the base layer will never have it's visible area clipped
+ // by its m_clippingRect, only the viewport.
+ // Note: values larger than this suffer from floating point rounding issues
+ FloatRect clip(0, 0, 1e7, 1e7);
bool forcePositionCalculation = !m_positionsCalculated;
float scale = 1.0f;
diff --git a/Source/WebCore/platform/graphics/android/layers/IFrameContentLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/IFrameContentLayerAndroid.cpp
index dadb13d..a0bd1b5 100644
--- a/Source/WebCore/platform/graphics/android/layers/IFrameContentLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/IFrameContentLayerAndroid.cpp
@@ -33,8 +33,8 @@ void IFrameContentLayerAndroid::getScrollRect(SkIRect* out) const
out->fLeft = m_scrollLimits.fLeft - pos.fX + m_iframeScrollOffset.x();
out->fTop = m_scrollLimits.fTop - pos.fY + m_iframeScrollOffset.y();
- out->fRight = getSize().width() - m_scrollLimits.width();
- out->fBottom = getSize().height() - m_scrollLimits.height();
+ out->fRight = m_scrollLimits.width();
+ out->fBottom = m_scrollLimits.height();
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index 293bbbc..d709a9c 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -122,6 +122,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
m_transform = layer.m_transform;
m_drawTransform = layer.m_drawTransform;
+ m_drawTransformUnfudged = layer.m_drawTransformUnfudged;
m_childrenTransform = layer.m_childrenTransform;
m_dirtyRegion = layer.m_dirtyRegion;
@@ -272,6 +273,9 @@ void LayerAndroid::addDirtyArea()
return;
}
+ // TODO: rewrite this to handle partial invalidate, and to handle base
+ // layer's large clip correctly
+
IntSize layerSize(getSize().width(), getSize().height());
FloatRect area =
@@ -283,6 +287,7 @@ void LayerAndroid::addDirtyArea()
area.intersect(clip);
IntRect dirtyArea(area.x(), area.y(), area.width(), area.height());
+
state()->addDirtyArea(dirtyArea);
}
@@ -407,6 +412,7 @@ void LayerAndroid::updateLocalTransformAndClip(const TransformationMatrix& paren
-originY,
-anchorPointZ());
+ m_drawTransformUnfudged = m_drawTransform;
if (m_drawTransform.isIdentityOrTranslation()
&& surface() && surface()->allowTransformFudging()) {
// adjust the translation coordinates of the draw transform matrix so
@@ -455,9 +461,8 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
setDrawOpacity(opacity);
// constantly recalculate the draw transform of layers that may require it (and their children)
- forceCalculation |= isPositionFixed()
- || contentIsScrollable()
- || (m_animations.size() != 0);
+ forceCalculation |= hasDynamicTransform();
+
forceCalculation &= !(disableFixedElemUpdate && isPositionFixed());
if (forceCalculation)
updateLocalTransformAndClip(parentMatrix, clipping);
@@ -465,7 +470,7 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
if (!countChildren() || !m_visible)
return;
- TransformationMatrix localMatrix = m_drawTransform;
+ TransformationMatrix localMatrix = m_drawTransformUnfudged;
// Flatten to 2D if the layer doesn't preserve 3D.
if (!preserves3D()) {
@@ -682,7 +687,7 @@ void LayerAndroid::assignSurfaces(LayerMergeState* mergeState)
mergeState->currentSurface->addLayer(this, m_drawTransform);
m_surface = mergeState->currentSurface;
- if (contentIsScrollable() || isPositionFixed()) {
+ if (hasDynamicTransform()) {
// disable layer merging within the children of these layer types
mergeState->nonMergeNestedLevel++;
}
@@ -704,7 +709,7 @@ void LayerAndroid::assignSurfaces(LayerMergeState* mergeState)
mergeState->depth--;
}
- if (contentIsScrollable() || isPositionFixed()) {
+ if (hasDynamicTransform()) {
// re-enable joining
mergeState->nonMergeNestedLevel--;
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
index c56d50a..f821d89 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
@@ -166,7 +166,7 @@ public:
void setPreserves3D(bool value) { m_preserves3D = value; }
void setAnchorPointZ(float z) { m_anchorPointZ = z; }
float anchorPointZ() { return m_anchorPointZ; }
- void setDrawTransform(const TransformationMatrix& transform) { m_drawTransform = transform; }
+ void setDrawTransform(const TransformationMatrix& transform) { m_drawTransform = m_drawTransformUnfudged = transform; }
virtual const TransformationMatrix* drawTransform() const { return &m_drawTransform; }
void setChildrenTransform(const TransformationMatrix& t) { m_childrenTransform = t; }
void setDrawClip(const FloatRect& rect) { m_clippingRect = rect; }
@@ -300,11 +300,15 @@ protected:
virtual void onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra, PaintStyle style);
virtual InvalidateFlags onSetHwAccelerated(bool hwAccelerated) { return InvalidateNone; }
TransformationMatrix m_drawTransform;
+ TransformationMatrix m_drawTransformUnfudged;
int m_uniqueId;
private:
void updateLocalTransformAndClip(const TransformationMatrix& parentMatrix,
const FloatRect& clip);
+ bool hasDynamicTransform() {
+ return contentIsScrollable() || isPositionFixed() || (m_animations.size() != 0);
+ }
#if DUMP_NAV_CACHE
friend class CachedLayer::Debug; // debugging access only
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
index 9df1a7a..73466d3 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
@@ -90,13 +90,24 @@ bool Surface::tryUpdateSurface(Surface* oldSurface)
return true;
}
+ SkRegion invalRegion;
+ bool fullInval = false;
if (singleLayer() && oldSurface->singleLayer()) {
// both are single matching layers, simply apply inval
SkRegion* layerInval = getFirstLayer()->getInvalRegion();
- m_surfaceBacking->markAsDirty(*layerInval);
+ invalRegion = *layerInval;
+
+ if (isBase()) {
+ // the base layer paints outside it's content area to ensure the
+ // viewport is convered, so fully invalidate all tiles if its size
+ // changes to ensure no stale content remains
+ LayerContent* newContent = getFirstLayer()->content();
+ LayerContent* oldContent = oldSurface->getFirstLayer()->content();
+ fullInval = newContent->width() != oldContent->width()
+ || newContent->height() != oldContent->height();
+ }
} else {
- SkRegion invalRegion;
- bool fullInval = m_layers.size() != oldSurface->m_layers.size();
+ fullInval = m_layers.size() != oldSurface->m_layers.size();
if (!fullInval) {
for (unsigned int i = 0; i < m_layers.size(); i++) {
if ((m_layers[i]->uniqueId() != oldSurface->m_layers[i]->uniqueId())
@@ -111,16 +122,15 @@ bool Surface::tryUpdateSurface(Surface* oldSurface)
FloatRect layerPos = m_layers[i]->fullContentAreaMapped();
m_layers[i]->getInvalRegion()->translate(layerPos.x(), layerPos.y());
invalRegion.op(*(m_layers[i]->getInvalRegion()), SkRegion::kUnion_Op);
- break;
}
}
}
+ }
- if (fullInval)
- invalRegion.setRect(-1e8, -1e8, 2e8, 2e8);
+ if (fullInval)
+ invalRegion.setRect(-1e8, -1e8, 2e8, 2e8);
- m_surfaceBacking->markAsDirty(invalRegion);
- }
+ m_surfaceBacking->markAsDirty(invalRegion);
return true;
}
@@ -230,17 +240,15 @@ bool Surface::drawGL(bool layerTilesDisabled)
if (singleLayer() && !getFirstLayer()->visible())
return false;
- bool isBaseLayer = isBase()
- || getFirstLayer()->subclassType() == LayerAndroid::FixedBackgroundImageLayer
- || getFirstLayer()->subclassType() == LayerAndroid::ForegroundBaseLayer;
-
- FloatRect drawClip = getFirstLayer()->drawClip();
- if (!singleLayer()) {
- for (unsigned int i = 1; i < m_layers.size(); i++)
- drawClip.unite(m_layers[i]->drawClip());
+ if (!isBase()) {
+ 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);
}
- 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/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
index 3cfabe1..1c769bf 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
@@ -151,10 +151,8 @@ void SurfaceCollection::addFrameworkInvals()
bool SurfaceCollection::isReady()
{
// Override layer readiness check for single surface mode
- if (m_compositedRoot->state()->isSingleSurfaceRenderingMode()) {
- // TODO: single surface mode should be properly double buffered
- return true;
- }
+ if (m_compositedRoot->state()->isSingleSurfaceRenderingMode())
+ return m_surfaces[0]->isReady();
for (unsigned int i = 0; i < m_surfaces.size(); i++) {
if (!m_surfaces[i]->isReady()) {
@@ -165,12 +163,6 @@ bool SurfaceCollection::isReady()
return true;
}
-bool SurfaceCollection::isBaseSurfaceReady()
-{
- // m_surfaces[0] should be the base surface when in single surface mode.
- return m_surfaces[0]->isReady();
-}
-
bool SurfaceCollection::isMissingBackgroundContent()
{
// return true when the first surface is missing content (indicating the
@@ -222,9 +214,9 @@ void SurfaceCollection::mergeInvalsInto(SurfaceCollection* replacementSurface)
m_compositedRoot->mergeInvalsInto(replacementSurface->m_compositedRoot);
}
-void SurfaceCollection::evaluateAnimations(double currentTime)
+bool SurfaceCollection::evaluateAnimations(double currentTime)
{
- m_compositedRoot->evaluateAnimations(currentTime);
+ return m_compositedRoot->evaluateAnimations(currentTime);
}
bool SurfaceCollection::hasCompositedLayers()
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
index ff4195f..a903015 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h
@@ -54,7 +54,6 @@ public:
void swapTiles();
void addFrameworkInvals();
bool isReady();
- bool isBaseSurfaceReady();
bool isMissingBackgroundContent();
void removePainterOperations();
void computeTexturesAmount(TexturesResult* result);
@@ -63,7 +62,7 @@ public:
void setIsPainting(SurfaceCollection* drawingSurfaceCollection);
void setIsDrawing();
void mergeInvalsInto(SurfaceCollection* replacementSurfaceCollection);
- void evaluateAnimations(double currentTime);
+ bool evaluateAnimations(double currentTime);
bool hasCompositedLayers();
bool hasCompositedAnimations();
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
index 724bf89..174720f 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
@@ -171,7 +171,8 @@ void SurfaceCollectionManager::updateScrollableLayer(int layerId, int x, int y)
}
-int SurfaceCollectionManager::singleSurfaceModeInvalidation(bool scrolling,
+int SurfaceCollectionManager::singleSurfaceModeInvalidation(bool hasRunningAnimation,
+ bool scrolling,
bool shouldDraw)
{
int returnFlags = 0;
@@ -179,21 +180,28 @@ int SurfaceCollectionManager::singleSurfaceModeInvalidation(bool scrolling,
// scrolling or have an incoming painting tree.
bool requireDirtyAll = (m_previouslyScrolling && !scrolling)
|| m_newPaintingCollection;
- if (requireDirtyAll)
- TilesManager::instance()->dirtyAllTiles();
// We also need to tell the framework to continue to invoke until
// the base layer is ready.
bool drawingBaseSurfaceReady = m_drawingCollection
- && m_drawingCollection->isBaseSurfaceReady();
+ && m_drawingCollection->isReady();
+
+ // When the base layer is ready, we can ask the framework to draw. And if
+ // animation is running, dirty all the tiles, otherwise the animation will
+ // be paused.
+ if (drawingBaseSurfaceReady) {
+ if (!shouldDraw)
+ returnFlags |= DrawGlInfo::kStatusDraw;
+ else
+ requireDirtyAll |= hasRunningAnimation;
+ }
+ if (requireDirtyAll)
+ TilesManager::instance()->dirtyAllTiles();
+
bool requireInvoke = requireDirtyAll || !drawingBaseSurfaceReady;
if (requireInvoke)
returnFlags |= DrawGlInfo::kStatusInvoke;
- // When the base layer is ready, we can ask the framework to draw.
- if (!shouldDraw && drawingBaseSurfaceReady)
- returnFlags |= DrawGlInfo::kStatusDraw;
-
m_newPaintingCollection = false;
m_previouslyScrolling = scrolling;
@@ -246,9 +254,6 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
if (m_paintingCollection)
returnFlags |= DrawGlInfo::kStatusInvoke;
- if (singleSurfaceMode)
- returnFlags |= singleSurfaceModeInvalidation(scrolling, shouldDraw);
-
if (!shouldDraw) {
if (didCollectionSwap
|| (!m_paintingCollection
@@ -270,6 +275,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
// Don't have a drawing collection, draw white background
Color background = Color::white;
bool drawBackground = true;
+ bool hasRunningAnimation = false;
if (m_drawingCollection) {
bool drawingReady = didCollectionSwap || m_drawingCollection->isReady();
@@ -288,7 +294,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
returnFlags |= DrawGlInfo::kStatusInvoke;
}
- m_drawingCollection->evaluateAnimations(currentTime);
+ hasRunningAnimation = m_drawingCollection->evaluateAnimations(currentTime);
ALOGV("drawing collection %p", m_drawingCollection);
background = m_drawingCollection->getBackgroundColor();
@@ -298,6 +304,9 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
background = m_paintingCollection->getBackgroundColor();
}
+ if (singleSurfaceMode)
+ returnFlags |= singleSurfaceModeInvalidation(hasRunningAnimation,
+ scrolling, shouldDraw);
// Start doing the actual GL drawing.
if (drawBackground) {
ALOGV("background is %x", background.rgb());
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
index 6aed060..53b5bb6 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
@@ -59,7 +59,7 @@ private:
void swap();
void clearCollections();
void updatePaintingCollection(SurfaceCollection* newCollection);
- int singleSurfaceModeInvalidation(bool scrolling, bool shouldDraw);
+ int singleSurfaceModeInvalidation(bool hasRunningAnimation, bool scrolling, bool shouldDraw);
SurfaceCollection* m_drawingCollection;
SurfaceCollection* m_paintingCollection;
SurfaceCollection* m_queuedCollection;