Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[offscreenCanvas] Take WebGL's rendered textures directly to … #1467

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Source/WebCore/html/OffscreenCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ void OffscreenCanvas::createContextWebGL(RenderingContextType contextType, WebGL
UNUSED_PARAM(contextType);
#endif
m_context = WebGLRenderingContextBase::create(*this, attrs, webGLVersion);
m_placeholderData->bufferPipeSource->setGraphicsContextGL(static_cast<WebGLRenderingContextBase*>(m_context.get())->graphicsContextGL());
}

#endif // ENABLE(WEBGL)
Expand Down Expand Up @@ -449,10 +448,8 @@ void OffscreenCanvas::commitToPlaceholderCanvas()

// FIXME: Transfer texture over if we're using accelerated compositing
if (m_context && (m_context->isWebGL() || m_context->isAccelerated())) {
m_context->prepareForDisplayWithSwapBuffers();
m_placeholderData->bufferPipeSource->swapBuffers();
m_context->prepareForDisplayWithPaint();
m_context->paintRenderingResultsToCanvas();
return;
}

if (m_placeholderData->bufferPipeSource) {
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/html/canvas/CanvasRenderingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class CanvasRenderingContext : public ScriptWrappable, public CanMakeWeakPtr<Can
// Called before paintRenderingResultsToCanvas if paintRenderingResultsToCanvas is
// used for compositing purposes.
virtual void prepareForDisplayWithPaint() { }
virtual void prepareForDisplayWithSwapBuffers() { }
virtual void paintRenderingResultsToCanvas() { }
virtual RefPtr<GraphicsLayerContentsDisplayDelegate> layerContentsDisplayDelegate();

Expand Down
11 changes: 0 additions & 11 deletions Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,22 +1455,11 @@ void WebGLRenderingContextBase::prepareForDisplayWithPaint()
m_isDisplayingWithPaint = true;
}

void WebGLRenderingContextBase::prepareForDisplayWithSwapBuffers()
{
m_isDisplayingWithSwapBuffers = true;
}

void WebGLRenderingContextBase::paintRenderingResultsToCanvas()
{
if (isContextLostOrPending())
return;

if (m_isDisplayingWithSwapBuffers) {
m_isDisplayingWithSwapBuffers = false;
m_markedCanvasDirty = false;
return;
}

if (m_isDisplayingWithPaint) {
bool canvasContainsDisplayBuffer = !m_markedCanvasDirty;
prepareForDisplay();
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ class WebGLRenderingContextBase : public GraphicsContextGL::Client, public GPUBa
void reshape(int width, int height) override;

void prepareForDisplayWithPaint() final;
void prepareForDisplayWithSwapBuffers() final;
void paintRenderingResultsToCanvas() final;
RefPtr<PixelBuffer> paintRenderingResultsToPixelBuffer();
#if ENABLE(MEDIA_STREAM)
Expand Down Expand Up @@ -748,7 +747,6 @@ class WebGLRenderingContextBase : public GraphicsContextGL::Client, public GPUBa

bool m_compositingResultsNeedUpdating { false };
bool m_isDisplayingWithPaint { false };
bool m_isDisplayingWithSwapBuffers { false };

// Enabled extension objects.
// FIXME: Move some of these to WebGLRenderingContext, the ones not needed for WebGL2
Expand Down
3 changes: 0 additions & 3 deletions Source/WebCore/platform/graphics/ImageBufferPipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
namespace WebCore {

class ImageBuffer;
class GraphicsContextGL;

// Used to provide GraphicsLayer contents for an externally managed ImageBuffer; e.g. an ImageBuffer created and owned by a Worker thread
class ImageBufferPipe : public RefCounted<ImageBufferPipe> {
Expand All @@ -44,8 +43,6 @@ class ImageBufferPipe : public RefCounted<ImageBufferPipe> {
virtual ~Source() = default;

virtual void handle(RefPtr<ImageBuffer>&&) = 0;
virtual void swapBuffers() = 0;
virtual void setGraphicsContextGL(GraphicsContextGL*) = 0;
};

static RefPtr<ImageBufferPipe> create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,36 +104,6 @@ void NicosiaImageBufferPipeSource::handle(RefPtr<ImageBuffer>&& buffer)
m_imageBuffer = WTFMove(buffer);
}

void NicosiaImageBufferPipeSource::swapBuffers()
{
if (!m_context)
return;

if (m_context->layerComposited())
return;

m_context->prepareTexture();
IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);

TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture;
if (m_context->contextAttributes().alpha)
flags |= TextureMapperGL::ShouldBlend;

{
auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy();
Locker locker { proxy.lock() };
ASSERT(is<TextureMapperPlatformLayerProxyGL>(proxy));
downcast<TextureMapperPlatformLayerProxyGL>(proxy).pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_context->m_compositorTexture, textureSize, flags, m_context->m_internalColorFormat));
}

m_context->markLayerComposited();
}

void NicosiaImageBufferPipeSource::setGraphicsContextGL(GraphicsContextGL* context)
{
m_context = static_cast<GraphicsContextGLOpenGL*>(context);
}

void NicosiaImageBufferPipeSource::swapBuffersIfNeeded()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#pragma once

#include "GraphicsContextGLOpenGL.h"
#include "ImageBufferPipe.h"
#include "NicosiaContentLayerTextureMapperImpl.h"

Expand Down Expand Up @@ -57,8 +56,6 @@ class NicosiaImageBufferPipeSource : public WebCore::ImageBufferPipe::Source, pu

// ImageBufferPipe::Source overrides.
void handle(RefPtr<WebCore::ImageBuffer>&&) final;
void swapBuffers() final;
void setGraphicsContextGL(WebCore::GraphicsContextGL*) final;

// ContentLayerTextureMapperImpl::Client overrides.
void swapBuffersIfNeeded() override;
Expand All @@ -69,7 +66,6 @@ class NicosiaImageBufferPipeSource : public WebCore::ImageBufferPipe::Source, pu

mutable Lock m_imageBufferLock;
RefPtr<WebCore::ImageBuffer> m_imageBuffer;
WebCore::GraphicsContextGLOpenGL* m_context;
};

class NicosiaImageBufferPipe final : public WebCore::ImageBufferPipe {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#if USE(NICOSIA)
namespace Nicosia {
class GCGLLayer;
class NicosiaImageBufferPipeSource;
}
#endif

Expand Down Expand Up @@ -575,7 +574,6 @@ class WEBCORE_EXPORT GraphicsContextGLOpenGL : public GraphicsContextGL

#if USE(NICOSIA)
friend class Nicosia::GCGLLayer;
friend class Nicosia::NicosiaImageBufferPipeSource;
std::unique_ptr<Nicosia::GCGLLayer> m_nicosiaLayer;
#elif USE(TEXTURE_MAPPER)
friend class TextureMapperGCGLPlatformLayer;
Expand Down