Diff
Modified: trunk/Source/WebCore/ChangeLog (167255 => 167256)
--- trunk/Source/WebCore/ChangeLog 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebCore/ChangeLog 2014-04-14 18:40:04 UTC (rev 167256)
@@ -1,3 +1,57 @@
+2014-04-12 Antti Koivisto <an...@apple.com>
+
+ Keep secondary tile grid for zoomed-out scale
+ https://bugs.webkit.org/show_bug.cgi?id=131586
+
+ Reviewed by Darin Adler.
+
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::updateContentsScale):
+
+ Don't repaint tiled backing with setNeedsDisplay, it invalidates itself correctly in setContentsScale.
+ Update custom child layers when tiled backing scale changes.
+
+ * platform/graphics/ca/mac/TileController.h:
+ * platform/graphics/ca/mac/TileController.mm:
+ (WebCore::TileController::TileController):
+ (WebCore::TileController::setNeedsDisplay):
+
+ Drop the whole zoomed-out grid on full repaint.
+
+ (WebCore::TileController::setNeedsDisplayInRect):
+
+ Drop changed zoomed-out tiles. A more sophisticated strategy is possible.
+
+ (WebCore::TileController::setContentsScale):
+
+ Swap the zoomed-out grid in and out as needed.
+ Repaint the active grid after scale change so the client does not have to.
+
+ (WebCore::TileController::contentsScale):
+
+ Get the content scale from the tile grid so it is not kept in two places.
+
+ (WebCore::TileController::zoomedOutContentsScale):
+ (WebCore::TileController::setZoomedOutContentsScale):
+
+ Drop the zoomed-out grid if it no longer matches the zoomed-out scale.
+
+ (WebCore::TileController::tileRevalidationTimerFired):
+ (WebCore::TileController::retainedTileBackingStoreMemory):
+ (WebCore::TileController::containerLayers):
+
+ Return both zoomed-out tiles and the active tiles. Active tiles are on top.
+
+ (WebCore::TileController::numberOfUnparentedTiles):
+ (WebCore::TileController::removeUnparentedTilesNow):
+ * platform/graphics/ca/mac/TileGrid.h:
+ * platform/graphics/ca/mac/TileGrid.mm:
+ (WebCore::TileGrid::dropTilesInRect):
+
+ Add a function for dropping tiles.
+
+ (WebCore::TileGrid::revalidateTiles):
+
2014-04-14 Oliver Hunt <oli...@apple.com>
Update test result
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (167255 => 167256)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2014-04-14 18:40:04 UTC (rev 167256)
@@ -2992,6 +2992,14 @@
return;
m_layer->setContentsScale(contentsScale);
+
+ if (tiledBacking()) {
+ // Scale change may swap in a different set of tiles changing the custom child layers.
+ if (m_isPageTiledBackingLayer)
+ m_uncommittedChanges |= ChildrenChanged;
+ // Tiled backing repaints automatically on scale change.
+ return;
+ }
if (drawsContent())
m_layer->setNeedsDisplay();
}
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h (167255 => 167256)
--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h 2014-04-14 18:40:04 UTC (rev 167256)
@@ -60,7 +60,7 @@
void setNeedsDisplayInRect(const IntRect&);
void setContentsScale(float);
- float contentsScale() const { return m_contentsScale; }
+ float contentsScale() const;
bool acceleratesDrawing() const { return m_acceleratesDrawing; }
void setAcceleratesDrawing(bool);
@@ -148,7 +148,7 @@
virtual void setScrollingModeIndication(ScrollingModeIndication) override;
virtual void setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight) override;
virtual void setZoomedOutContentsScale(float) override;
- virtual float zoomedOutContentsScale() const override { return m_zoomedOutContentsScale; }
+ virtual float zoomedOutContentsScale() const override;
void scheduleTileRevalidation(double interval);
void tileRevalidationTimerFired(Timer<TileController>*);
@@ -162,6 +162,7 @@
std::unique_ptr<TileCoverageMap> m_coverageMap;
std::unique_ptr<TileGrid> m_tileGrid;
+ std::unique_ptr<TileGrid> m_zoomedOutTileGrid;
IntSize m_tileSize;
FloatRect m_visibleRect;
@@ -170,7 +171,6 @@
Timer<TileController> m_tileRevalidationTimer;
- float m_contentsScale;
float m_zoomedOutContentsScale;
float m_deviceScaleFactor;
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm (167255 => 167256)
--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm 2014-04-14 18:40:04 UTC (rev 167256)
@@ -44,11 +44,6 @@
namespace WebCore {
-enum TileValidationPolicyFlag {
- PruneSecondaryTiles = 1 << 0,
- UnparentAllTiles = 1 << 1
-};
-
PassOwnPtr<TileController> TileController::create(PlatformCALayer* rootPlatformLayer)
{
return adoptPtr(new TileController(rootPlatformLayer));
@@ -59,7 +54,6 @@
, m_tileGrid(std::make_unique<TileGrid>(*this))
, m_tileSize(defaultTileWidth, defaultTileHeight)
, m_tileRevalidationTimer(this, &TileController::tileRevalidationTimerFired)
- , m_contentsScale(1)
, m_zoomedOutContentsScale(0)
, m_deviceScaleFactor(1)
, m_tileCoverage(CoverageForVisibleArea)
@@ -96,21 +90,21 @@
void TileController::setNeedsDisplay()
{
tileGrid().setNeedsDisplay();
+ m_zoomedOutTileGrid = nullptr;
}
void TileController::setNeedsDisplayInRect(const IntRect& rect)
{
tileGrid().setNeedsDisplayInRect(rect);
+ if (m_zoomedOutTileGrid)
+ m_zoomedOutTileGrid->dropTilesInRect(rect);
}
void TileController::setContentsScale(float scale)
{
ASSERT(owningGraphicsLayer()->isCommittingChanges());
- m_contentsScale = scale;
-
float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
-
// The scale we get is the product of the page scale factor and device scale factor.
// Divide by the device scale factor so we'll get the page scale factor.
scale /= deviceScaleFactor;
@@ -121,16 +115,44 @@
m_hasTilesWithTemporaryScaleFactor = false;
m_deviceScaleFactor = deviceScaleFactor;
+ if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() == scale) {
+ m_tileGrid = std::move(m_zoomedOutTileGrid);
+ m_tileGrid->revalidateTiles(0);
+ return;
+ }
+
+ if (m_zoomedOutContentsScale && m_zoomedOutContentsScale == tileGrid().scale() && tileGrid().scale() != scale && !m_hasTilesWithTemporaryScaleFactor) {
+ m_zoomedOutTileGrid = std::move(m_tileGrid);
+ m_tileGrid = std::make_unique<TileGrid>(*this);
+ }
+
tileGrid().setScale(scale);
+ tileGrid().setNeedsDisplay();
}
+float TileController::contentsScale() const
+{
+ return tileGrid().scale() * m_deviceScaleFactor;
+}
+
+float TileController::zoomedOutContentsScale() const
+{
+ return m_zoomedOutContentsScale * m_deviceScaleFactor;
+}
+
void TileController::setZoomedOutContentsScale(float scale)
{
ASSERT(owningGraphicsLayer()->isCommittingChanges());
+ float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
+ scale /= deviceScaleFactor;
+
if (m_zoomedOutContentsScale == scale)
return;
m_zoomedOutContentsScale = scale;
+
+ if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() != m_zoomedOutContentsScale)
+ m_zoomedOutTileGrid = nullptr;
}
void TileController::setAcceleratesDrawing(bool acceleratesDrawing)
@@ -322,8 +344,10 @@
setNeedsRevalidateTiles();
return;
}
+ // If we are not visible get rid of the zoomed-out tiles.
+ m_zoomedOutTileGrid = nullptr;
- TileGrid::TileValidationPolicyFlags validationPolicy = (shouldAggressivelyRetainTiles() ? 0 : PruneSecondaryTiles) | UnparentAllTiles;
+ unsigned validationPolicy = (shouldAggressivelyRetainTiles() ? 0 : TileGrid::PruneSecondaryTiles) | TileGrid::UnparentAllTiles;
tileGrid().revalidateTiles(validationPolicy);
}
@@ -379,7 +403,10 @@
double TileController::retainedTileBackingStoreMemory() const
{
- return tileGrid().retainedTileBackingStoreMemory();
+ double bytes = tileGrid().retainedTileBackingStoreMemory();
+ if (m_zoomedOutTileGrid)
+ bytes += m_zoomedOutTileGrid->retainedTileBackingStoreMemory();
+ return bytes;
}
// Return the rect in layer coords, not tile coords.
@@ -478,20 +505,27 @@
Vector<RefPtr<PlatformCALayer>> TileController::containerLayers()
{
- Vector<RefPtr<PlatformCALayer>> layerList(1);
- layerList[0] = &tileGrid().containerLayer();
+ Vector<RefPtr<PlatformCALayer>> layerList;
+ if (m_zoomedOutTileGrid)
+ layerList.append(&m_zoomedOutTileGrid->containerLayer());
+ layerList.append(&tileGrid().containerLayer());
return layerList;
}
-
+
#if PLATFORM(IOS)
unsigned TileController::numberOfUnparentedTiles() const
{
- return tileGrid().numberOfUnparentedTiles();
+ unsigned count = tileGrid().numberOfUnparentedTiles();
+ if (m_zoomedOutTileGrid)
+ count += m_zoomedOutTileGrid->numberOfUnparentedTiles();
+ return count;
}
void TileController::removeUnparentedTilesNow()
{
tileGrid().removeUnparentedTilesNow();
+ if (m_zoomedOutTileGrid)
+ m_zoomedOutTileGrid->removeUnparentedTilesNow();
updateTileCoverageMap();
}
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h (167255 => 167256)
--- trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h 2014-04-14 18:40:04 UTC (rev 167256)
@@ -54,13 +54,17 @@
void setNeedsDisplay();
void setNeedsDisplayInRect(const IntRect&);
+ void dropTilesInRect(const IntRect&);
void updateTilerLayerProperties();
bool prepopulateRect(const FloatRect&);
- typedef unsigned TileValidationPolicyFlags;
- void revalidateTiles(TileValidationPolicyFlags);
+ enum TileValidationPolicyFlag {
+ PruneSecondaryTiles = 1 << 0,
+ UnparentAllTiles = 1 << 1
+ };
+ void revalidateTiles(unsigned validationPolicyFlags);
bool tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const;
IntRect tileCoverageRect() const;
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm (167255 => 167256)
--- trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm 2014-04-14 18:40:04 UTC (rev 167256)
@@ -39,11 +39,6 @@
namespace WebCore {
-enum TileValidationPolicyFlag {
- PruneSecondaryTiles = 1 << 0,
- UnparentAllTiles = 1 << 1
-};
-
TileGrid::TileGrid(TileController& controller)
: m_controller(controller)
, m_containerLayer(*controller.rootLayer().createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr))
@@ -124,6 +119,25 @@
setTileNeedsDisplayInRect(it->key, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
}
+void TileGrid::dropTilesInRect(const IntRect& rect)
+{
+ if (m_tiles.isEmpty())
+ return;
+
+ FloatRect scaledRect(rect);
+ scaledRect.scale(m_scale);
+ IntRect dropRectInTileCoords(enclosingIntRect(scaledRect));
+
+ Vector<TileIndex> tilesToRemove;
+
+ for (auto& index : m_tiles.keys()) {
+ if (rectForTileIndex(index).intersects(dropRectInTileCoords))
+ tilesToRemove.append(index);
+ }
+
+ removeTiles(tilesToRemove);
+}
+
void TileGrid::setTileNeedsDisplayInRect(const TileIndex& tileIndex, TileInfo& tileInfo, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords)
{
PlatformCALayer* tileLayer = tileInfo.layer.get();
@@ -323,7 +337,7 @@
removeTiles(tilesToRemove);
}
-void TileGrid::revalidateTiles(TileValidationPolicyFlags validationPolicy)
+void TileGrid::revalidateTiles(unsigned validationPolicy)
{
FloatRect visibleRect = m_controller.visibleRect();
IntRect bounds = m_controller.bounds();
Modified: trunk/Source/WebKit2/ChangeLog (167255 => 167256)
--- trunk/Source/WebKit2/ChangeLog 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebKit2/ChangeLog 2014-04-14 18:40:04 UTC (rev 167256)
@@ -1,3 +1,18 @@
+2014-04-12 Antti Koivisto <an...@apple.com>
+
+ Keep secondary tile grid for zoomed-out scale
+ https://bugs.webkit.org/show_bug.cgi?id=131586
+
+ Reviewed by Darin Adler.
+
+ * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
+ (WebKit::PlatformCALayerRemoteTiledBacking::PlatformCALayerRemoteTiledBacking):
+ (WebKit::PlatformCALayerRemoteTiledBacking::customSublayers):
+
+ Always request new sublayer list from tile controller.
+
+ * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h:
+
2014-04-14 Tim Horton <timothy_hor...@apple.com>
Make WK(Web)View magnification setters actually use view-relative positions
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp (167255 => 167256)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp 2014-04-14 18:40:04 UTC (rev 167256)
@@ -40,7 +40,6 @@
: PlatformCALayerRemote(layerType, owner, context)
{
m_tileController = TileController::create(this);
- m_customSublayers = std::make_unique<PlatformCALayerList>(m_tileController->containerLayers());
}
PlatformCALayerRemoteTiledBacking::~PlatformCALayerRemoteTiledBacking()
@@ -57,7 +56,8 @@
const WebCore::PlatformCALayerList* PlatformCALayerRemoteTiledBacking::customSublayers() const
{
- return m_customSublayers.get();
+ m_customSublayers = m_tileController->containerLayers();
+ return &m_customSublayers;
}
void PlatformCALayerRemoteTiledBacking::setBounds(const WebCore::FloatRect& bounds)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h (167255 => 167256)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h 2014-04-14 18:04:20 UTC (rev 167255)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h 2014-04-14 18:40:04 UTC (rev 167256)
@@ -54,7 +54,7 @@
virtual void setBorderColor(const WebCore::Color&) override;
OwnPtr<WebCore::TileController> m_tileController;
- std::unique_ptr<WebCore::PlatformCALayerList> m_customSublayers;
+ mutable WebCore::PlatformCALayerList m_customSublayers;
};
} // namespace WebKit