Minor TileCoverageMap refinements
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jun 2014 18:12:44 +0000 (18:12 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jun 2014 18:12:44 +0000 (18:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133468

Reviewed by Simon Fraser.

* platform/graphics/ca/mac/TileController.mm:
(WebCore::TileController::setContentsScale):
* platform/graphics/ca/mac/TileCoverageMap.h:
* platform/graphics/ca/mac/TileCoverageMap.mm:
(WebCore::TileCoverageMap::TileCoverageMap):
(WebCore::TileCoverageMap::setDeviceScaleFactor):
Keep the TileCoverageMap's contentsScale at the device scale factor, so that it
looks sharp on non-1x displays.

(WebCore::TileCoverageMap::update):
Decrease the height available for the TileCoverageMap by the topContentInset;
it's already being vertically offset by the topContentInset, but the height was
not adjusted, so it would run off the bottom of the window.

* platform/graphics/ca/mac/TileGrid.mm:
(WebCore::TileGrid::drawTileMapContents):
If using aggressive tile retention (and thus not coloring tiles based on age),
dim tiles that aren't in the visible cohort.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169563 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ca/mac/TileController.mm
Source/WebCore/platform/graphics/ca/mac/TileCoverageMap.h
Source/WebCore/platform/graphics/ca/mac/TileCoverageMap.mm
Source/WebCore/platform/graphics/ca/mac/TileGrid.mm

index 671859e..2be0d6c 100644 (file)
@@ -1,5 +1,31 @@
 2014-06-03  Timothy Horton  <timothy_horton@apple.com>
 
+        Minor TileCoverageMap refinements
+        https://bugs.webkit.org/show_bug.cgi?id=133468
+
+        Reviewed by Simon Fraser.
+
+        * platform/graphics/ca/mac/TileController.mm:
+        (WebCore::TileController::setContentsScale):
+        * platform/graphics/ca/mac/TileCoverageMap.h:
+        * platform/graphics/ca/mac/TileCoverageMap.mm:
+        (WebCore::TileCoverageMap::TileCoverageMap):
+        (WebCore::TileCoverageMap::setDeviceScaleFactor):
+        Keep the TileCoverageMap's contentsScale at the device scale factor, so that it
+        looks sharp on non-1x displays.
+
+        (WebCore::TileCoverageMap::update):
+        Decrease the height available for the TileCoverageMap by the topContentInset;
+        it's already being vertically offset by the topContentInset, but the height was
+        not adjusted, so it would run off the bottom of the window.
+
+        * platform/graphics/ca/mac/TileGrid.mm:
+        (WebCore::TileGrid::drawTileMapContents):
+        If using aggressive tile retention (and thus not coloring tiles based on age),
+        dim tiles that aren't in the visible cohort.
+
+2014-06-03  Timothy Horton  <timothy_horton@apple.com>
+
         Fix a typo, TileGrid::updateTilerLayerProperties
         https://bugs.webkit.org/show_bug.cgi?id=133474
 
index 93c7306..1f8c3f1 100644 (file)
@@ -114,6 +114,9 @@ void TileController::setContentsScale(float scale)
     m_hasTilesWithTemporaryScaleFactor = false;
     m_deviceScaleFactor = deviceScaleFactor;
 
+    if (m_coverageMap)
+        m_coverageMap->setDeviceScaleFactor(deviceScaleFactor);
+
     if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() == scale) {
         m_tileGrid = std::move(m_zoomedOutTileGrid);
         m_tileGrid->revalidateTiles(0);
index 3ad2198..04e3c25 100644 (file)
@@ -52,6 +52,8 @@ public:
 
     PlatformCALayer& layer() { return m_layer.get(); }
 
+    void setDeviceScaleFactor(float);
+
 private:
     // PlatformCALayerClient
     virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return GraphicsLayer::CompositingCoordinatesTopDown; }
index 6fe1d7e..517acf3 100644 (file)
@@ -43,6 +43,7 @@ TileCoverageMap::TileCoverageMap(const TileController& controller)
     m_layer.get().setBorderColor(Color::black);
     m_layer.get().setBorderWidth(1);
     m_layer.get().setPosition(FloatPoint(2, 2));
+    m_layer.get().setContentsScale(m_controller.deviceScaleFactor());
     m_visibleRectIndicatorLayer.get().setBorderWidth(2);
     m_visibleRectIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
     m_visibleRectIndicatorLayer.get().setBorderColor(Color(255, 0, 0));
@@ -62,6 +63,7 @@ void TileCoverageMap::update()
     FloatRect containerBounds = m_controller.bounds();
     FloatRect visibleRect = m_controller.visibleRect();
     visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges.
+    visibleRect.setHeight(visibleRect.height() - m_controller.topContentInset());
 
     float widthScale = 1;
     float scale = 1;
@@ -110,4 +112,9 @@ float TileCoverageMap::platformCALayerDeviceScaleFactor() const
     return m_controller.rootLayer().owner()->platformCALayerDeviceScaleFactor();
 }
 
+void TileCoverageMap::setDeviceScaleFactor(float deviceScaleFactor)
+{
+    m_layer.get().setContentsScale(deviceScaleFactor);
+}
+
 }
index 7f46187..eb85857 100644 (file)
@@ -579,20 +579,24 @@ void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) con
         CGFloat red = 1;
         CGFloat green = 1;
         CGFloat blue = 1;
+        CGFloat alpha = 1;
         if (tileInfo.hasStaleContent) {
             red = 0.25;
             green = 0.125;
             blue = 0;
+        } else if (m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort) {
+            red = 0.8;
+            green = 0.8;
+            blue = 0.8;
         }
 
         TileCohort newestCohort = newestTileCohort();
         TileCohort oldestCohort = oldestTileCohort();
 
-        if (!m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort) {
-            float cohortProportion = static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort);
-            CGContextSetRGBFillColor(context, red, green, blue, 1 - cohortProportion);
-        } else
-            CGContextSetRGBFillColor(context, red, green, blue, 1);
+        if (!m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort)
+            alpha = 1 - (static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort));
+
+        CGContextSetRGBFillColor(context, red, green, blue, alpha);
 
         if (tileLayer->superlayer()) {
             CGContextSetLineWidth(context, 0.5 / contextScale);