Skip to content

Commit bd90673

Browse files
committed
Ensure that a single composition happens for each acc canvas or WebGL frame.
Rendering a new WebGL or accelerated canvas frame can request two compositions, one due to the layerFlush and another one because of the new buffer pushed to the proxies. This can cause problems to apps relying on rAF. This commit disables the composition request that comes from pushing a new buffer from WebGL or the acc canvas, and ensures that the only composition request comes from the layerFlush.
1 parent 8a6a015 commit bd90673

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

Source/WebCore/platform/graphics/cairo/ImageBufferCairoGLSurfaceBackend.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,8 @@ void ImageBufferCairoGLSurfaceBackend::swapBuffersIfNeeded()
223223
auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy();
224224
ASSERT(is<TextureMapperPlatformLayerProxyGL>(proxy));
225225

226-
if (proxy.isEmpty()) {
227-
Locker locker { proxy.lock() };
228-
downcast<TextureMapperPlatformLayerProxyGL>(proxy).pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_textures[1], backendSize, TextureMapperGL::ShouldBlend, GL_RGBA));
229-
}
226+
Locker locker { proxy.lock() };
227+
downcast<TextureMapperPlatformLayerProxyGL>(proxy).pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_textures[1], backendSize, TextureMapperGL::ShouldBlend, GL_RGBA), false);
230228
}
231229

232230
if (previousActiveContext)

Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void GCGLLayer::swapBuffersIfNeeded()
132132
auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy();
133133
Locker locker { proxy.lock() };
134134
ASSERT(is<TextureMapperPlatformLayerProxyGL>(proxy));
135-
downcast<TextureMapperPlatformLayerProxyGL>(proxy).pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat));
135+
downcast<TextureMapperPlatformLayerProxyGL>(proxy).pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat), false);
136136
}
137137

138138
m_context.markLayerComposited();

Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyGL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void TextureMapperPlatformLayerProxyGL::invalidate()
124124
updateFunction();
125125
}
126126

127-
void TextureMapperPlatformLayerProxyGL::pushNextBuffer(std::unique_ptr<TextureMapperPlatformLayerBuffer>&& newBuffer)
127+
void TextureMapperPlatformLayerProxyGL::pushNextBuffer(std::unique_ptr<TextureMapperPlatformLayerBuffer>&& newBuffer, bool requestComposition)
128128
{
129129
ASSERT(m_lock.isHeld());
130130
#if USE(ANGLE)
@@ -136,7 +136,7 @@ void TextureMapperPlatformLayerProxyGL::pushNextBuffer(std::unique_ptr<TextureMa
136136
m_pendingBuffer = WTFMove(newBuffer);
137137
m_wasBufferDropped = false;
138138

139-
if (m_compositor)
139+
if (m_compositor && requestComposition)
140140
m_compositor->onNewBufferAvailable();
141141
}
142142

Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxyGL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TextureMapperPlatformLayerProxyGL final : public TextureMapperPlatformLaye
5555
WEBCORE_EXPORT void swapBuffer() override;
5656

5757
std::unique_ptr<TextureMapperPlatformLayerBuffer> getAvailableBuffer(const IntSize&, GLint internalFormat);
58-
void pushNextBuffer(std::unique_ptr<TextureMapperPlatformLayerBuffer>&&);
58+
void pushNextBuffer(std::unique_ptr<TextureMapperPlatformLayerBuffer>&&, bool = true);
5959

6060
void dropCurrentBufferWhilePreservingTexture(bool shouldWait = false);
6161

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,13 @@ void CoordinatedGraphicsLayer::updatePlatformLayer()
754754

755755
m_shouldUpdatePlatformLayer = false;
756756
#if USE(COORDINATED_GRAPHICS) && USE(NICOSIA)
757-
if (m_nicosia.contentLayer)
757+
if (m_nicosia.contentLayer) {
758+
// The call to swapBuffersIfNeeded will cause that WebGL and acc canvas push a new buffer to their proxy.
759+
// They won't request a composition with this new buffer, so we need to ensure that the composition is
760+
// triggered in case no other component does it.
758761
downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosia.contentLayer->impl()).swapBuffersIfNeeded();
762+
// m_nicosia.performLayerSync |= true;
763+
}
759764
#endif
760765
}
761766

0 commit comments

Comments
 (0)