Diff
Modified: trunk/Source/WebCore/ChangeLog (174829 => 174830)
--- trunk/Source/WebCore/ChangeLog 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebCore/ChangeLog 2014-10-17 19:50:09 UTC (rev 174830)
@@ -1,3 +1,21 @@
+2014-10-17 [email protected] <[email protected]>
+
+ [WinCairo] Accelerated compositing is not implemented.
+ https://bugs.webkit.org/show_bug.cgi?id=137345
+
+ Reviewed by Brent Fulgham.
+
+ This patch is based on GTK, and the texture mapper graphics layer type.
+
+ * WebCore.vcxproj/copyForwardingHeaders.cmd: Copy texmap headers.
+ * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp: Added method and flag indicating whether animation has started.
+ (WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
+ (WebCore::GraphicsLayerTextureMapper::addAnimation):
+ * platform/graphics/texmap/GraphicsLayerTextureMapper.h: Ditto.
+ (WebCore::GraphicsLayerTextureMapper::startedAnimation):
+ * platform/graphics/texmap/TextureMapperShaderProgram.cpp: Use same precision for uniform in vertex shader as in fragment shader.
+ Otherwise glLinkProgram() will fail, and nothing will be rendered.
+
2014-10-17 Alexey Proskuryakov <[email protected]>
[iOS] Crash when load is canceled while waiting for the user to type HTTP authentication credentials
Modified: trunk/Source/WebCore/WebCore.vcxproj/copyForwardingHeaders.cmd (174829 => 174830)
--- trunk/Source/WebCore/WebCore.vcxproj/copyForwardingHeaders.cmd 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebCore/WebCore.vcxproj/copyForwardingHeaders.cmd 2014-10-17 19:50:09 UTC (rev 174830)
@@ -58,6 +58,8 @@
xcopy /y /d "%ProjectDir%..\platform\graphics\win\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\platform\graphics\win\%1\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\platform\graphics\opentype\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
+xcopy /y /d "%ProjectDir%..\platform\graphics\opengl\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
+xcopy /y /d "%ProjectDir%..\platform\graphics\texmap\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\platform\mock\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\platform\text\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\platform\text\icu\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (174829 => 174830)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp 2014-10-17 19:50:09 UTC (rev 174830)
@@ -54,6 +54,7 @@
, m_contentsLayer(0)
, m_animationStartTime(0)
, m_isScrollable(false)
+ , m_startedAnimation(false)
{
}
@@ -591,6 +592,7 @@
m_animationStartTime = currentTime - timeOffset;
notifyChange(AnimationChange);
notifyChange(AnimationStarted);
+ m_startedAnimation = true;
return true;
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h (174829 => 174830)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h 2014-10-17 19:50:09 UTC (rev 174830)
@@ -100,6 +100,8 @@
float debugBorderWidth() const { return m_debugBorderWidth; }
void setRepaintCount(int);
+ bool startedAnimation() const { return m_startedAnimation; }
+
private:
virtual void willBeDestroyed();
@@ -177,6 +179,7 @@
IntSize m_committedScrollOffset;
bool m_isScrollable;
+ bool m_startedAnimation;
};
inline static GraphicsLayerTextureMapper* toGraphicsLayerTextureMapper(GraphicsLayer* layer)
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp (174829 => 174830)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp 2014-10-17 19:50:09 UTC (rev 174830)
@@ -208,6 +208,8 @@
ANTIALIASING_TEX_COORD_DIRECTIVE
BLUR_CONSTANTS
STRINGIFY(
+ precision highp float;
+ uniform mat4 u_textureSpaceMatrix;
precision mediump float;
uniform SamplerType s_sampler;
uniform sampler2D s_contentTexture;
@@ -220,7 +222,6 @@
uniform vec2 u_shadowOffset;
uniform vec4 u_color;
uniform float u_gaussianKernel[GAUSSIAN_KERNEL_HALF_WIDTH];
- uniform mat4 u_textureSpaceMatrix;
void noop(inout vec4 dummyParameter) { }
void noop(inout vec4 dummyParameter, vec2 texCoord) { }
Modified: trunk/Source/WebKit/ChangeLog (174829 => 174830)
--- trunk/Source/WebKit/ChangeLog 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebKit/ChangeLog 2014-10-17 19:50:09 UTC (rev 174830)
@@ -1,3 +1,15 @@
+2014-10-17 [email protected] <[email protected]>
+
+ [WinCairo] Accelerated compositing is not implemented.
+ https://bugs.webkit.org/show_bug.cgi?id=137345
+
+ Reviewed by Brent Fulgham.
+
+ This patch is based on GTK, and the texture mapper graphics layer type.
+
+ * WebKit.vcxproj/WebKit/WebKit.vcxproj: Added new accelerated compositing source files.
+ * WebKit.vcxproj/WebKit/WebKit.vcxproj.filters: Ditto.
+
2014-10-16 Tim Horton <[email protected]>
Implement selection services menu for Legacy WebKit
Modified: trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj (174829 => 174830)
--- trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj 2014-10-17 19:50:09 UTC (rev 174830)
@@ -323,6 +323,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\win\WebCoreStatistics.cpp" />
+ <ClCompile Include="..\..\win\WebCoreSupport\AcceleratedCompositingContext.cpp" />
<ClCompile Include="..\..\win\WebCoreSupport\EmbeddedWidget.cpp" />
<ClCompile Include="..\..\win\WebCoreSupport\WebChromeClient.cpp" />
<ClCompile Include="..\..\win\WebCoreSupport\WebContextMenuClient.cpp" />
@@ -460,6 +461,7 @@
<ClInclude Include="..\..\win\WebCachedFramePlatformData.h" />
<ClInclude Include="..\..\win\WebCookieManager.h" />
<ClInclude Include="..\..\win\WebCoreStatistics.h" />
+ <ClInclude Include="..\..\win\WebCoreSupport\AcceleratedCompositingContext.h" />
<ClInclude Include="..\..\win\WebCoreSupport\EmbeddedWidget.h" />
<ClInclude Include="..\..\win\WebCoreSupport\WebChromeClient.h" />
<ClInclude Include="..\..\win\WebCoreSupport\WebContextMenuClient.h" />
Modified: trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj.filters (174829 => 174830)
--- trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj.filters 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebKit/WebKit.vcxproj/WebKit/WebKit.vcxproj.filters 2014-10-17 19:50:09 UTC (rev 174830)
@@ -275,6 +275,9 @@
<ClCompile Include="..\..\win\AccessibleTextImpl.cpp">
<Filter>Sources</Filter>
</ClCompile>
+ <ClCompile Include="..\..\win\WebCoreSupport\AcceleratedCompositingContext.cpp">
+ <Filter>WebCoreSupport</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\win\WebCoreSupport\EmbeddedWidget.h">
@@ -536,6 +539,9 @@
<ClInclude Include="..\..\win\AccessibleTextImpl.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\win\WebCoreSupport\AcceleratedCompositingContext.h">
+ <Filter>WebCoreSupport</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="WebKitPostBuild.cmd" />
Modified: trunk/Source/WebKit/win/ChangeLog (174829 => 174830)
--- trunk/Source/WebKit/win/ChangeLog 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebKit/win/ChangeLog 2014-10-17 19:50:09 UTC (rev 174830)
@@ -1,3 +1,49 @@
+2014-10-17 [email protected] <[email protected]>
+
+ [WinCairo] Accelerated compositing is not implemented.
+ https://bugs.webkit.org/show_bug.cgi?id=137345
+
+ Reviewed by Brent Fulgham.
+
+ This patch is based on GTK, and the texture mapper graphics layer type.
+
+ * WebCoreSupport/AcceleratedCompositingContext.cpp: Added.
+ (WebKit::AcceleratedCompositingContext::AcceleratedCompositingContext):
+ (WebKit::getWebViewSize):
+ (WebKit::AcceleratedCompositingContext::initialize):
+ (WebKit::AcceleratedCompositingContext::~AcceleratedCompositingContext):
+ (WebKit::AcceleratedCompositingContext::stopAnyPendingLayerFlush):
+ (WebKit::AcceleratedCompositingContext::enabled):
+ (WebKit::AcceleratedCompositingContext::prepareForRendering):
+ (WebKit::AcceleratedCompositingContext::startedAnimation):
+ (WebKit::AcceleratedCompositingContext::compositeLayersToContext):
+ (WebKit::AcceleratedCompositingContext::setRootCompositingLayer):
+ (WebKit::AcceleratedCompositingContext::setNonCompositedContentsNeedDisplay):
+ (WebKit::AcceleratedCompositingContext::setNeedsDisplayInRect):
+ (WebKit::AcceleratedCompositingContext::resizeRootLayer):
+ (WebKit::AcceleratedCompositingContext::scrollNonCompositedContents):
+ (WebKit::AcceleratedCompositingContext::scheduleLayerFlush):
+ (WebKit::AcceleratedCompositingContext::flushPendingLayerChanges):
+ (WebKit::AcceleratedCompositingContext::flushPendingLayerChangesSoon):
+ (WebKit::AcceleratedCompositingContext::flushAndRenderLayers):
+ (WebKit::AcceleratedCompositingContext::layerFlushTimerFired):
+ (WebKit::AcceleratedCompositingContext::notifyAnimationStarted):
+ (WebKit::AcceleratedCompositingContext::notifyFlushRequired):
+ (WebKit::AcceleratedCompositingContext::paintContents):
+ * WebCoreSupport/AcceleratedCompositingContext.h: Added.
+ (WebKit::AcceleratedCompositingContext::LayerFlushTimer::LayerFlushTimer):
+ (WebKit::AcceleratedCompositingContext::LayerFlushTimer::fired):
+ * WebView.cpp:
+ (WebView::WebView):
+ (WebView::addToDirtyRegion):
+ (WebView::scrollBackingStore):
+ (WebView::sizeChanged):
+ (WebView::paint):
+ (WebView::setRootChildLayer):
+ (WebView::flushPendingGraphicsLayerChangesSoon):
+ (WebView::setAcceleratedCompositing):
+ * WebView.h:
+
2014-10-16 Commit Queue <[email protected]>
Unreviewed, rolling out r174754.
Added: trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.cpp (0 => 174830)
--- trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.cpp (rev 0)
+++ trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.cpp 2014-10-17 19:50:09 UTC (rev 174830)
@@ -0,0 +1,328 @@
+/*
+ * Copyright (C) 2014 Apple, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AcceleratedCompositingContext.h"
+
+#if USE(TEXTURE_MAPPER_GL)
+
+#include "WebView.h"
+
+#include <WebCore/Document.h>
+#include <WebCore/Frame.h>
+#include <WebCore/FrameView.h>
+#include <WebCore/GraphicsLayerTextureMapper.h>
+#include <WebCore/MainFrame.h>
+#include <WebCore/Page.h>
+#include <WebCore/Settings.h>
+#include <WebCore/TemporaryOpenGLSetting.h>
+#include <WebCore/TextureMapperGL.h>
+#include <WebCore/TextureMapperLayer.h>
+
+#if USE(OPENGL_ES_2)
+#include <GLES2/gl2.h>
+#else
+#include <GL/gl.h>
+#endif
+
+using namespace WebCore;
+
+AcceleratedCompositingContext::AcceleratedCompositingContext(WebView& webView)
+ : m_webView(webView)
+ , m_layerFlushTimer(*this)
+ , m_context(nullptr)
+ , m_window(0)
+{
+}
+
+static IntSize getWebViewSize(WebView& webView)
+{
+ RECT r;
+ webView.frameRect(&r);
+ return IntSize(r.right - r.left, r.bottom - r.top);
+}
+
+void AcceleratedCompositingContext::initialize()
+{
+ if (m_rootLayer)
+ return;
+
+ IntSize pageSize = getWebViewSize(m_webView);
+
+ m_window = m_webView.viewWindow();
+
+ if (!m_window)
+ return;
+
+ m_rootLayer = GraphicsLayer::create(nullptr, *this);
+ m_rootLayer->setDrawsContent(false);
+ m_rootLayer->setSize(pageSize);
+
+ // The non-composited contents are a child of the root layer.
+ m_nonCompositedContentLayer = GraphicsLayer::create(nullptr, *this);
+ m_nonCompositedContentLayer->setDrawsContent(true);
+ m_nonCompositedContentLayer->setContentsOpaque(!m_webView.transparent());
+ m_nonCompositedContentLayer->setSize(pageSize);
+ if (core(&m_webView)->settings().acceleratedDrawingEnabled())
+ m_nonCompositedContentLayer->setAcceleratesDrawing(true);
+
+#ifndef NDEBUG
+ m_rootLayer->setName("Root layer");
+ m_nonCompositedContentLayer->setName("Non-composited content");
+#endif
+
+ m_rootLayer->addChild(m_nonCompositedContentLayer.get());
+ m_nonCompositedContentLayer->setNeedsDisplay();
+
+ // The creation of the TextureMapper needs an active OpenGL context.
+ if (!m_context)
+ m_context = GLContext::createContextForWindow(m_window, GLContext::sharingContext());
+
+ m_context->makeContextCurrent();
+
+ m_textureMapper = TextureMapperGL::create(TextureMapper::OpenGLMode);
+ static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
+ toTextureMapperLayer(m_rootLayer.get())->setTextureMapper(m_textureMapper.get());
+
+ scheduleLayerFlush();
+}
+
+AcceleratedCompositingContext::~AcceleratedCompositingContext()
+{
+ stopAnyPendingLayerFlush();
+}
+
+void AcceleratedCompositingContext::stopAnyPendingLayerFlush()
+{
+ m_layerFlushTimer.stop();
+}
+
+bool AcceleratedCompositingContext::enabled()
+{
+ return m_window && m_rootLayer && m_textureMapper;
+}
+
+bool AcceleratedCompositingContext::prepareForRendering()
+{
+ if (!enabled())
+ return false;
+
+ if (!m_context)
+ return false;
+
+ if (!m_context->makeContextCurrent())
+ return false;
+
+ return true;
+}
+
+bool AcceleratedCompositingContext::startedAnimation(WebCore::GraphicsLayer* layer)
+{
+ if (!layer)
+ return false;
+
+ if (toGraphicsLayerTextureMapper(layer)->startedAnimation())
+ return true;
+
+ for (auto childLayer : layer->children()) {
+ if (startedAnimation(childLayer))
+ return true;
+ }
+
+ return false;
+}
+
+void AcceleratedCompositingContext::compositeLayersToContext(CompositePurpose purpose)
+{
+ if (!prepareForRendering())
+ return;
+
+ RECT r;
+ if (!::GetClientRect(m_window, &r))
+ return;
+ IntSize windowSize(r.right, r.bottom);
+ glViewport(0, 0, windowSize.width(), windowSize.height());
+
+ if (purpose == ForResize) {
+ TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
+ glClearColor(1, 1, 1, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+
+ m_textureMapper->beginPainting();
+ toTextureMapperLayer(m_rootLayer.get())->paint();
+ m_fpsCounter.updateFPSAndDisplay(m_textureMapper.get());
+ m_textureMapper->endPainting();
+
+ m_context->swapBuffers();
+}
+
+void AcceleratedCompositingContext::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
+{
+ prepareForRendering();
+
+ if (!graphicsLayer) {
+ stopAnyPendingLayerFlush();
+ m_rootLayer = nullptr;
+ m_nonCompositedContentLayer = nullptr;
+ m_textureMapper = nullptr;
+ return;
+ }
+
+ // Add the accelerated layer tree hierarchy.
+ initialize();
+ if (!m_window)
+ return;
+
+ m_nonCompositedContentLayer->removeAllChildren();
+ m_nonCompositedContentLayer->addChild(graphicsLayer);
+
+ stopAnyPendingLayerFlush();
+
+ scheduleLayerFlush();
+}
+
+void AcceleratedCompositingContext::setNonCompositedContentsNeedDisplay(const IntRect& rect)
+{
+ if (!m_rootLayer)
+ return;
+ if (rect.isEmpty()) {
+ m_rootLayer->setNeedsDisplay();
+ return;
+ }
+ m_nonCompositedContentLayer->setNeedsDisplayInRect(rect);
+ scheduleLayerFlush();
+}
+
+void AcceleratedCompositingContext::setNeedsDisplayInRect(const IntRect& rect)
+{
+ if (!m_rootLayer)
+ return;
+ if (rect.isEmpty()) {
+ m_rootLayer->setNeedsDisplay();
+ return;
+ }
+ m_rootLayer->setNeedsDisplayInRect(rect);
+ scheduleLayerFlush();
+}
+
+void AcceleratedCompositingContext::resizeRootLayer(const IntSize& newSize)
+{
+ if (!enabled())
+ return;
+
+ if (m_rootLayer->size() == newSize)
+ return;
+
+ m_rootLayer->setSize(newSize);
+
+ // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed
+ // for those newly exposed areas.
+ FloatSize oldSize = m_nonCompositedContentLayer->size();
+ m_nonCompositedContentLayer->setSize(newSize);
+
+ if (newSize.width() > oldSize.width()) {
+ float height = std::min(static_cast<float>(newSize.height()), oldSize.height());
+ m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height));
+ }
+
+ if (newSize.height() > oldSize.height())
+ m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
+
+ m_nonCompositedContentLayer->setNeedsDisplayInRect(IntRect(IntPoint(), newSize));
+ compositeLayersToContext(ForResize);
+ scheduleLayerFlush();
+}
+
+void AcceleratedCompositingContext::scrollNonCompositedContents(const IntRect& scrollRect, const IntSize& /* scrollOffset */)
+{
+ m_nonCompositedContentLayer->setNeedsDisplay();
+ scheduleLayerFlush();
+}
+
+void AcceleratedCompositingContext::scheduleLayerFlush()
+{
+ if (!enabled())
+ return;
+
+ if (m_layerFlushTimer.isActive())
+ return;
+
+ m_layerFlushTimer.startOneShot(0);
+}
+
+bool AcceleratedCompositingContext::flushPendingLayerChanges()
+{
+ m_rootLayer->flushCompositingStateForThisLayerOnly();
+ m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly();
+ return core(&m_webView)->mainFrame().view()->flushCompositingStateIncludingSubframes();
+}
+
+bool AcceleratedCompositingContext::flushPendingLayerChangesSoon()
+{
+ scheduleLayerFlush();
+ return true;
+}
+
+void AcceleratedCompositingContext::flushAndRenderLayers()
+{
+ if (!enabled())
+ return;
+
+ Frame& frame = core(&m_webView)->mainFrame();
+ if (!frame.contentRenderer() || !frame.view())
+ return;
+ frame.view()->updateLayoutAndStyleIfNeededRecursive();
+
+ if (!enabled())
+ return;
+
+ if (m_context && !m_context->makeContextCurrent())
+ return;
+
+ if (!flushPendingLayerChanges())
+ return;
+
+ compositeLayersToContext();
+}
+
+void AcceleratedCompositingContext::layerFlushTimerFired()
+{
+ flushAndRenderLayers();
+
+ // In case an animation is running, we should flush again soon.
+ if (startedAnimation(m_rootLayer.get()))
+ scheduleLayerFlush();
+}
+
+void AcceleratedCompositingContext::paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& rectToPaint)
+{
+ context.save();
+ context.clip(rectToPaint);
+ core(&m_webView)->mainFrame().view()->paint(&context, enclosingIntRect(rectToPaint));
+ context.restore();
+}
+
+#endif // USE(TEXTURE_MAPPER_GL)
Added: trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.h (0 => 174830)
--- trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.h (rev 0)
+++ trunk/Source/WebKit/win/WebCoreSupport/AcceleratedCompositingContext.h 2014-10-17 19:50:09 UTC (rev 174830)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2014 Apple, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AcceleratedCompositingContext_h
+#define AcceleratedCompositingContext_h
+
+#if USE(TEXTURE_MAPPER_GL)
+
+#include <WebCore/FloatRect.h>
+#include <WebCore/GLContext.h>
+#include <WebCore/GraphicsLayer.h>
+#include <WebCore/GraphicsLayerClient.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/IntSize.h>
+#include <WebCore/TextureMapperFPSCounter.h>
+#include <WebCore/Timer.h>
+#include <wtf/PassOwnPtr.h>
+
+class WebView;
+
+class AcceleratedCompositingContext : public WebCore::GraphicsLayerClient {
+ WTF_MAKE_NONCOPYABLE(AcceleratedCompositingContext);
+public:
+ explicit AcceleratedCompositingContext(WebView&);
+ virtual ~AcceleratedCompositingContext();
+
+ void setRootCompositingLayer(WebCore::GraphicsLayer*);
+ void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&);
+ void setNeedsDisplayInRect(const WebCore::IntRect&);
+ void scheduleLayerFlush();
+ void resizeRootLayer(const WebCore::IntSize&);
+ bool enabled();
+
+ // GraphicsLayerClient
+ virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& rectToPaint);
+
+ void initialize();
+
+ enum CompositePurpose { ForResize, NotForResize };
+ void compositeLayersToContext(CompositePurpose = NotForResize);
+
+ void flushAndRenderLayers();
+ bool flushPendingLayerChanges();
+ bool flushPendingLayerChangesSoon();
+ void scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+
+private:
+ WebView& m_webView;
+ OwnPtr<WebCore::GLContext> m_context;
+ HWND m_window;
+ std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
+ std::unique_ptr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
+ std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
+ WebCore::TextureMapperFPSCounter m_fpsCounter;
+
+ class LayerFlushTimer : public WebCore::TimerBase {
+ public:
+ LayerFlushTimer(AcceleratedCompositingContext& context)
+ : m_context(context)
+ {
+ }
+
+ private:
+ virtual void fired()
+ {
+ m_context.layerFlushTimerFired();
+ }
+
+ AcceleratedCompositingContext& m_context;
+ } m_layerFlushTimer;
+
+ void layerFlushTimerFired();
+ void stopAnyPendingLayerFlush();
+ bool prepareForRendering();
+ bool startedAnimation(WebCore::GraphicsLayer*);
+};
+
+#endif // TEXTURE_MAPPER_GL
+
+#endif // AcceleratedCompositingContext_h
Modified: trunk/Source/WebKit/win/WebView.cpp (174829 => 174830)
--- trunk/Source/WebKit/win/WebView.cpp 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebKit/win/WebView.cpp 2014-10-17 19:50:09 UTC (rev 174830)
@@ -170,6 +170,8 @@
#if USE(CA)
#include <WebCore/CACFLayerTreeHost.h>
#include <WebCore/PlatformCALayer.h>
+#elif USE(TEXTURE_MAPPER_GL)
+#include "AcceleratedCompositingContext.h"
#endif
#if ENABLE(FULLSCREEN_API)
@@ -409,6 +411,9 @@
, m_lastSetCursor(0)
, m_usesLayeredWindow(false)
, m_needsDisplay(false)
+#if USE(TEXTURE_MAPPER_GL)
+ , m_acceleratedCompositingContext(nullptr)
+#endif
{
JSC::initializeThreading();
WTF::initializeMainThread();
@@ -860,7 +865,11 @@
// http://webkit.org/b/29350.
if (isAcceleratedCompositing()) {
+#if USE(CA)
m_backingLayer->setNeedsDisplayInRect(dirtyRect);
+#elif USE(TEXTURE_MAPPER_GL)
+ m_acceleratedCompositingContext->setNeedsDisplayInRect(dirtyRect);
+#endif
return;
}
@@ -895,7 +904,11 @@
if (isAcceleratedCompositing()) {
// FIXME: We should be doing something smarter here, like moving tiles around and painting
// any newly-exposed tiles. <http://webkit.org/b/52714>
+#if USE(CA)
m_backingLayer->setNeedsDisplayInRect(scrollViewRect);
+#elif USE(TEXTURE_MAPPER_GL)
+ m_acceleratedCompositingContext->scrollNonCompositedContents(scrollViewRect, IntSize(dx, dy));
+#endif
return;
}
@@ -952,10 +965,14 @@
#if USE(CA)
if (m_layerTreeHost)
m_layerTreeHost->resize();
+
if (m_backingLayer) {
m_backingLayer->setSize(newSize);
m_backingLayer->setNeedsDisplay();
}
+#elif USE(TEXTURE_MAPPER_GL)
+ if (m_acceleratedCompositingContext)
+ m_acceleratedCompositingContext->resizeRootLayer(newSize);
#endif
}
@@ -1084,18 +1101,22 @@
{
LOCAL_GDI_COUNTER(0, __FUNCTION__);
+ if (isAcceleratedCompositing() && !usesLayeredWindow()) {
#if USE(CA)
- if (isAcceleratedCompositing() && !usesLayeredWindow()) {
m_layerTreeHost->flushPendingLayerChangesNow();
+#elif USE(TEXTURE_MAPPER_GL)
+ m_acceleratedCompositingContext->flushAndRenderLayers();
+#endif
// Flushing might have taken us out of compositing mode.
if (isAcceleratedCompositing()) {
+#if USE(CA)
// FIXME: We need to paint into dc (if provided). <http://webkit.org/b/52578>
m_layerTreeHost->paint();
+#endif
::ValidateRect(m_viewWindow, 0);
return;
}
}
-#endif
Frame* coreFrame = core(m_mainFrame);
if (!coreFrame)
@@ -2393,8 +2414,10 @@
RECT windowRect;
::GetClientRect(hWnd, &windowRect);
::InvalidateRect(hWnd, &windowRect, false);
+#if USE(CA)
if (webView->isAcceleratedCompositing())
webView->m_backingLayer->setNeedsDisplay();
+#endif
}
break;
case WM_MOUSEACTIVATE:
@@ -6551,9 +6574,15 @@
void WebView::setRootChildLayer(GraphicsLayer* layer)
{
setAcceleratedCompositing(layer ? true : false);
+#if USE(CA)
if (!m_backingLayer)
return;
m_backingLayer->addChild(layer);
+#elif USE(TEXTURE_MAPPER_GL)
+ if (!m_acceleratedCompositingContext)
+ return;
+ m_acceleratedCompositingContext->setRootCompositingLayer(layer);
+#endif
}
void WebView::flushPendingGraphicsLayerChangesSoon()
@@ -6562,13 +6591,20 @@
if (!m_layerTreeHost)
return;
m_layerTreeHost->flushPendingGraphicsLayerChangesSoon();
+#elif USE(TEXTURE_MAPPER_GL)
+ if (!m_acceleratedCompositingContext)
+ return;
+ m_acceleratedCompositingContext->flushPendingLayerChangesSoon();
#endif
}
void WebView::setAcceleratedCompositing(bool accelerated)
{
+ if (m_isAcceleratedCompositing == accelerated)
+ return;
+
#if USE(CA)
- if (m_isAcceleratedCompositing == accelerated || !CACFLayerTreeHost::acceleratedCompositingAvailable())
+ if (!CACFLayerTreeHost::acceleratedCompositingAvailable())
return;
if (accelerated) {
@@ -6608,6 +6644,10 @@
m_backingLayer = nullptr;
m_isAcceleratedCompositing = false;
}
+#elif USE(TEXTURE_MAPPER_GL)
+ if (accelerated && !m_acceleratedCompositingContext)
+ m_acceleratedCompositingContext = std::make_unique<AcceleratedCompositingContext>(*this);
+ m_isAcceleratedCompositing = accelerated;
#endif
}
@@ -6752,14 +6792,18 @@
FrameView* view = coreFrame->view();
if (!view)
return;
+#if USE(CA)
if (!m_backingLayer)
return;
+#endif
view->updateLayoutAndStyleIfNeededRecursive();
+#if USE(CA)
// Updating layout might have taken us out of compositing mode.
if (m_backingLayer)
m_backingLayer->flushCompositingStateForThisLayerOnly();
+#endif
view->flushCompositingStateIncludingSubframes();
}
Modified: trunk/Source/WebKit/win/WebView.h (174829 => 174830)
--- trunk/Source/WebKit/win/WebView.h 2014-10-17 19:21:01 UTC (rev 174829)
+++ trunk/Source/WebKit/win/WebView.h 2014-10-17 19:50:09 UTC (rev 174830)
@@ -67,6 +67,9 @@
class WebFrame;
class WebInspector;
class WebInspectorClient;
+#if USE(TEXTURE_MAPPER_GL)
+class AcceleratedCompositingContext;
+#endif
WebView* kit(WebCore::Page*);
WebCore::Page* core(IWebView*);
@@ -1136,8 +1139,10 @@
void setAcceleratedCompositing(bool);
#if USE(CA)
RefPtr<WebCore::CACFLayerTreeHost> m_layerTreeHost;
+ std::unique_ptr<WebCore::GraphicsLayer> m_backingLayer;
+#elif USE(TEXTURE_MAPPER_GL)
+ std::unique_ptr<AcceleratedCompositingContext> m_acceleratedCompositingContext;
#endif
- std::unique_ptr<WebCore::GraphicsLayer> m_backingLayer;
bool m_isAcceleratedCompositing;
bool m_nextDisplayIsSynchronous;