|
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 |
} |
| 86 |
|
| 87 |
~ScopedStateSaver() |
| 88 |
{ |
| 89 |
if (m_attribEnabled) |
| 90 |
::glEnableVertexAttribArray(0); |
| 91 |
|
| 92 |
::glBindBuffer(GL_ARRAY_BUFFER, m_attribBufferBinding); |
| 93 |
::glVertexAttribPointer(0, m_attribSize, m_attribType, m_attribNormalized, m_attribStride, m_attribPointer); |
| 94 |
::glActiveTexture(m_boundTexUnit); |
| 95 |
} |
| 96 |
|
| 97 |
private: |
| 98 |
GLint m_boundTexUnit; |
| 99 |
GLint m_boundProgram; |
| 100 |
GLint m_attribEnabled; |
| 101 |
GLint m_attribSize; |
| 102 |
GLint m_attribStride; |
| 103 |
GLint m_attribType; |
| 104 |
GLint m_attribNormalized; |
| 105 |
GLint m_attribBufferBinding; |
| 106 |
void* m_attribPointer; |
| 107 |
}; |
| 108 |
|
| 71 |
GLPlatformSurface::GLPlatformSurface() |
109 |
GLPlatformSurface::GLPlatformSurface() |
| 72 |
: m_restoreNeeded(true) |
110 |
: m_sharedDisplay(0) |
| 73 |
, m_fboId(0) |
|
|
| 74 |
, m_sharedDisplay(0) |
| 75 |
, m_drawable(0) |
111 |
, m_drawable(0) |
| 76 |
, m_bufferHandle(0) |
112 |
, m_bufferHandle(0) |
|
|
113 |
, m_restoreNeeded(true) |
| 77 |
{ |
114 |
{ |
| 78 |
} |
115 |
} |
| 79 |
|
116 |
|
|
Lines 111-138
void GLPlatformSurface::swapBuffers()
Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec3
|
| 111 |
notImplemented(); |
148 |
notImplemented(); |
| 112 |
} |
149 |
} |
| 113 |
|
150 |
|
| 114 |
void GLPlatformSurface::updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture) |
151 |
void GLPlatformSurface::updateContents(const uint32_t texture, const IntSize& textureSize, const GLuint bindFboId, const uint32_t bindTexture) |
| 115 |
{ |
152 |
{ |
| 116 |
if (!m_fboId) |
153 |
if (!m_textureBlitter) { |
| 117 |
glGenFramebuffers(1, &m_fboId); |
154 |
m_textureBlitter = TextureMapperGL::create(); |
|
|
155 |
m_flags = TextureMapperGL::ShouldFlipTexture; |
| 156 |
} |
| 118 |
|
157 |
|
| 119 |
m_restoreNeeded = false; |
158 |
m_restoreNeeded = false; |
| 120 |
|
159 |
|
| 121 |
int x = 0; |
160 |
// Save any current bound vertex array to restore after updating surface with texture content. |
| 122 |
int y = 0; |
161 |
// This is needed as TextureMapperGL doesn't track and restore current bound vertex array. |
| 123 |
int width = m_rect.width(); |
162 |
ScopedStateSaver stateSaver; |
| 124 |
int height = m_rect.height(); |
163 |
::glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 125 |
|
164 |
::glColorMask(true, true, true, true); |
| 126 |
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fboId); |
165 |
m_textureBlitter->beginPainting(); |
| 127 |
glBindTexture(GL_TEXTURE_2D, texture); |
166 |
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); |
167 |
m_textureBlitter->endPainting(); |
| 129 |
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); |
168 |
|
| 130 |
// Use NEAREST as no scale is performed during the blit. |
169 |
::glFlush(); |
| 131 |
glBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
|
|
| 132 |
swapBuffers(); |
170 |
swapBuffers(); |
| 133 |
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); |
171 |
::glBindTexture(GL_TEXTURE_2D, bindTexture); |
| 134 |
glBindTexture(GL_TEXTURE_2D, bindTexture); |
172 |
::glBindFramebuffer(GL_FRAMEBUFFER, bindFboId); |
| 135 |
glBindFramebuffer(GL_FRAMEBUFFER, bindFboId); |
|
|
| 136 |
} |
173 |
} |
| 137 |
|
174 |
|
| 138 |
void GLPlatformSurface::setGeometry(const IntRect& newRect) |
175 |
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() |
180 |
void GLPlatformSurface::destroy() |
| 144 |
{ |
181 |
{ |
| 145 |
m_rect = IntRect(); |
182 |
m_rect = IntRect(); |
| 146 |
|
|
|
| 147 |
if (m_fboId) |
| 148 |
glDeleteFramebuffers(1, &m_fboId); |
| 149 |
|
| 150 |
m_fboId = 0; |
| 151 |
} |
183 |
} |
| 152 |
|
184 |
|
| 153 |
} |
185 |
} |