WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
patch
platformsurface.patch (text/plain), 8.47 KB, created by
Kalyan
on 2013-02-09 10:13:54 PST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Kalyan
Created:
2013-02-09 10:13:54 PST
Size:
8.47 KB
patch
obsolete
>diff --git Source/WebCore/ChangeLog Source/WebCore/ChangeLog >index a293088..13debb0 100644 >--- Source/WebCore/ChangeLog >+++ Source/WebCore/ChangeLog >@@ -1,3 +1,28 @@ >+2013-02-09 Kondapally Kalyan <kalyan.kondapally@intel.com> >+ >+ [EFL] [WebGL] Add support for bliting texture contents to FBO. >+ https://bugs.webkit.org/show_bug.cgi?id=106508 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Covered by existing WebGL tests. >+ >+ We currently rely on EXT_framebuffer_blit to blit texture contents to the surface. >+ This extension is not exposed on GLES2.0. This patch address this by making use >+ of TextureMapperGL to draw texture contents to the surface on both GL and GLES. >+ >+ * platform/graphics/opengl/GLPlatformSurface.cpp: >+ (ScopedStateSaver): >+ (WebCore::ScopedStateSaver::ScopedStateSaver): >+ (WebCore::ScopedStateSaver::~ScopedStateSaver): >+ (WebCore): >+ Used to save and restore current bound Array Buffer. >+ (WebCore::GLPlatformSurface::GLPlatformSurface): >+ (WebCore::GLPlatformSurface::updateContents): >+ (WebCore::GLPlatformSurface::destroy): >+ * platform/graphics/opengl/GLPlatformSurface.h: >+ (GLPlatformSurface): >+ > 2013-02-09 Kent Tamura <tkent@chromium.org> > >diff --git Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp >index d109567..66d0117 100644 >--- Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp >+++ Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp >@@ -140,10 +140,11 @@ uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() > m_platformSurface->setGeometry(IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight)); > } > >+ int width = m_context->m_currentWidth; >+ int height = m_context->m_currentHeight; >+ > if (m_context->m_attrs.antialias) { > bool enableScissorTest = false; >- int width = m_context->m_currentWidth; >- int height = m_context->m_currentHeight; > // We should copy the full buffer, and not respect the current scissor bounds. > // FIXME: It would be more efficient to track the state of the scissor test. > if (m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST)) { >@@ -161,7 +162,7 @@ uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() > m_context->enable(GraphicsContext3D::SCISSOR_TEST); > } > >- m_platformSurface->updateContents(m_context->m_texture, m_context->m_boundFBO, m_context->m_boundTexture0); >+ m_platformSurface->updateContents(m_context->m_texture, IntSize(width, height), m_context->m_boundFBO, m_context->m_boundTexture0); > > return 0; > } >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >index 7f7a564..2c24af6 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >+++ Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp >@@ -28,7 +28,7 @@ > > #if USE(ACCELERATED_COMPOSITING) > >-#if HAVE(GLX) >+#if USE(GLX) > #include "GLXSurface.h" > #endif > >@@ -68,12 +68,53 @@ PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface() > return nullptr; > } > >+class ScopedStateSaver { >+ WTF_MAKE_NONCOPYABLE(ScopedStateSaver); >+ >+public: >+ ScopedStateSaver() >+ { >+ ::glGetIntegerv(GL_ACTIVE_TEXTURE, &m_boundTexUnit); >+ ::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &m_attribEnabled); >+ ::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_SIZE, &m_attribSize); >+ ::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &m_attribStride); >+ ::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_TYPE, &m_attribType); >+ ::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &m_attribNormalized); >+ ::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &m_attribBufferBinding); >+ ::glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &m_attribPointer); >+ ::glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &m_currentArrayBufferBinding); >+ ::glActiveTexture(GL_TEXTURE0); >+ } >+ >+ ~ScopedStateSaver() >+ { >+ if (m_attribEnabled) >+ ::glEnableVertexAttribArray(0); >+ >+ ::glBindBuffer(GL_ARRAY_BUFFER, m_attribBufferBinding); >+ ::glVertexAttribPointer(0, m_attribSize, m_attribType, m_attribNormalized, m_attribStride, m_attribPointer); >+ ::glBindBuffer(GL_ARRAY_BUFFER, m_currentArrayBufferBinding); >+ ::glActiveTexture(m_boundTexUnit); >+ } >+ >+private: >+ GLint m_boundTexUnit; >+ GLint m_boundProgram; >+ GLint m_currentArrayBufferBinding; >+ GLint m_attribEnabled; >+ GLint m_attribSize; >+ GLint m_attribStride; >+ GLint m_attribType; >+ GLint m_attribNormalized; >+ GLint m_attribBufferBinding; >+ void* m_attribPointer; >+}; >+ > GLPlatformSurface::GLPlatformSurface() >- : m_restoreNeeded(true) >- , m_fboId(0) >- , m_sharedDisplay(0) >+ : m_sharedDisplay(0) > , m_drawable(0) > , m_bufferHandle(0) >+ , m_restoreNeeded(true) > { > } > >@@ -111,28 +152,28 @@ void GLPlatformSurface::swapBuffers() > notImplemented(); > } > >-void GLPlatformSurface::updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture) >+void GLPlatformSurface::updateContents(const uint32_t texture, const IntSize& textureSize, const GLuint bindFboId, const uint32_t bindTexture) > { >- if (!m_fboId) >- glGenFramebuffers(1, &m_fboId); >+ if (!m_textureBlitter) { >+ m_textureBlitter = TextureMapperGL::create(); >+ m_flags = TextureMapperGL::ShouldFlipTexture; >+ } > > m_restoreNeeded = false; > >- int x = 0; >- int y = 0; >- int width = m_rect.width(); >- int height = m_rect.height(); >- >- glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fboId); >- glBindTexture(GL_TEXTURE_2D, texture); >- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); >- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); >- // Use NEAREST as no scale is performed during the blit. >- glBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); >+ // Save any current bound vertex array to restore after updating surface with texture content. >+ // This is needed as TextureMapperGL doesn't track and restore current bound vertex array. >+ ScopedStateSaver stateSaver; >+ ::glBindFramebuffer(GL_FRAMEBUFFER, 0); >+ >+ m_textureBlitter->beginPainting(); >+ m_textureBlitter->drawTexture(texture, m_flags, textureSize, m_rect, m_identityMatrix, 1.0, 0); >+ m_textureBlitter->endPainting(); >+ >+ ::glFlush(); > swapBuffers(); >- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); >- glBindTexture(GL_TEXTURE_2D, bindTexture); >- glBindFramebuffer(GL_FRAMEBUFFER, bindFboId); >+ ::glBindTexture(GL_TEXTURE_2D, bindTexture); >+ ::glBindFramebuffer(GL_FRAMEBUFFER, bindFboId); > } > > void GLPlatformSurface::setGeometry(const IntRect& newRect) >@@ -143,11 +184,6 @@ void GLPlatformSurface::setGeometry(const IntRect& newRect) > void GLPlatformSurface::destroy() > { > m_rect = IntRect(); >- >- if (m_fboId) >- glDeleteFramebuffers(1, &m_fboId); >- >- m_fboId = 0; > } > > } >diff --git Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >index e8db425..acc8847 100644 >--- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >+++ Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h >@@ -30,6 +30,7 @@ > > #include "GLDefs.h" > #include "IntRect.h" >+#include <texmap/TextureMapperGL.h> > #include <wtf/Noncopyable.h> > #include <wtf/PassOwnPtr.h> > >@@ -66,7 +67,7 @@ public: > // a) Blits texture contents to back buffer. > // b) Calls Swap Buffers. > // c) Sets current FBO as bindFboId. >- virtual void updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture); >+ virtual void updateContents(const uint32_t texture, const IntSize&, const GLuint bindFboId, const uint32_t bindTexture); > > virtual void setGeometry(const IntRect& newRect); > >@@ -76,12 +77,14 @@ public: > > protected: > GLPlatformSurface(); >- bool m_restoreNeeded; >- IntRect m_rect; >- GLuint m_fboId; > PlatformDisplay m_sharedDisplay; > PlatformDrawable m_drawable; > PlatformBufferHandle m_bufferHandle; >+ OwnPtr<TextureMapperGL> m_textureBlitter; >+ bool m_restoreNeeded :1; >+ IntRect m_rect; >+ TransformationMatrix m_identityMatrix; >+ TextureMapperGL::Flags m_flags; > }; > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 106508
:
182022
|
182603
|
185304
|
187316
|
187435
|
187475
|
187480
|
187483
|
187728