+2013-02-11 Viatcheslav Ostapenko <sl.ostapenko@samsung.com>
+
+ [Qt][EFL][WebGL] Minor refactoring of GraphicsSurface/GraphicsSurfaceGLX
+ https://bugs.webkit.org/show_bug.cgi?id=108686
+
+ Reviewed by Noam Rosenthal.
+
+ Remove unused platformSurface()/m_platformSurface from GraphicsSurface.
+ Move m_texture from GraphicsSurface to GLX GraphicsSurfacePrivate to match
+ Win and Mac implementations.
+
+ No new tests, refactoring only.
+
+ * platform/graphics/surfaces/GraphicsSurface.cpp:
+ (WebCore::GraphicsSurface::GraphicsSurface):
+ * platform/graphics/surfaces/GraphicsSurface.h:
+ (GraphicsSurface):
+ * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
+ (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
+ (WebCore::GraphicsSurfacePrivate::swapBuffers):
+ (WebCore::GraphicsSurfacePrivate::surface):
+ (GraphicsSurfacePrivate):
+ (WebCore::GraphicsSurfacePrivate::textureID):
+ (WebCore::GraphicsSurfacePrivate::clear):
+ (WebCore::GraphicsSurface::platformExport):
+ (WebCore::GraphicsSurface::platformGetTextureID):
+ (WebCore::GraphicsSurface::platformSwapBuffers):
+ (WebCore::GraphicsSurface::platformCreate):
+ (WebCore::GraphicsSurface::platformImport):
+ (WebCore::GraphicsSurface::platformDestroy):
+
2013-02-11 Viatcheslav Ostapenko <sl.ostapenko@samsung.com>
[EFL][WebGL] WebGL content is not painted after resizing the viewport.
, m_detachedContext(0)
, m_detachedSurface(0)
, m_isReceiver(false)
+ , m_texture(0)
{
GLXContext shareContextObject = 0;
, m_detachedContext(0)
, m_detachedSurface(0)
, m_isReceiver(true)
+ , m_texture(0)
{
m_configSelector = adoptPtr(new GLXConfigSelector());
}
void swapBuffers()
{
- // The buffers are being switched on the writing side, the reading side just reads
- // whatever texture the XWindow contains.
- if (m_isReceiver)
+ if (isReceiver()) {
+ if (isMesaGLX() && textureID()) {
+ glBindTexture(GL_TEXTURE_2D, textureID());
+ // Mesa doesn't re-bind texture to the front buffer on glXSwapBufer
+ // Manually release previous lock and rebind texture to surface to ensure frame updates.
+ pGlXReleaseTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT);
+ pGlXBindTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT, 0);
+ }
+
return;
+ }
GLXContext glContext = glXGetCurrentContext();
TextureMapperGL::Flags flags() const { return m_flags; }
+ Window surface() const { return m_surface; }
+
+ GLuint textureID() const
+ {
+ if (m_texture)
+ return m_texture;
+
+ GLXPixmap pixmap = glxPixmap();
+ if (!pixmap)
+ return 0;
+
+ GLuint texture;
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ pGlXBindTexImageEXT(display(), pixmap, GLX_FRONT_EXT, 0);
+ const_cast<GraphicsSurfacePrivate*>(this)->m_texture = texture;
+
+ return texture;
+ }
private:
void clear()
{
+ if (m_texture) {
+ pGlXReleaseTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT);
+ glDeleteTextures(1, &m_texture);
+ }
+
if (m_glxPixmap) {
glXDestroyPixmap(display(), m_glxPixmap);
m_glxPixmap = 0;
OwnPtr<GLXConfigSelector> m_configSelector;
bool m_isReceiver;
TextureMapperGL::Flags m_flags;
+ GLuint m_texture;
};
static bool resolveGLMethods()
GraphicsSurfaceToken GraphicsSurface::platformExport()
{
- return GraphicsSurfaceToken(m_platformSurface);
+ return GraphicsSurfaceToken(m_private->surface());
}
uint32_t GraphicsSurface::platformGetTextureID()
{
- if (!m_texture) {
- GLXPixmap pixmap = m_private->glxPixmap();
- if (!pixmap)
- return 0;
-
- glGenTextures(1, &m_texture);
- glBindTexture(GL_TEXTURE_2D, m_texture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- pGlXBindTexImageEXT(m_private->display(), pixmap, GLX_FRONT_EXT, 0);
- }
-
- return m_texture;
+ return m_private->textureID();
}
void GraphicsSurface::platformCopyToGLTexture(uint32_t /*target*/, uint32_t /*id*/, const IntRect& /*targetRect*/, const IntPoint& /*offset*/)
uint32_t GraphicsSurface::platformSwapBuffers()
{
- if (m_private->isReceiver()) {
- if (isMesaGLX() && platformGetTextureID()) {
- glBindTexture(GL_TEXTURE_2D, platformGetTextureID());
- // Mesa doesn't re-bind texture to the front buffer on glXSwapBufer
- // Manually release previous lock and rebind texture to surface to get frame update.
- pGlXReleaseTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT);
- pGlXBindTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT, 0);
- }
- return 0;
- }
-
m_private->swapBuffers();
return 0;
}
if (!resolveGLMethods())
return PassRefPtr<GraphicsSurface>();
- surface->m_platformSurface = surface->m_private->createSurface(size);
+ surface->m_private->createSurface(size);
return surface;
}
return PassRefPtr<GraphicsSurface>();
RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
- surface->m_platformSurface = token.frontBufferHandle;
- surface->m_private = new GraphicsSurfacePrivate(surface->m_platformSurface);
+ surface->m_private = new GraphicsSurfacePrivate(token.frontBufferHandle);
if (!resolveGLMethods())
return PassRefPtr<GraphicsSurface>();
void GraphicsSurface::platformDestroy()
{
- if (m_texture) {
- pGlXReleaseTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT);
- glDeleteTextures(1, &m_texture);
- }
-
delete m_private;
m_private = 0;
}