|
Lines 28-34
Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec1
|
| 28 |
|
28 |
|
| 29 |
#if USE(ACCELERATED_COMPOSITING) |
29 |
#if USE(ACCELERATED_COMPOSITING) |
| 30 |
|
30 |
|
| 31 |
#if HAVE(GLX) |
31 |
#if USE(GLX) |
| 32 |
#include "GLXSurface.h" |
32 |
#include "GLXSurface.h" |
| 33 |
#endif |
33 |
#endif |
| 34 |
|
34 |
|
|
Lines 68-79
PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface()
Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec2
|
| 68 |
return nullptr; |
68 |
return nullptr; |
| 69 |
} |
69 |
} |
| 70 |
|
70 |
|
|
|
71 |
class ScopedStateSaver { |
| 72 |
WTF_MAKE_NONCOPYABLE(ScopedStateSaver); |
| 73 |
|
| 74 |
public: |
| 75 |
ScopedStateSaver() |
| 76 |
{ |
| 77 |
::glGetIntegerv(GL_ACTIVE_TEXTURE, &m_boundTexUnit); |
| 78 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &m_attribEnabled); |
| 79 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_SIZE, &m_attribSize); |
| 80 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &m_attribStride); |
| 81 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_TYPE, &m_attribType); |
| 82 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &m_attribNormalized); |
| 83 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &m_attribBufferBinding); |
| 84 |
::glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &m_attribPointer); |
| 85 |
::glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &m_currentArrayBufferBinding); |
| 86 |
::glActiveTexture(GL_TEXTURE0); |
| 87 |
} |
| 88 |
|
| 89 |
~ScopedStateSaver() |
| 90 |
{ |
| 91 |
if (m_attribEnabled) |
| 92 |
::glEnableVertexAttribArray(0); |
| 93 |
|
| 94 |
::glBindBuffer(GL_ARRAY_BUFFER, m_attribBufferBinding); |
| 95 |
::glVertexAttribPointer(0, m_attribSize, m_attribType, m_attribNormalized, m_attribStride, m_attribPointer); |
| 96 |
::glBindBuffer(GL_ARRAY_BUFFER, m_currentArrayBufferBinding); |
| 97 |
::glActiveTexture(m_boundTexUnit); |
| 98 |
} |
| 99 |
|
| 100 |
private: |
| 101 |
GLint m_boundTexUnit; |
| 102 |
GLint m_boundProgram; |
| 103 |
GLint m_currentArrayBufferBinding; |
| 104 |
GLint m_attribEnabled; |
| 105 |
GLint m_attribSize; |
| 106 |
GLint m_attribStride; |
| 107 |
GLint m_attribType; |
| 108 |
GLint m_attribNormalized; |
| 109 |
GLint m_attribBufferBinding; |
| 110 |
void* m_attribPointer; |
| 111 |
}; |
| 112 |
|
| 71 |
GLPlatformSurface::GLPlatformSurface() |
113 |
GLPlatformSurface::GLPlatformSurface() |
| 72 |
: m_restoreNeeded(true) |
114 |
: m_sharedDisplay(0) |
| 73 |
, m_fboId(0) |
|
|
| 74 |
, m_sharedDisplay(0) |
| 75 |
, m_drawable(0) |
115 |
, m_drawable(0) |
| 76 |
, m_bufferHandle(0) |
116 |
, m_bufferHandle(0) |
|
|
117 |
, m_restoreNeeded(true) |
| 77 |
{ |
118 |
{ |
| 78 |
} |
119 |
} |
| 79 |
|
120 |
|
|
Lines 111-138
void GLPlatformSurface::swapBuffers()
Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec3
|
| 111 |
notImplemented(); |
152 |
notImplemented(); |
| 112 |
} |
153 |
} |
| 113 |
|
154 |
|
| 114 |
void GLPlatformSurface::updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture) |
155 |
void GLPlatformSurface::updateContents(const uint32_t texture, const IntSize& textureSize, const GLuint bindFboId, const uint32_t bindTexture) |
| 115 |
{ |
156 |
{ |
| 116 |
if (!m_fboId) |
157 |
if (!m_textureBlitter) { |
| 117 |
glGenFramebuffers(1, &m_fboId); |
158 |
m_textureBlitter = TextureMapperGL::create(); |
|
|
159 |
m_flags = TextureMapperGL::ShouldFlipTexture; |
| 160 |
} |
| 118 |
|
161 |
|
| 119 |
m_restoreNeeded = false; |
162 |
m_restoreNeeded = false; |
| 120 |
|
163 |
|
| 121 |
int x = 0; |
164 |
// Save any current bound vertex array to restore after updating surface with texture content. |
| 122 |
int y = 0; |
165 |
// This is needed as TextureMapperGL doesn't track and restore current bound vertex array. |
| 123 |
int width = m_rect.width(); |
166 |
ScopedStateSaver stateSaver; |
| 124 |
int height = m_rect.height(); |
167 |
::glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 125 |
|
168 |
|
| 126 |
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fboId); |
169 |
m_textureBlitter->beginPainting(); |
| 127 |
glBindTexture(GL_TEXTURE_2D, texture); |
170 |
m_textureBlitter->drawTexture(texture, m_flags, textureSize, m_rect, m_identityMatrix, 1.0, 0); |
| 128 |
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); |
171 |
m_textureBlitter->endPainting(); |
| 129 |
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); |
172 |
|
| 130 |
// Use NEAREST as no scale is performed during the blit. |
173 |
::glFlush(); |
| 131 |
glBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
|
|
| 132 |
swapBuffers(); |
174 |
swapBuffers(); |
| 133 |
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); |
175 |
::glBindTexture(GL_TEXTURE_2D, bindTexture); |
| 134 |
glBindTexture(GL_TEXTURE_2D, bindTexture); |
176 |
::glBindFramebuffer(GL_FRAMEBUFFER, bindFboId); |
| 135 |
glBindFramebuffer(GL_FRAMEBUFFER, bindFboId); |
|
|
| 136 |
} |
177 |
} |
| 137 |
|
178 |
|
| 138 |
void GLPlatformSurface::setGeometry(const IntRect& newRect) |
179 |
void GLPlatformSurface::setGeometry(const IntRect& newRect) |
|
Lines 143-153
void GLPlatformSurface::setGeometry(const IntRect& newRect)
Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec4
|
| 143 |
void GLPlatformSurface::destroy() |
184 |
void GLPlatformSurface::destroy() |
| 144 |
{ |
185 |
{ |
| 145 |
m_rect = IntRect(); |
186 |
m_rect = IntRect(); |
| 146 |
|
|
|
| 147 |
if (m_fboId) |
| 148 |
glDeleteFramebuffers(1, &m_fboId); |
| 149 |
|
| 150 |
m_fboId = 0; |
| 151 |
} |
187 |
} |
| 152 |
|
188 |
|
| 153 |
} |
189 |
} |