| Differences between
and this patch
- Source/WebCore/ChangeLog +25 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2013-02-10  Kondapally Kalyan  <kalyan.kondapally@intel.com>
2
3
        [EFL] [WebGL] Add support for bliting texture contents to FBO.
4
        https://bugs.webkit.org/show_bug.cgi?id=106508
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Covered by existing WebGL tests.
9
10
        We currently rely on EXT_framebuffer_blit to blit texture contents to the surface.
11
        This extension is not exposed on GLES2.0. This patch address this by making use
12
        of TextureMapperGL to draw texture contents to the surface on both GL and GLES.
13
14
        * platform/graphics/opengl/GLPlatformSurface.cpp:
15
        (ScopedStateSaver):
16
        (WebCore::ScopedStateSaver::ScopedStateSaver):
17
        (WebCore::ScopedStateSaver::~ScopedStateSaver):
18
        (WebCore):
19
        Used to save and restore current bound Array Buffer.
20
        (WebCore::GLPlatformSurface::GLPlatformSurface):
21
        (WebCore::GLPlatformSurface::updateContents):
22
        (WebCore::GLPlatformSurface::destroy):
23
        * platform/graphics/opengl/GLPlatformSurface.h:
24
        (GLPlatformSurface):
25
1
2013-02-10  Andreas Kling  <akling@apple.com>
26
2013-02-10  Andreas Kling  <akling@apple.com>
2
27
3
        RenderStyle should use copy-on-write inheritance for NinePieceImage.
28
        RenderStyle should use copy-on-write inheritance for NinePieceImage.
- Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp -3 / +4 lines
Lines 140-149 uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec1
140
        m_platformSurface->setGeometry(IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
140
        m_platformSurface->setGeometry(IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
141
    }
141
    }
142
142
143
    int width = m_context->m_currentWidth;
144
    int height = m_context->m_currentHeight;
145
143
    if (m_context->m_attrs.antialias) {
146
    if (m_context->m_attrs.antialias) {
144
        bool enableScissorTest = false;
147
        bool enableScissorTest = false;
145
        int width = m_context->m_currentWidth;
146
        int height = m_context->m_currentHeight;
147
        // We should copy the full buffer, and not respect the current scissor bounds.
148
        // We should copy the full buffer, and not respect the current scissor bounds.
148
        // FIXME: It would be more efficient to track the state of the scissor test.
149
        // FIXME: It would be more efficient to track the state of the scissor test.
149
        if (m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST)) {
150
        if (m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST)) {
Lines 161-167 uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec2
161
            m_context->enable(GraphicsContext3D::SCISSOR_TEST);
162
            m_context->enable(GraphicsContext3D::SCISSOR_TEST);
162
    }
163
    }
163
164
164
    m_platformSurface->updateContents(m_context->m_texture, m_context->m_boundFBO, m_context->m_boundTexture0);
165
    m_platformSurface->updateContents(m_context->m_texture, IntSize(width, height), m_context->m_boundFBO, m_context->m_boundTexture0);
165
166
166
    return 0;
167
    return 0;
167
}
168
}
- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp -26 / +58 lines
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
}
- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h -4 / +7 lines
Lines 30-35 Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec1
30
30
31
#include "GLDefs.h"
31
#include "GLDefs.h"
32
#include "IntRect.h"
32
#include "IntRect.h"
33
#include <texmap/TextureMapperGL.h>
33
#include <wtf/Noncopyable.h>
34
#include <wtf/Noncopyable.h>
34
#include <wtf/PassOwnPtr.h>
35
#include <wtf/PassOwnPtr.h>
35
36
Lines 66-72 public: Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec2
66
    // a) Blits texture contents to back buffer.
67
    // a) Blits texture contents to back buffer.
67
    // b) Calls Swap Buffers.
68
    // b) Calls Swap Buffers.
68
    // c) Sets current FBO as bindFboId.
69
    // c) Sets current FBO as bindFboId.
69
    virtual void updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture);
70
    virtual void updateContents(const uint32_t texture, const IntSize&, const GLuint bindFboId, const uint32_t bindTexture);
70
71
71
    virtual void setGeometry(const IntRect& newRect);
72
    virtual void setGeometry(const IntRect& newRect);
72
73
Lines 76-87 public: Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec3
76
77
77
protected:
78
protected:
78
    GLPlatformSurface();
79
    GLPlatformSurface();
79
    bool m_restoreNeeded;
80
    IntRect m_rect;
81
    GLuint m_fboId;
82
    PlatformDisplay m_sharedDisplay;
80
    PlatformDisplay m_sharedDisplay;
83
    PlatformDrawable m_drawable;
81
    PlatformDrawable m_drawable;
84
    PlatformBufferHandle m_bufferHandle;
82
    PlatformBufferHandle m_bufferHandle;
83
    OwnPtr<TextureMapperGL> m_textureBlitter;
84
    bool m_restoreNeeded :1;
85
    IntRect m_rect;
86
    TransformationMatrix m_identityMatrix;
87
    TextureMapperGL::Flags m_flags;
85
};
88
};
86
89
87
}
90
}

Return to Bug 106508