No subject
Mon Sep 28 12:00:37 PDT 2015
handled differently. These are multiplied and provided to
TextureMapperBackingStore.
* platform/graphics/texmap/TextureMapperTile.cpp:
(WebCore::TextureMapperTile::updateContents):
* platform/graphics/texmap/TextureMapperTile.h:
* platform/graphics/texmap/TextureMapperTiledBackingStore.cpp:
Modified to increase the cover rect for tiles creation. For the image
contents, it just creates texture with a image size, regardless of the
contents scale.
* platform/graphics/texmap/BitmapTexture.cpp:
(WebCore::BitmapTexture::updateContents):
Apply the device scale to the graphics context before painting contents.
* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::setContentsToImage):
(WebCore::GraphicsLayerTextureMapper::updateBackingStoreIfNeeded):
Apply the device scale and the page scale to the backing store
Source/WebKit2:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
* UIProcess/gtk/RedirectedXCompositeWindow.cpp:
Modified to create scaled size of window.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::initialize):
(WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged):
We should apply device scale factor to the root layer to apply
the scale matrix before applying other transform matrices.
(WebKit::LayerTreeHostGtk::deviceScaleFactor): Added.
(WebKit::LayerTreeHostGtk::pageScaleFactor): Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapBitmapTexturecpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapBitmapTextureh">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMappercpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTilecpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTileh">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTile.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTiledBackingStorecpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTiledBackingStoreh">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebKit2ChangeLog">releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebKit2UIProcessgtkRedirectedXCompositeWindowcpp">releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebKit2UIProcessgtkRedirectedXCompositeWindowh">releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkcpp">releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkh">releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit210SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2015-09-30 Gwang Yoon Hwang <yoon at igalia.com>
+
+ [GTK] Support HiDPI Properly in WebKitGtk+ with the TextureMapper
+ https://bugs.webkit.org/show_bug.cgi?id=141782
+
+ Reviewed by Carlos Garcia Campos.
+
+ This patch fixes HiDPI issue in the TextureMapper.
+ To support HiDPI in the TextureMapper, we need to draw scaled contents
+ in the TextureMapperTile, and apply the global scale in the root layer
+ to apply transforms correctly.
+
+ Supporting the device scale is handled at LayerTreeHostGtk and
+ TextureMapperBackingStore, and GraphicsLayerTextureMapper doesn't handle
+ the device scale directly.
+
+ From the TextureMapperLayer, deviceScale and pageScale do not have to be
+ handled differently. These are multiplied and provided to
+ TextureMapperBackingStore.
+
+ * platform/graphics/texmap/TextureMapperTile.cpp:
+ (WebCore::TextureMapperTile::updateContents):
+ * platform/graphics/texmap/TextureMapperTile.h:
+ * platform/graphics/texmap/TextureMapperTiledBackingStore.cpp:
+
+ Modified to increase the cover rect for tiles creation. For the image
+ contents, it just creates texture with a image size, regardless of the
+ contents scale.
+
+ * platform/graphics/texmap/BitmapTexture.cpp:
+ (WebCore::BitmapTexture::updateContents):
+
+ Apply the device scale to the graphics context before painting contents.
+
+ * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+ (WebCore::GraphicsLayerTextureMapper::setContentsToImage):
+ (WebCore::GraphicsLayerTextureMapper::updateBackingStoreIfNeeded):
+
+ Apply the device scale and the page scale to the backing store
+
</ins><span class="cx"> 2015-10-05 Jiewen Tan <jiewen_tan at apple.com>
</span><span class="cx">
</span><span class="cx"> Cleaning up after revision 190339
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapBitmapTexturecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-void BitmapTexture::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)
</del><ins>+void BitmapTexture::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag, float scale)
</ins><span class="cx"> {
</span><span class="cx"> // Making an unconditionally unaccelerated buffer here is OK because this code
</span><span class="cx"> // isn't used by any platforms that respect the accelerated bit.
</span><span class="lines">@@ -48,7 +48,10 @@
</span><span class="cx">
</span><span class="cx"> IntRect sourceRect(targetRect);
</span><span class="cx"> sourceRect.setLocation(offset);
</span><del>- context->translate(-offset.x(), -offset.y());
</del><ins>+ sourceRect.scale(1 / scale);
+ context->applyDeviceScaleFactor(scale);
+ context->translate(-sourceRect.x(), -sourceRect.y());
+
</ins><span class="cx"> sourceLayer->paintGraphicsLayerContents(*context, sourceRect);
</span><span class="cx">
</span><span class="cx"> RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapBitmapTextureh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.h (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.h 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/BitmapTexture.h 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">
</span><span class="cx"> virtual IntSize size() const = 0;
</span><span class="cx"> virtual void updateContents(Image*, const IntRect&, const IntPoint& offset, UpdateContentsFlag) = 0;
</span><del>- virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag);
</del><ins>+ virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag, float scale = 1);
</ins><span class="cx"> virtual void updateContents(const void*, const IntRect& target, const IntPoint& offset, int bytesPerLine, UpdateContentsFlag) = 0;
</span><span class="cx"> virtual bool isValid() const = 0;
</span><span class="cx"> inline Flags flags() const { return m_flags; }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMappercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -300,6 +300,7 @@
</span><span class="cx"> if (!m_compositedImage)
</span><span class="cx"> m_compositedImage = TextureMapperTiledBackingStore::create();
</span><span class="cx"> m_compositedImage->setContentsToImage(image);
</span><ins>+ m_compositedImage->updateContentsScale(pageScaleFactor() * deviceScaleFactor());
</ins><span class="cx"> } else {
</span><span class="cx"> m_compositedNativeImagePtr = nullptr;
</span><span class="cx"> m_compositedImage = nullptr;
</span><span class="lines">@@ -545,7 +546,9 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> TextureMapperTiledBackingStore* backingStore = static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get());
</span><ins>+ backingStore->updateContentsScale(pageScaleFactor() * deviceScaleFactor());
</ins><span class="cx">
</span><ins>+ dirtyRect.scale(pageScaleFactor() * deviceScaleFactor());
</ins><span class="cx"> backingStore->updateContents(textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
</span><span class="cx">
</span><span class="cx"> m_needsDisplay = false;
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTilecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx"> m_texture->updateContents(image, targetRect, sourceOffset, updateContentsFlag);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void TextureMapperTile::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
</del><ins>+void TextureMapperTile::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag, float scale)
</ins><span class="cx"> {
</span><span class="cx"> IntRect targetRect = enclosingIntRect(m_rect);
</span><span class="cx"> targetRect.intersect(dirtyRect);
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx"> m_texture->reset(targetRect.size(), BitmapTexture::SupportsAlpha);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- m_texture->updateContents(textureMapper, sourceLayer, targetRect, sourceOffset, updateContentsFlag);
</del><ins>+ m_texture->updateContents(textureMapper, sourceLayer, targetRect, sourceOffset, updateContentsFlag, scale);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TextureMapperTile::paint(TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, const unsigned exposedEdges)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTileh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTile.h (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTile.h 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTile.h 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx"> inline void setRect(const FloatRect& rect) { m_rect = rect; }
</span><span class="cx">
</span><span class="cx"> void updateContents(TextureMapper*, Image*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
</span><del>- void updateContents(TextureMapper*, GraphicsLayer*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
</del><ins>+ void updateContents(TextureMapper*, GraphicsLayer*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData, float scale = 1);
</ins><span class="cx"> virtual void paint(TextureMapper*, const TransformationMatrix&, float, const unsigned exposedEdges);
</span><span class="cx"> virtual ~TextureMapperTile() { }
</span><span class="cx">
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTiledBackingStorecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -29,10 +29,6 @@
</span><span class="cx">
</span><span class="cx"> class GraphicsLayer;
</span><span class="cx">
</span><del>-TextureMapperTiledBackingStore::TextureMapperTiledBackingStore()
-{
-}
-
</del><span class="cx"> void TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded(TextureMapper* textureMapper)
</span><span class="cx"> {
</span><span class="cx"> if (!m_image)
</span><span class="lines">@@ -69,21 +65,35 @@
</span><span class="cx"> textureMapper->drawNumber(repaintCount, borderColor, tile.rect().location(), adjustedTransform);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void TextureMapperTiledBackingStore::updateContentsScale(float scale)
+{
+ if (m_contentsScale == scale)
+ return;
+
+ m_isScaleDirty = true;
+ m_contentsScale = scale;
+}
+
</ins><span class="cx"> void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatSize& size, const IntSize& tileSize, bool hasAlpha)
</span><span class="cx"> {
</span><del>- if (size == m_size)
</del><ins>+ if (size == m_size && !m_isScaleDirty)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> m_size = size;
</span><ins>+ m_isScaleDirty = false;
</ins><span class="cx">
</span><ins>+ FloatSize scaledSize(m_size);
+ if (!m_image)
+ scaledSize.scale(m_contentsScale);
+
</ins><span class="cx"> Vector<FloatRect> tileRectsToAdd;
</span><span class="cx"> Vector<int> tileIndicesToRemove;
</span><span class="cx"> static const size_t TileEraseThreshold = 6;
</span><span class="cx">
</span><span class="cx"> // This method recycles tiles. We check which tiles we need to add, which to remove, and use as many
</span><span class="cx"> // removable tiles as replacement for new tiles when possible.
</span><del>- for (float y = 0; y < m_size.height(); y += tileSize.height()) {
- for (float x = 0; x < m_size.width(); x += tileSize.width()) {
</del><ins>+ for (float y = 0; y < scaledSize.height(); y += tileSize.height()) {
+ for (float x = 0; x < scaledSize.width(); x += tileSize.width()) {
</ins><span class="cx"> FloatRect tileRect(x, y, tileSize.width(), tileSize.height());
</span><span class="cx"> tileRect.intersect(rect());
</span><span class="cx"> tileRectsToAdd.append(tileRect);
</span><span class="lines">@@ -147,7 +157,7 @@
</span><span class="cx"> {
</span><span class="cx"> createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), true);
</span><span class="cx"> for (auto& tile : m_tiles)
</span><del>- tile.updateContents(textureMapper, sourceLayer, dirtyRect, updateContentsFlag);
</del><ins>+ tile.updateContents(textureMapper, sourceLayer, dirtyRect, updateContentsFlag, m_contentsScale);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<BitmapTexture> TextureMapperTiledBackingStore::texture() const
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTiledBackingStoreh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -41,21 +41,31 @@
</span><span class="cx"> virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float) override;
</span><span class="cx"> virtual void drawBorder(TextureMapper*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) override;
</span><span class="cx"> virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) override;
</span><ins>+
+ void updateContentsScale(float);
</ins><span class="cx"> void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
</span><span class="cx"> void updateContents(TextureMapper*, GraphicsLayer*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
</span><span class="cx">
</span><span class="cx"> void setContentsToImage(Image* image) { m_image = image; }
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- TextureMapperTiledBackingStore();
</del><ins>+ TextureMapperTiledBackingStore() { }
+
</ins><span class="cx"> void createOrDestroyTilesIfNeeded(const FloatSize& backingStoreSize, const IntSize& tileSize, bool hasAlpha);
</span><span class="cx"> void updateContentsFromImageIfNeeded(TextureMapper*);
</span><span class="cx"> TransformationMatrix adjustedTransformForRect(const FloatRect&);
</span><del>- inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
</del><ins>+ inline FloatRect rect() const
+ {
+ FloatRect rect(FloatPoint::zero(), m_size);
+ rect.scale(m_contentsScale);
+ return rect;
+ }
</ins><span class="cx">
</span><span class="cx"> Vector<TextureMapperTile> m_tiles;
</span><span class="cx"> FloatSize m_size;
</span><span class="cx"> RefPtr<Image> m_image;
</span><ins>+ float m_contentsScale { 1 };
+ bool m_isScaleDirty { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2015-09-30 Gwang Yoon Hwang <yoon at igalia.com>
+
+ [GTK] Support HiDPI Properly in WebKitGtk+ with the TextureMapper
+ https://bugs.webkit.org/show_bug.cgi?id=141782
+
+ Reviewed by Carlos Garcia Campos.
+
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ * UIProcess/gtk/RedirectedXCompositeWindow.cpp:
+
+ Modified to create scaled size of window.
+
+ * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+ (WebKit::LayerTreeHostGtk::initialize):
+ (WebKit::LayerTreeHostGtk::deviceOrPageScaleFactorChanged):
+
+ We should apply device scale factor to the root layer to apply
+ the scale matrix before applying other transform matrices.
+
+ (WebKit::LayerTreeHostGtk::deviceScaleFactor): Added.
+ (WebKit::LayerTreeHostGtk::pageScaleFactor): Added.
+
</ins><span class="cx"> 2015-09-29 Chris Dumez <cdumez at apple.com>
</span><span class="cx">
</span><span class="cx"> Memory cache revalidations should refresh the network disk cache
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -487,6 +487,7 @@
</span><span class="cx"> if (!priv->redirectedWindow)
</span><span class="cx"> return false;
</span><span class="cx">
</span><ins>+ priv->redirectedWindow->setDeviceScaleFactor(webViewBase->priv->pageProxy->deviceScaleFactor());
</ins><span class="cx"> priv->redirectedWindow->resize(drawingArea->size());
</span><span class="cx">
</span><span class="cx"> if (cairo_surface_t* surface = priv->redirectedWindow->surface()) {
</span><span class="lines">@@ -1069,6 +1070,10 @@
</span><span class="cx"> #if HAVE(GTK_SCALE_FACTOR)
</span><span class="cx"> static void deviceScaleFactorChanged(WebKitWebViewBase* webkitWebViewBase)
</span><span class="cx"> {
</span><ins>+#if USE(REDIRECTED_XCOMPOSITE_WINDOW)
+ if (webkitWebViewBase->priv->redirectedWindow)
+ webkitWebViewBase->priv->redirectedWindow->setDeviceScaleFactor(webkitWebViewBase->priv->pageProxy->deviceScaleFactor());
+#endif
</ins><span class="cx"> webkitWebViewBase->priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
</span><span class="cx"> }
</span><span class="cx"> #endif // HAVE(GTK_SCALE_FACTOR)
</span><span class="lines">@@ -1344,6 +1349,7 @@
</span><span class="cx"> if (!drawingArea)
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ priv->redirectedWindow->setDeviceScaleFactor(webkitWebViewBase->priv->pageProxy->deviceScaleFactor());
</ins><span class="cx"> priv->redirectedWindow->resize(drawingArea->size());
</span><span class="cx"> // Force a resize to ensure the new redirected window size is used by the WebProcess.
</span><span class="cx"> drawingArea->forceResize();
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebKit2UIProcessgtkRedirectedXCompositeWindowcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx">
</span><span class="cx"> #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
</span><span class="cx">
</span><ins>+#include <WebCore/CairoUtilities.h>
</ins><span class="cx"> #include <WebCore/PlatformDisplayX11.h>
</span><span class="cx"> #include <X11/Xlib.h>
</span><span class="cx"> #include <X11/extensions/Xcomposite.h>
</span><span class="lines">@@ -138,6 +139,7 @@
</span><span class="cx"> RedirectedXCompositeWindow::RedirectedXCompositeWindow(GdkWindow* parentWindow, std::function<void()> damageNotify)
</span><span class="cx"> : m_display(GDK_DISPLAY_XDISPLAY(gdk_window_get_display(parentWindow)))
</span><span class="cx"> , m_needsNewPixmapAfterResize(false)
</span><ins>+ , m_deviceScale(1)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == m_display);
</span><span class="cx"> Screen* screen = DefaultScreenOfDisplay(m_display);
</span><span class="lines">@@ -211,14 +213,17 @@
</span><span class="cx">
</span><span class="cx"> void RedirectedXCompositeWindow::resize(const IntSize& size)
</span><span class="cx"> {
</span><del>- if (size == m_size)
</del><ins>+ IntSize scaledSize(size);
+ scaledSize.scale(m_deviceScale);
+
+ if (scaledSize == m_size)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // Resize the window to at last 1x1 since X doesn't allow to create empty windows.
</span><del>- XResizeWindow(m_display, m_window.get(), std::max(1, size.width()), std::max(1, size.height()));
</del><ins>+ XResizeWindow(m_display, m_window.get(), std::max(1, scaledSize.width()), std::max(1, scaledSize.height()));
</ins><span class="cx"> XFlush(m_display);
</span><span class="cx">
</span><del>- m_size = size;
</del><ins>+ m_size = scaledSize;
</ins><span class="cx"> m_needsNewPixmapAfterResize = true;
</span><span class="cx"> if (m_size.isEmpty())
</span><span class="cx"> cleanupPixmapAndPixmapSurface();
</span><span class="lines">@@ -256,6 +261,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<cairo_surface_t> newSurface = adoptRef(cairo_xlib_surface_create(m_display, newPixmap.get(), windowAttributes.visual, m_size.width(), m_size.height()));
</span><ins>+ cairoSurfaceSetDeviceScale(newSurface.get(), m_deviceScale, m_deviceScale);
</ins><span class="cx">
</span><span class="cx"> // Nvidia drivers seem to prepare their redirected window pixmap asynchronously, so for a few fractions
</span><span class="cx"> // of a second after each resize, while doing continuous resizing (which constantly destroys and creates
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebKit2UIProcessgtkRedirectedXCompositeWindowh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.h 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx">
</span><span class="cx"> Window windowID() const { return m_window.get(); }
</span><span class="cx"> void resize(const WebCore::IntSize&);
</span><ins>+ void setDeviceScaleFactor(float scale) { m_deviceScale = scale; }
</ins><span class="cx"> cairo_surface_t* surface();
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -61,6 +62,7 @@
</span><span class="cx"> WebCore::XUniqueDamage m_damage;
</span><span class="cx"> RefPtr<cairo_surface_t> m_surface;
</span><span class="cx"> bool m_needsNewPixmapAfterResize;
</span><ins>+ float m_deviceScale;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -98,6 +98,11 @@
</span><span class="cx"> m_rootLayer->setDrawsContent(false);
</span><span class="cx"> m_rootLayer->setSize(m_webPage->size());
</span><span class="cx">
</span><ins>+ m_scaleMatrix.makeIdentity();
+ m_scaleMatrix.scale(m_webPage->deviceScaleFactor() * m_webPage->pageScaleFactor());
+ downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setAnchorPoint(FloatPoint3D());
+ downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setTransform(m_scaleMatrix);
+
</ins><span class="cx"> // The non-composited contents are a child of the root layer.
</span><span class="cx"> m_nonCompositedContentLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
</span><span class="cx"> m_nonCompositedContentLayer->setDrawsContent(true);
</span><span class="lines">@@ -205,6 +210,10 @@
</span><span class="cx"> {
</span><span class="cx"> // Other layers learn of the scale factor change via WebPage::setDeviceScaleFactor.
</span><span class="cx"> m_nonCompositedContentLayer->deviceOrPageScaleFactorChanged();
</span><ins>+
+ m_scaleMatrix.makeIdentity();
+ m_scaleMatrix.scale(m_webPage->deviceScaleFactor() * m_webPage->pageScaleFactor());
+ downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setTransform(m_scaleMatrix);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void LayerTreeHostGtk::forceRepaint()
</span><span class="lines">@@ -218,6 +227,16 @@
</span><span class="cx"> m_webPage->drawRect(graphicsContext, enclosingIntRect(clipRect));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+float LayerTreeHostGtk::deviceScaleFactor() const
+{
+ return m_webPage->deviceScaleFactor();
+}
+
+float LayerTreeHostGtk::pageScaleFactor() const
+{
+ return m_webPage->pageScaleFactor();
+}
+
</ins><span class="cx"> static inline bool shouldSkipNextFrameBecauseOfContinousImmediateFlushes(double current, double lastImmediateFlushTime)
</span><span class="cx"> {
</span><span class="cx"> // 100ms is about a perceptable delay in UI, so when scheduling layer flushes immediately for more than 100ms,
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h (190943 => 190944)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h 2015-10-13 10:06:49 UTC (rev 190943)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h 2015-10-13 10:16:12 UTC (rev 190944)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include "TextureMapperLayer.h"
</span><span class="cx"> #include <WebCore/GLContext.h>
</span><span class="cx"> #include <WebCore/GraphicsLayerClient.h>
</span><ins>+#include <WebCore/TransformationMatrix.h>
</ins><span class="cx"> #include <wtf/glib/GMainLoopSource.h>
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -75,6 +76,8 @@
</span><span class="cx">
</span><span class="cx"> // GraphicsLayerClient
</span><span class="cx"> virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect) override;
</span><ins>+ virtual float deviceScaleFactor() const override;
+ virtual float pageScaleFactor() const override;
</ins><span class="cx">
</span><span class="cx"> bool flushPendingLayerChanges();
</span><span class="cx">
</span><span class="lines">@@ -99,6 +102,7 @@
</span><span class="cx"> bool m_layerFlushSchedulingEnabled;
</span><span class="cx"> GMainLoopSource m_layerFlushTimerCallback;
</span><span class="cx"> WebCore::GraphicsLayer* m_viewOverlayRootLayer;
</span><ins>+ WebCore::TransformationMatrix m_scaleMatrix;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>
</body>
</html>
More information about the webkit-changes
mailing list