| Differences between
and this patch
- Source/WebCore/ChangeLog +77 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2013-02-18  Kondapally Kalyan  <kalyan.kondapally@intel.com>
2
3
        [WebGL][EFL] Refactor GraphicsContext3DPrivate to add support for SharedContext.
4
        https://bugs.webkit.org/show_bug.cgi?id=109988
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Covered by existing WebGL tests.
9
10
        This patch refactors PlatformContext and GraphicsContext3DPrivate to
11
        add support for Shared Context. This would help share GL resources
12
        between transport surface and offscreen surface without having to worry
13
        about the context state. So far, we used the same drawable as transport
14
        surface and offscreen surface. After this patch we use pixmap surface as
15
        offscreen surface and use shared context to render texture content to
16
        transport surface. This would also align as to how shared surface is implemented
17
        on EFL and Qt ports.
18
19
        * platform/graphics/efl/GraphicsContext3DEfl.cpp:
20
        (WebCore::GraphicsContext3D::GraphicsContext3D):
21
        * platform/graphics/efl/GraphicsContext3DPrivate.cpp:
22
        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
23
        (WebCore):
24
        (WebCore::GraphicsContext3DPrivate::initialize):
25
        (WebCore::GraphicsContext3DPrivate::makeSharedContextCurrent):
26
        (WebCore::GraphicsContext3DPrivate::copyToGraphicsSurface):
27
        * platform/graphics/efl/GraphicsContext3DPrivate.h:
28
        (GraphicsContext3DPrivate):
29
        * platform/graphics/opengl/GLPlatformContext.cpp:
30
        (WebCore::GLPlatformContext::initialize):
31
        * platform/graphics/opengl/GLPlatformContext.h:
32
        Needed changes to take shared context into use.
33
34
        * platform/graphics/opengl/GLPlatformSurface.cpp:
35
        (WebCore::GLPlatformSurface::createOffScreenSurface):
36
        (WebCore::GLPlatformSurface::updateContents):
37
        * platform/graphics/opengl/GLPlatformSurface.h:
38
        (GLPlatformSurface):
39
        * platform/graphics/surfaces/glx/GLXConfigSelector.h:
40
        (WebCore::GLXConfigSelector::GLXConfigSelector):
41
        (WebCore::GLXConfigSelector::visualInfo):
42
        (WebCore::GLXConfigSelector::pixmapContextConfig):
43
        (GLXConfigSelector):
44
        (WebCore::GLXConfigSelector::reset):
45
        * platform/graphics/surfaces/glx/GLXContext.cpp:
46
        Added support to query configiration supporting
47
        pixmap surface.
48
49
        (WebCore::GLXOffScreenContext::initialize):
50
        * platform/graphics/surfaces/glx/GLXContext.h:
51
        (GLXOffScreenContext):
52
        * platform/graphics/surfaces/glx/GLXSurface.cpp:
53
        (WebCore::GLXTransportSurface::GLXTransportSurface):
54
        (WebCore::GLXTransportSurface::swapBuffers):
55
        (WebCore::GLXOffScreenSurface::GLXOffScreenSurface):
56
        (WebCore::GLXOffScreenSurface::~GLXOffScreenSurface):
57
        (WebCore::GLXOffScreenSurface::initialize):
58
        (WebCore::GLXOffScreenSurface::configuration):
59
        (WebCore::GLXOffScreenSurface::destroy):
60
        (WebCore::GLXOffScreenSurface::freeResources):
61
        (WebCore::GLXOffScreenSurface::setGeometry):
62
        Renamed GLXPBuffer surface as GLXOffScreenSurface.
63
64
        * platform/graphics/surfaces/glx/GLXSurface.h:
65
        (GLXTransportSurface):
66
        (GLXOffScreenSurface):
67
        * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
68
        (WebCore::GraphicsSurfacePrivate::createSurface):
69
        * platform/graphics/surfaces/glx/X11Helper.cpp:
70
        (WebCore::X11Helper::createPixmap):
71
        (WebCore):
72
        (WebCore::X11Helper::destroyPixmap):
73
        (WebCore::X11Helper::createOffScreenWindow):
74
        * platform/graphics/surfaces/glx/X11Helper.h:
75
        (X11Helper):
76
        Added functions to create and destroy pixmap.
77
1
2013-02-18  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
78
2013-02-18  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
2
79
3
        [WK2][EFL] Unified text checker implementation
80
        [WK2][EFL] Unified text checker implementation
- Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp -18 / +21 lines
Lines 34-42 namespace WebCore { Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp_sec1
34
34
35
PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, RenderStyle renderStyle)
35
PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, RenderStyle renderStyle)
36
{
36
{
37
    if (renderStyle == RenderDirectlyToHostWindow)
38
        return 0;
39
40
    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
37
    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
41
    return context->m_private ? context.release() : 0;
38
    return context->m_private ? context.release() : 0;
42
}
39
}
Lines 63-80 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp_sec2
63
    , m_multisampleFBO(0)
60
    , m_multisampleFBO(0)
64
    , m_multisampleDepthStencilBuffer(0)
61
    , m_multisampleDepthStencilBuffer(0)
65
    , m_multisampleColorBuffer(0)
62
    , m_multisampleColorBuffer(0)
66
    , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle)))
63
    , m_private(GraphicsContext3DPrivate::create(this, hostWindow))
67
{
64
{
68
    if (!m_private || !m_private->m_platformContext) {
65
    if (!m_private)
69
        m_private = nullptr;
70
        return;
66
        return;
71
    }
72
67
73
    validateAttributes();
68
    validateAttributes();
74
69
75
    if (renderStyle == RenderOffscreen) {
70
    if (renderStyle == RenderOffscreen) {
76
        // Create buffers for the canvas FBO.
71
        // Create buffers for the canvas FBO.
77
        glGenFramebuffers(/* count */ 1, &m_fbo);
72
        glGenFramebuffers(1, &m_fbo);
78
73
79
        // Create a texture to render into.
74
        // Create a texture to render into.
80
        glGenTextures(1, &m_texture);
75
        glGenTextures(1, &m_texture);
Lines 134-163 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp_sec3
134
129
135
GraphicsContext3D::~GraphicsContext3D()
130
GraphicsContext3D::~GraphicsContext3D()
136
{
131
{
137
    if (!m_private || !makeContextCurrent())
132
    if (!m_private || (m_renderStyle == RenderToCurrentGLContext) || !makeContextCurrent())
138
        return;
133
        return;
139
134
140
    glDeleteTextures(1, &m_texture);
135
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
136
    glBindTexture(GL_TEXTURE_2D, 0);
137
138
    if (m_texture)
139
        glDeleteTextures(1, &m_texture);
140
141
    if (m_fbo)
142
        glDeleteFramebuffers(1, &m_fbo);
141
143
142
    if (m_attrs.antialias) {
144
    if (m_attrs.antialias) {
143
        glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
145
        if (m_multisampleColorBuffer)
146
            glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
144
147
145
        if (m_attrs.stencil || m_attrs.depth)
148
        if (m_multisampleDepthStencilBuffer)
146
            glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
149
            glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
147
150
148
        glDeleteFramebuffers(1, &m_multisampleFBO);
151
        if (m_multisampleFBO)
152
            glDeleteFramebuffers(1, &m_multisampleFBO);
149
    } else if (m_attrs.stencil || m_attrs.depth) {
153
    } else if (m_attrs.stencil || m_attrs.depth) {
150
#if USE(OPENGL_ES_2)
154
#if USE(OPENGL_ES_2)
151
        if (m_attrs.depth)
155
        if (m_depthBuffer)
152
            glDeleteRenderbuffers(1, &m_depthBuffer);
156
            glDeleteRenderbuffers(1, &m_depthBuffer);
153
157
154
        if (m_attrs.stencil)
158
        if (m_stencilBuffer)
155
            glDeleteRenderbuffers(1, &m_stencilBuffer);
159
            glDeleteRenderbuffers(1, &m_stencilBuffer);
156
#endif
160
#endif
157
        glDeleteRenderbuffers(1, &m_depthStencilBuffer);
161
        if (m_depthStencilBuffer)
162
            glDeleteRenderbuffers(1, &m_depthStencilBuffer);
158
    }
163
    }
159
160
    m_private->releaseResources();
161
}
164
}
162
165
163
PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
166
PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
- Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp -57 / +119 lines
Lines 1-6 Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec1
1
/*
1
/*
2
    Copyright (C) 2012 Samsung Electronics
2
    Copyright (C) 2012 Samsung Electronics
3
    Copyright (C) 2012 Intel Corporation.
3
    Copyright (C) 2012 Intel Corporation. All rights reserved.
4
4
5
    This library is free software; you can redistribute it and/or
5
    This library is free software; you can redistribute it and/or
6
    modify it under the terms of the GNU Library General Public
6
    modify it under the terms of the GNU Library General Public
Lines 28-85 Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec2
28
28
29
namespace WebCore {
29
namespace WebCore {
30
30
31
GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
31
PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context, HostWindow* hostWindow)
32
{
33
    OwnPtr<GraphicsContext3DPrivate> platformLayer = adoptPtr(new GraphicsContext3DPrivate(context, hostWindow));
34
35
    if (platformLayer && platformLayer->initialize())
36
        return platformLayer.release();
37
38
    return nullptr;
39
}
40
41
GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow)
32
    : m_context(context)
42
    : m_context(context)
33
    , m_hostWindow(hostWindow)
43
    , m_hostWindow(hostWindow)
34
    , m_pendingSurfaceResize(false)
35
{
44
{
45
}
46
47
bool GraphicsContext3DPrivate::initialize()
48
{
49
    if (m_context->m_renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow)
50
        return false;
51
36
    if (m_hostWindow && m_hostWindow->platformPageClient()) {
52
    if (m_hostWindow && m_hostWindow->platformPageClient()) {
37
        // FIXME: Implement this code path for WebKit1.
53
        // FIXME: Implement this code path for WebKit1.
38
        // Get Evas object from platformPageClient and set EvasGL related members.
54
        // Get Evas object from platformPageClient and set EvasGL related members.
39
        return;
55
        return false;
40
    }
56
    }
41
57
42
    m_platformContext = GLPlatformContext::createContext(renderStyle);
58
    m_offScreenContext = GLPlatformContext::createContext(m_context->m_renderStyle);
43
    if (!m_platformContext)
59
    if (!m_offScreenContext)
44
        return;
60
        return false;
45
61
46
    if (renderStyle == GraphicsContext3D::RenderOffscreen) {
62
    if (m_context->m_renderStyle == GraphicsContext3D::RenderOffscreen) {
47
#if USE(GRAPHICS_SURFACE)
63
#if USE(GRAPHICS_SURFACE)
48
        m_platformSurface = GLPlatformSurface::createTransportSurface();
64
        m_sharedSurface = GLPlatformSurface::createTransportSurface();
49
#else
65
        if (!m_sharedSurface)
50
        m_platformSurface = GLPlatformSurface::createOffscreenSurface();
66
            return false;
67
68
        m_sharedContext = GLPlatformContext::createContext(m_context->m_renderStyle);
69
        if (!m_sharedContext)
70
            return false;
51
#endif
71
#endif
52
        if (!m_platformSurface) {
53
            m_platformContext = nullptr;
54
            return;
55
        }
56
72
57
        if (!m_platformContext->initialize(m_platformSurface.get()) || !m_platformContext->makeCurrent(m_platformSurface.get())) {
73
        m_offScreenSurface = GLPlatformSurface::createOffScreenSurface();
58
            releaseResources();
74
59
            m_platformContext = nullptr;
75
        if (!m_offScreenSurface)
60
            m_platformSurface = nullptr;
76
            return false;
77
78
        if (!m_offScreenContext->initialize(m_offScreenSurface.get()))
79
            return false;
80
61
#if USE(GRAPHICS_SURFACE)
81
#if USE(GRAPHICS_SURFACE)
62
        } else
82
        if (!m_sharedContext->initialize(m_sharedSurface.get(), m_offScreenContext->handle()))
63
            m_surfaceHandle = GraphicsSurfaceToken(m_platformSurface->handle());
83
            return false;
64
#else
84
65
        }
85
        if (!makeSharedContextCurrent())
86
            return false;
87
88
        m_surfaceHandle = GraphicsSurfaceToken(m_sharedSurface->handle());
66
#endif
89
#endif
67
    }
90
    }
91
92
    if (!makeContextCurrent())
93
        return false;
94
95
    return true;
68
}
96
}
69
97
70
GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
98
GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
71
{
99
{
100
    releaseResources();
72
}
101
}
73
102
74
void GraphicsContext3DPrivate::releaseResources()
103
void GraphicsContext3DPrivate::releaseResources()
75
{
104
{
105
    if (m_context->m_renderStyle == GraphicsContext3D::RenderToCurrentGLContext)
106
        return;
107
76
    // Release the current context and drawable only after destroying any associated gl resources.
108
    // Release the current context and drawable only after destroying any associated gl resources.
77
    if (m_platformSurface)
109
#if USE(GRAPHICS_SURFACE)
78
        m_platformSurface->destroy();
110
    if (m_sharedContext && m_sharedContext->handle() && m_sharedSurface)
111
        makeSharedContextCurrent();
112
113
    if (m_sharedSurface)
114
        m_sharedSurface->destroy();
79
115
80
    if (m_platformContext) {
116
    if (m_sharedContext) {
81
        m_platformContext->destroy();
117
        m_sharedContext->destroy();
82
        m_platformContext->releaseCurrent();
118
        m_sharedContext->releaseCurrent();
119
    }
120
#endif
121
    if (m_offScreenSurface)
122
        m_offScreenSurface->destroy();
123
124
    if (m_offScreenContext) {
125
        m_offScreenContext->destroy();
126
        m_offScreenContext->releaseCurrent();
83
    }
127
    }
84
}
128
}
85
129
Lines 96-145 void GraphicsContext3DPrivate::setContextLostCallback(PassOwnPtr<GraphicsContext Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec3
96
140
97
PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const
141
PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const
98
{
142
{
99
    return m_platformContext->handle();
143
    return m_offScreenContext->handle();
100
}
144
}
101
145
102
bool GraphicsContext3DPrivate::makeContextCurrent()
146
bool GraphicsContext3DPrivate::makeContextCurrent() const
103
{
147
{
104
    bool success = m_platformContext->makeCurrent(m_platformSurface.get());
148
    bool success = m_offScreenContext->makeCurrent(m_offScreenSurface.get());
105
149
106
    if (!m_platformContext->isValid()) {
150
    if (!m_offScreenContext->isValid()) {
107
        // FIXME: Restore context
151
        // FIXME: Restore context
108
        if (m_contextLostCallback)
152
        if (m_contextLostCallback)
109
            m_contextLostCallback->onContextLost();
153
            m_contextLostCallback->onContextLost();
110
154
111
        success = false;
155
        return false;
112
    }
156
    }
113
157
114
    return success;
158
    return success;
115
}
159
}
116
160
117
#if USE(TEXTURE_MAPPER_GL)
161
bool GraphicsContext3DPrivate::prepareBuffer() const
118
void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */)
119
{
162
{
120
    notImplemented();
163
    if (!makeContextCurrent())
121
}
164
        return false;
122
#endif
123
124
#if USE(GRAPHICS_SURFACE)
125
void GraphicsContext3DPrivate::didResizeCanvas(const IntSize& size)
126
{
127
    m_pendingSurfaceResize = true;
128
    m_size = size;
129
}
130
131
uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
132
{
133
    if (!m_platformContext || !makeContextCurrent())
134
        return 0;
135
165
136
    m_context->markLayerComposited();
166
    m_context->markLayerComposited();
137
167
138
    if (m_pendingSurfaceResize) {
139
        m_pendingSurfaceResize = false;
140
        m_platformSurface->setGeometry(IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
141
    }
142
143
    if (m_context->m_attrs.antialias) {
168
    if (m_context->m_attrs.antialias) {
144
        bool enableScissorTest = false;
169
        bool enableScissorTest = false;
145
        int width = m_context->m_currentWidth;
170
        int width = m_context->m_currentWidth;
Lines 161-168 uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec4
161
            m_context->enable(GraphicsContext3D::SCISSOR_TEST);
186
            m_context->enable(GraphicsContext3D::SCISSOR_TEST);
162
    }
187
    }
163
188
164
    m_platformSurface->updateContents(m_context->m_texture, m_context->m_boundFBO, m_context->m_boundTexture0);
189
    return true;
190
}
191
192
#if USE(TEXTURE_MAPPER_GL)
193
void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */)
194
{
195
    notImplemented();
196
}
197
#endif
198
199
#if USE(GRAPHICS_SURFACE)
200
bool GraphicsContext3DPrivate::makeSharedContextCurrent() const
201
{
202
    bool success = m_sharedContext->makeCurrent(m_sharedSurface.get());
203
204
    if (!m_sharedContext->isValid()) {
205
        // FIXME: Restore context
206
        if (m_contextLostCallback)
207
            m_contextLostCallback->onContextLost();
208
209
        success = false;
210
    }
211
212
    return success;
213
}
165
214
215
void GraphicsContext3DPrivate::didResizeCanvas(const IntSize& size)
216
{
217
    m_size = size;
218
    m_sharedSurface->setGeometry(IntRect(0, 0, m_size.width(), m_size.height()));
219
}
220
221
uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
222
{
223
    if (m_context->m_layerComposited || !prepareBuffer() || !makeSharedContextCurrent())
224
        return 0;
225
226
    m_sharedSurface->updateContents(m_context->m_texture);
227
    makeContextCurrent();
228
    glBindFramebuffer(GL_FRAMEBUFFER,  m_context->m_boundFBO);
166
    return 0;
229
    return 0;
167
}
230
}
168
231
Lines 175-181 IntSize GraphicsContext3DPrivate::platformLayerSize() const Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec5
175
{
238
{
176
    return m_size;
239
    return m_size;
177
}
240
}
178
179
#endif
241
#endif
180
242
181
} // namespace WebCore
243
} // namespace WebCore
- Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h -15 / +21 lines
Lines 1-6 Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h_sec1
1
/*
1
/*
2
    Copyright (C) 2012 Samsung Electronics
2
    Copyright (C) 2012 Samsung Electronics
3
    Copyright (C) 2012 Intel Corporation.
3
    Copyright (C) 2012 Intel Corporation. All rights reserved.
4
4
5
    This library is free software; you can redistribute it and/or
5
    This library is free software; you can redistribute it and/or
6
    modify it under the terms of the GNU Library General Public
6
    modify it under the terms of the GNU Library General Public
Lines 41-77 class GraphicsContext3DPrivate Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h_sec2
41
#endif
41
#endif
42
{
42
{
43
public:
43
public:
44
    GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle);
44
    static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*, HostWindow*);
45
    ~GraphicsContext3DPrivate();
45
    ~GraphicsContext3DPrivate();
46
46
47
    bool createSurface(PageClientEfl*, bool);
47
    bool createSurface(PageClientEfl*, bool);
48
    PlatformGraphicsContext3D platformGraphicsContext3D() const;
48
    PlatformGraphicsContext3D platformGraphicsContext3D() const;
49
    void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback>  callBack);
49
    void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback>);
50
#if USE(ACCELERATED_COMPOSITING)
51
    PlatformLayer* platformLayer() const;
52
#endif
53
#if USE(TEXTURE_MAPPER_GL)
50
#if USE(TEXTURE_MAPPER_GL)
54
    virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
51
    virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE;
55
#endif
52
#endif
56
#if USE(GRAPHICS_SURFACE)
53
#if USE(GRAPHICS_SURFACE)
57
    virtual IntSize platformLayerSize() const;
54
    virtual IntSize platformLayerSize() const OVERRIDE;
58
    virtual uint32_t copyToGraphicsSurface();
55
    virtual uint32_t copyToGraphicsSurface() OVERRIDE;
59
    virtual GraphicsSurfaceToken graphicsSurfaceToken() const;
56
    virtual GraphicsSurfaceToken graphicsSurfaceToken() const OVERRIDE;
60
    void didResizeCanvas(const IntSize&);
57
    void didResizeCanvas(const IntSize&);
61
#endif
58
#endif
62
    bool makeContextCurrent();
59
    bool makeContextCurrent() const;
60
61
private:
62
    GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*);
63
    bool initialize();
64
    bool prepareBuffer() const;
63
    void releaseResources();
65
    void releaseResources();
64
    GraphicsContext3D::Attributes m_attributes;
66
#if USE(GRAPHICS_SURFACE)
67
    bool makeSharedContextCurrent() const;
68
#endif
65
    GraphicsContext3D* m_context;
69
    GraphicsContext3D* m_context;
66
    HostWindow* m_hostWindow;
70
    HostWindow* m_hostWindow;
67
    OwnPtr<GLPlatformContext> m_platformContext;
71
    OwnPtr<GLPlatformContext> m_offScreenContext;
68
    OwnPtr<GLPlatformSurface> m_platformSurface;
72
    OwnPtr<GLPlatformSurface> m_offScreenSurface;
69
#if USE(GRAPHICS_SURFACE)
73
#if USE(GRAPHICS_SURFACE)
74
    OwnPtr<GLPlatformContext> m_sharedContext;
75
    OwnPtr<GLPlatformSurface> m_sharedSurface;
70
    GraphicsSurfaceToken m_surfaceHandle;
76
    GraphicsSurfaceToken m_surfaceHandle;
71
#endif
77
#endif
72
    OwnPtr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback;
78
    OwnPtr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback;
73
    ListHashSet<GC3Denum> m_syntheticErrors;
79
    ListHashSet<GC3Denum> m_syntheticErrors;
74
    bool m_pendingSurfaceResize;
75
    IntSize m_size;
80
    IntSize m_size;
76
};
81
};
77
82
Lines 80-82 public: Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h_sec3
80
#endif
85
#endif
81
86
82
#endif
87
#endif
88
- Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp -2 / +2 lines
Lines 207-213 bool GLPlatformContext::makeCurrent(GLPlatformSurface* surface) Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp_sec1
207
207
208
    m_currentContext = 0;
208
    m_currentContext = 0;
209
209
210
    if (!surface || (surface && !surface->handle()))
210
    if (!surface || (surface && !surface->drawable()))
211
        platformReleaseCurrent();
211
        platformReleaseCurrent();
212
    else if (platformMakeCurrent(surface))
212
    else if (platformMakeCurrent(surface))
213
        m_currentContext = this;
213
        m_currentContext = this;
Lines 262-268 bool GLPlatformContext::isCurrentContext() const Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp_sec2
262
    return true;
262
    return true;
263
}
263
}
264
264
265
bool GLPlatformContext::initialize(GLPlatformSurface*)
265
bool GLPlatformContext::initialize(GLPlatformSurface*, PlatformContext)
266
{
266
{
267
    return true;
267
    return true;
268
}
268
}
- Source/WebCore/platform/graphics/opengl/GLPlatformContext.h -1 / +1 lines
Lines 63-69 public: Source/WebCore/platform/graphics/opengl/GLPlatformContext.h_sec1
63
63
64
    virtual ~GLPlatformContext();
64
    virtual ~GLPlatformContext();
65
65
66
    virtual bool initialize(GLPlatformSurface*);
66
    virtual bool initialize(GLPlatformSurface*, PlatformContext = 0);
67
67
68
    // Makes this and surface as current context and drawable.
68
    // Makes this and surface as current context and drawable.
69
    // Calling this function with no surface is same as calling releaseCurrent.
69
    // Calling this function with no surface is same as calling releaseCurrent.
- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp -16 / +10 lines
Lines 40-51 Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec1
40
40
41
namespace WebCore {
41
namespace WebCore {
42
42
43
PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface()
43
PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface()
44
{
44
{
45
#if USE(GLX)
45
#if USE(GLX)
46
    OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXPBuffer());
46
    OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXOffScreenSurface());
47
47
48
    if (surface->handle() && surface->drawable())
48
    if (surface->drawable())
49
        return surface.release();
49
        return surface.release();
50
#endif
50
#endif
51
51
Lines 54-60 PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface() Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec2
54
54
55
PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface()
55
PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface()
56
{
56
{
57
#if USE(GRAPHICS_SURFACE)
58
#if USE(GLX)
57
#if USE(GLX)
59
    OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface());
58
    OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface());
60
#elif USE(EGL)
59
#elif USE(EGL)
Lines 63-76 PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface() Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec3
63
62
64
    if (surface && surface->handle() && surface->drawable())
63
    if (surface && surface->handle() && surface->drawable())
65
        return surface.release();
64
        return surface.release();
66
#endif
67
65
68
    return nullptr;
66
    return nullptr;
69
}
67
}
70
68
71
GLPlatformSurface::GLPlatformSurface()
69
GLPlatformSurface::GLPlatformSurface()
72
    : m_restoreNeeded(true)
70
    : m_fboId(0)
73
    , m_fboId(0)
74
    , m_sharedDisplay(0)
71
    , m_sharedDisplay(0)
75
    , m_drawable(0)
72
    , m_drawable(0)
76
    , m_bufferHandle(0)
73
    , m_bufferHandle(0)
Lines 111-123 void GLPlatformSurface::swapBuffers() Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec4
111
    notImplemented();
108
    notImplemented();
112
}
109
}
113
110
114
void GLPlatformSurface::updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture)
111
void GLPlatformSurface::updateContents(const uint32_t texture)
115
{
112
{
116
    if (!m_fboId)
113
    if (!m_fboId)
117
        glGenFramebuffers(1, &m_fboId);
114
        glGenFramebuffers(1, &m_fboId);
118
115
119
    m_restoreNeeded = false;
120
121
    int x = 0;
116
    int x = 0;
122
    int y = 0;
117
    int y = 0;
123
    int width = m_rect.width();
118
    int width = m_rect.width();
Lines 130-138 void GLPlatformSurface::updateContents(const uint32_t texture, const GLuint bind Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec5
130
    // Use NEAREST as no scale is performed during the blit.
125
    // Use NEAREST as no scale is performed during the blit.
131
    glBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
126
    glBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
132
    swapBuffers();
127
    swapBuffers();
133
    glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
134
    glBindTexture(GL_TEXTURE_2D, bindTexture);
135
    glBindFramebuffer(GL_FRAMEBUFFER, bindFboId);
136
}
128
}
137
129
138
void GLPlatformSurface::setGeometry(const IntRect& newRect)
130
void GLPlatformSurface::setGeometry(const IntRect& newRect)
Lines 144-153 void GLPlatformSurface::destroy() Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec6
144
{
136
{
145
    m_rect = IntRect();
137
    m_rect = IntRect();
146
138
147
    if (m_fboId)
139
    if (m_fboId) {
140
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
141
        glBindTexture(GL_TEXTURE_2D, 0);
148
        glDeleteFramebuffers(1, &m_fboId);
142
        glDeleteFramebuffers(1, &m_fboId);
149
143
        m_fboId = 0;
150
    m_fboId = 0;
144
    }
151
}
145
}
152
146
153
}
147
}
- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h -5 / +6 lines
Lines 42-48 class GLPlatformSurface { Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec1
42
42
43
public:
43
public:
44
    // Creates a GL surface used for offscreen rendering.
44
    // Creates a GL surface used for offscreen rendering.
45
    static PassOwnPtr<GLPlatformSurface> createOffscreenSurface();
45
    static PassOwnPtr<GLPlatformSurface> createOffScreenSurface();
46
46
47
    // Creates a GL surface used for offscreen rendering. The results can be transported
47
    // Creates a GL surface used for offscreen rendering. The results can be transported
48
    // to the UI process for display.
48
    // to the UI process for display.
Lines 53-58 public: Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec2
53
    const IntRect& geometry() const;
53
    const IntRect& geometry() const;
54
54
55
    // Get the underlying platform specific buffer handle.
55
    // Get the underlying platform specific buffer handle.
56
    // The handle will be null if surface doesn't support
57
    // buffer sharing.
56
    PlatformBufferHandle handle() const;
58
    PlatformBufferHandle handle() const;
57
59
58
    PlatformDrawable drawable() const;
60
    PlatformDrawable drawable() const;
Lines 61-72 public: Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec3
61
63
62
    virtual void swapBuffers();
64
    virtual void swapBuffers();
63
65
64
    // Convenience Function to update surface backbuffer with texture contents, restore current FBO and Texture.
66
    // Convenience Function to update surface backbuffer with texture contents.
67
    // Note that the function doesn't track or restore any GL states.
65
    // Function does the following(in order):
68
    // Function does the following(in order):
66
    // a) Blits texture contents to back buffer.
69
    // a) Blits texture contents to back buffer.
67
    // b) Calls Swap Buffers.
70
    // b) Calls Swap Buffers.
68
    // c) Sets current FBO as bindFboId.
71
    virtual void updateContents(const uint32_t texture);
69
    virtual void updateContents(const uint32_t texture, const GLuint bindFboId, const uint32_t bindTexture);
70
72
71
    virtual void setGeometry(const IntRect& newRect);
73
    virtual void setGeometry(const IntRect& newRect);
72
74
Lines 76-82 public: Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec4
76
78
77
protected:
79
protected:
78
    GLPlatformSurface();
80
    GLPlatformSurface();
79
    bool m_restoreNeeded;
80
    IntRect m_rect;
81
    IntRect m_rect;
81
    GLuint m_fboId;
82
    GLuint m_fboId;
82
    PlatformDisplay m_sharedDisplay;
83
    PlatformDisplay m_sharedDisplay;
- Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp -3 / +3 lines
Lines 67-73 EGLOffScreenContext::EGLOffScreenContext() Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp_sec1
67
{
67
{
68
}
68
}
69
69
70
bool EGLOffScreenContext::initialize(GLPlatformSurface* surface)
70
bool EGLOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext sharedContext)
71
{
71
{
72
    if (!surface)
72
    if (!surface)
73
        return false;
73
        return false;
Lines 86-92 bool EGLOffScreenContext::initialize(GLPlatformSurface* surface) Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp_sec2
86
        return false;
86
        return false;
87
87
88
    if (isRobustnessExtSupported(m_display))
88
    if (isRobustnessExtSupported(m_display))
89
        m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextRobustnessAttributes);
89
        m_contextHandle = eglCreateContext(m_display, config, sharedContext, contextRobustnessAttributes);
90
90
91
    if (m_contextHandle != EGL_NO_CONTEXT) {
91
    if (m_contextHandle != EGL_NO_CONTEXT) {
92
        // The EGL_EXT_create_context_robustness spec requires that a context created with
92
        // The EGL_EXT_create_context_robustness spec requires that a context created with
Lines 100-106 bool EGLOffScreenContext::initialize(GLPlatformSurface* surface) Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp_sec3
100
    }
100
    }
101
101
102
    if (m_contextHandle == EGL_NO_CONTEXT)
102
    if (m_contextHandle == EGL_NO_CONTEXT)
103
        m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttributes);
103
        m_contextHandle = eglCreateContext(m_display, config, sharedContext, contextAttributes);
104
104
105
    if (m_contextHandle != EGL_NO_CONTEXT)
105
    if (m_contextHandle != EGL_NO_CONTEXT)
106
        return true;
106
        return true;
- Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h -1 / +1 lines
Lines 37-43 class EGLOffScreenContext : public GLPlatformContext { Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h_sec1
37
public:
37
public:
38
    EGLOffScreenContext();
38
    EGLOffScreenContext();
39
    virtual ~EGLOffScreenContext();
39
    virtual ~EGLOffScreenContext();
40
    virtual bool initialize(GLPlatformSurface*) OVERRIDE;
40
    virtual bool initialize(GLPlatformSurface*, PlatformContext) OVERRIDE;
41
    virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
41
    virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
42
    virtual void platformReleaseCurrent() OVERRIDE;
42
    virtual void platformReleaseCurrent() OVERRIDE;
43
    virtual void destroy() OVERRIDE;
43
    virtual void destroy() OVERRIDE;
- Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h -14 / +13 lines
Lines 48-55 class GLXConfigSelector { Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h_sec1
48
48
49
public:
49
public:
50
    GLXConfigSelector()
50
    GLXConfigSelector()
51
        : m_pbufferFBConfig(0)
51
        : m_surfaceContextFBConfig(0)
52
        , m_surfaceContextFBConfig(0)
52
        , m_pixmapContextFBConfig(0)
53
    {
53
    {
54
    }
54
    }
55
55
Lines 57-90 public: Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h_sec2
57
    {
57
    {
58
    }
58
    }
59
59
60
    XVisualInfo* visualInfo()
60
    XVisualInfo* visualInfo(const GLXFBConfig& config)
61
    {
61
    {
62
        if (!surfaceContextConfig())
62
        return glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), config);
63
            return 0;
64
65
        return glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), m_surfaceContextFBConfig);
66
    }
63
    }
67
64
68
    GLXFBConfig pBufferContextConfig()
65
    GLXFBConfig pixmapContextConfig()
69
    {
66
    {
70
        if (!m_pbufferFBConfig) {
67
        if (!m_pixmapContextFBConfig) {
71
            static const int attributes[] = {
68
            static const int attributes[] = {
72
                GLX_LEVEL, 0,
69
                GLX_LEVEL, 0,
73
                GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
70
                GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
74
                GLX_RENDER_TYPE,   GLX_RGBA_BIT,
71
                GLX_RENDER_TYPE,   GLX_RGBA_BIT,
75
                GLX_RED_SIZE,      1,
72
                GLX_RED_SIZE,      1,
76
                GLX_GREEN_SIZE,    1,
73
                GLX_GREEN_SIZE,    1,
77
                GLX_BLUE_SIZE,     1,
74
                GLX_BLUE_SIZE,     1,
75
                GLX_ALPHA_SIZE,    1,
78
                GLX_DOUBLEBUFFER,  GL_FALSE,
76
                GLX_DOUBLEBUFFER,  GL_FALSE,
79
                None
77
                None
80
            };
78
            };
81
79
82
            m_pbufferFBConfig = findMatchingConfig(attributes);
80
            m_pixmapContextFBConfig = findMatchingConfig(attributes);
83
        }
81
        }
84
82
85
        return m_pbufferFBConfig;
83
        return m_pixmapContextFBConfig;
86
    }
84
    }
87
85
86
88
    GLXFBConfig surfaceContextConfig()
87
    GLXFBConfig surfaceContextConfig()
89
    {
88
    {
90
        if (!m_surfaceContextFBConfig)
89
        if (!m_surfaceContextFBConfig)
Lines 103-110 public: Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h_sec3
103
102
104
    void reset()
103
    void reset()
105
    {
104
    {
106
        m_pbufferFBConfig = 0;
107
        m_surfaceContextFBConfig = 0;
105
        m_surfaceContextFBConfig = 0;
106
        m_pixmapContextFBConfig = 0;
108
    }
107
    }
109
108
110
private:
109
private:
Lines 159-166 private: Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h_sec4
159
        return temp[0];
158
        return temp[0];
160
    }
159
    }
161
160
162
    GLXFBConfig m_pbufferFBConfig;
163
    GLXFBConfig m_surfaceContextFBConfig;
161
    GLXFBConfig m_surfaceContextFBConfig;
162
    GLXFBConfig m_pixmapContextFBConfig;
164
};
163
};
165
164
166
}
165
}
- Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp -4 / +4 lines
Lines 56-62 GLXOffScreenContext::GLXOffScreenContext() Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp_sec1
56
{
56
{
57
}
57
}
58
58
59
bool GLXOffScreenContext::initialize(GLPlatformSurface* surface)
59
bool GLXOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext sharedContext)
60
{
60
{
61
    if (!surface)
61
    if (!surface)
62
        return false;
62
        return false;
Lines 71-77 bool GLXOffScreenContext::initialize(GLPlatformSurface* surface) Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp_sec2
71
        initializeARBExtensions();
71
        initializeARBExtensions();
72
72
73
        if (glXCreateContextAttribsARB)
73
        if (glXCreateContextAttribsARB)
74
            m_contextHandle = glXCreateContextAttribsARB(x11Display, config, 0, true, Attribs);
74
            m_contextHandle = glXCreateContextAttribsARB(x11Display, config, sharedContext, true, Attribs);
75
75
76
        if (m_contextHandle) {
76
        if (m_contextHandle) {
77
            // The GLX_ARB_create_context_robustness spec requires that a context created with
77
            // The GLX_ARB_create_context_robustness spec requires that a context created with
Lines 85-91 bool GLXOffScreenContext::initialize(GLPlatformSurface* surface) Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp_sec3
85
        }
85
        }
86
86
87
        if (!m_contextHandle)
87
        if (!m_contextHandle)
88
            m_contextHandle = glXCreateNewContext(x11Display, config, GLX_RGBA_TYPE, 0, true);
88
            m_contextHandle = glXCreateNewContext(x11Display, config, GLX_RGBA_TYPE, sharedContext, true);
89
89
90
        if (m_contextHandle)
90
        if (m_contextHandle)
91
            return true;
91
            return true;
Lines 105-111 bool GLXOffScreenContext::isCurrentContext() const Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp_sec4
105
105
106
bool GLXOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface)
106
bool GLXOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface)
107
{
107
{
108
    return glXMakeCurrent(surface->sharedDisplay(), surface->handle(), m_contextHandle);
108
    return glXMakeCurrent(surface->sharedDisplay(), surface->drawable(), m_contextHandle);
109
}
109
}
110
110
111
void GLXOffScreenContext::platformReleaseCurrent()
111
void GLXOffScreenContext::platformReleaseCurrent()
- Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h -1 / +1 lines
Lines 37-43 class GLXOffScreenContext : public GLPlatformContext { Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h_sec1
37
public:
37
public:
38
    GLXOffScreenContext();
38
    GLXOffScreenContext();
39
    virtual ~GLXOffScreenContext();
39
    virtual ~GLXOffScreenContext();
40
    virtual bool initialize(GLPlatformSurface*) OVERRIDE;
40
    virtual bool initialize(GLPlatformSurface*, PlatformContext) OVERRIDE;
41
    virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
41
    virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
42
    virtual void platformReleaseCurrent() OVERRIDE;
42
    virtual void platformReleaseCurrent() OVERRIDE;
43
    virtual void destroy() OVERRIDE;
43
    virtual void destroy() OVERRIDE;
- Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp -33 / +31 lines
Lines 32-44 namespace WebCore { Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec1
32
32
33
static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, 0 };
33
static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, 0 };
34
34
35
#if USE(GRAPHICS_SURFACE)
36
GLXTransportSurface::GLXTransportSurface()
35
GLXTransportSurface::GLXTransportSurface()
37
    : GLPlatformSurface()
36
    : GLPlatformSurface()
38
{
37
{
39
    m_sharedDisplay = X11Helper::nativeDisplay();
38
    m_sharedDisplay = X11Helper::nativeDisplay();
40
    m_configSelector = adoptPtr(new GLXConfigSelector());
39
    m_configSelector = adoptPtr(new GLXConfigSelector());
41
    OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo());
40
    OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo(m_configSelector->surfaceContextConfig()));
42
41
43
    if (!visInfo.get()) {
42
    if (!visInfo.get()) {
44
        destroy();
43
        destroy();
Lines 77-90 void GLXTransportSurface::swapBuffers() Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec2
77
    if (!m_drawable)
76
    if (!m_drawable)
78
        return;
77
        return;
79
78
80
    if (m_restoreNeeded) {
79
    glXSwapBuffers(sharedDisplay(), m_drawable);
81
        GLint oldFBO;
82
        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
83
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
84
        glXSwapBuffers(sharedDisplay(), m_drawable);
85
        glBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
86
    } else
87
        glXSwapBuffers(sharedDisplay(), m_drawable);
88
}
80
}
89
81
90
void GLXTransportSurface::destroy()
82
void GLXTransportSurface::destroy()
Lines 100-166 void GLXTransportSurface::destroy() Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec3
100
    m_configSelector = nullptr;
92
    m_configSelector = nullptr;
101
}
93
}
102
94
103
#endif
95
GLXOffScreenSurface::GLXOffScreenSurface()
104
105
GLXPBuffer::GLXPBuffer()
106
    : GLPlatformSurface()
96
    : GLPlatformSurface()
97
    , m_pixmap(0)
98
    , m_glxPixmap(0)
107
{
99
{
108
    initialize();
100
    initialize();
109
}
101
}
110
102
111
GLXPBuffer::~GLXPBuffer()
103
GLXOffScreenSurface::~GLXOffScreenSurface()
112
{
104
{
113
}
105
}
114
106
115
void GLXPBuffer::initialize()
107
void GLXOffScreenSurface::initialize()
116
{
108
{
117
    m_sharedDisplay = X11Helper::nativeDisplay();
109
    m_sharedDisplay = X11Helper::nativeDisplay();
118
110
119
    m_configSelector = adoptPtr(new GLXConfigSelector());
111
    m_configSelector = adoptPtr(new GLXConfigSelector());
120
    GLXFBConfig config = m_configSelector->pBufferContextConfig();
121
112
122
    if (!config) {
113
    OwnPtrX11<XVisualInfo> visualInfo(m_configSelector->visualInfo(m_configSelector->pixmapContextConfig()));
114
    X11Helper::createPixmap(&m_pixmap, *visualInfo.get());
115
116
    if (!m_pixmap) {
123
        destroy();
117
        destroy();
124
        return;
118
        return;
125
    }
119
    }
126
120
127
    m_drawable = glXCreatePbuffer(m_sharedDisplay, config, pbufferAttributes);
121
    m_glxPixmap = glXCreateGLXPixmap(m_sharedDisplay, visualInfo.get(), m_pixmap);
128
122
129
    if (!m_drawable) {
123
    if (!m_glxPixmap) {
130
        destroy();
124
        destroy();
131
        return;
125
        return;
132
    }
126
    }
133
127
134
    m_bufferHandle = m_drawable;
128
    m_drawable = m_glxPixmap;
135
}
129
}
136
130
137
PlatformSurfaceConfig GLXPBuffer::configuration()
131
PlatformSurfaceConfig GLXOffScreenSurface::configuration()
138
{
132
{
139
    return m_configSelector->pBufferContextConfig();
133
    return m_configSelector->pixmapContextConfig();
140
}
134
}
141
135
142
void GLXPBuffer::destroy()
136
void GLXOffScreenSurface::destroy()
143
{
137
{
144
    freeResources();
138
    freeResources();
145
}
139
}
146
140
147
void GLXPBuffer::freeResources()
141
void GLXOffScreenSurface::freeResources()
148
{
142
{
149
    GLPlatformSurface::destroy();
143
    GLPlatformSurface::destroy();
150
    Display* display = sharedDisplay();
144
    Display* display = sharedDisplay();
151
145
152
    if (m_drawable && display) {
146
    if (!display)
153
        glXDestroyPbuffer(display, m_drawable);
147
        return;
154
        m_drawable = 0;
148
155
        m_bufferHandle = 0;
149
    if (m_glxPixmap) {
150
        glXDestroyGLXPixmap(display, m_glxPixmap);
151
        glXWaitGL();
152
        m_glxPixmap = 0;
156
    }
153
    }
157
154
158
    m_configSelector = nullptr;
155
    if (m_pixmap) {
159
}
156
        X11Helper::destroyPixmap(m_pixmap);
157
        m_pixmap = 0;
158
    }
160
159
161
void GLXPBuffer::setGeometry(const IntRect& newRect)
160
    m_configSelector = nullptr;
162
{
161
    m_drawable = 0;
163
    GLPlatformSurface::setGeometry(newRect);
164
}
162
}
165
163
166
}
164
}
- Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h -6 / +5 lines
Lines 34-40 Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h_sec1
34
34
35
namespace WebCore {
35
namespace WebCore {
36
36
37
#if USE(GRAPHICS_SURFACE)
38
class GLXTransportSurface : public GLPlatformSurface {
37
class GLXTransportSurface : public GLPlatformSurface {
39
38
40
public:
39
public:
Lines 49-69 private: Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h_sec2
49
    void initialize();
48
    void initialize();
50
    OwnPtr<GLXConfigSelector> m_configSelector;
49
    OwnPtr<GLXConfigSelector> m_configSelector;
51
};
50
};
52
#endif
53
51
54
class GLXPBuffer : public GLPlatformSurface {
52
class GLXOffScreenSurface : public GLPlatformSurface {
55
53
56
public:
54
public:
57
    GLXPBuffer();
55
    GLXOffScreenSurface();
58
    virtual ~GLXPBuffer();
56
    virtual ~GLXOffScreenSurface();
59
    virtual PlatformSurfaceConfig configuration() OVERRIDE;
57
    virtual PlatformSurfaceConfig configuration() OVERRIDE;
60
    virtual void setGeometry(const IntRect&) OVERRIDE;
61
    virtual void destroy() OVERRIDE;
58
    virtual void destroy() OVERRIDE;
62
59
63
private:
60
private:
64
    void initialize();
61
    void initialize();
65
    void freeResources();
62
    void freeResources();
66
    OwnPtr<GLXConfigSelector> m_configSelector;
63
    OwnPtr<GLXConfigSelector> m_configSelector;
64
    Pixmap m_pixmap;
65
    GLXPixmap m_glxPixmap;
67
};
66
};
68
67
69
}
68
}
- Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp -2 / +3 lines
Lines 123-129 struct GraphicsSurfacePrivate { Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp_sec1
123
        if (!display() || !m_configSelector)
123
        if (!display() || !m_configSelector)
124
            return 0;
124
            return 0;
125
125
126
        OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo());
126
        GLXFBConfig config = m_configSelector->surfaceContextConfig();
127
        OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo(config));
127
128
128
        if (!visInfo.get()) {
129
        if (!visInfo.get()) {
129
            clear();
130
            clear();
Lines 137-143 struct GraphicsSurfacePrivate { Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp_sec2
137
            return 0;
138
            return 0;
138
        }
139
        }
139
140
140
        m_glxSurface = glXCreateWindow(display(), m_configSelector->surfaceContextConfig(), m_surface, 0);
141
        m_glxSurface = glXCreateWindow(display(), config, m_surface, 0);
141
        return m_surface;
142
        return m_surface;
142
    }
143
    }
143
144
- Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp -2 / +42 lines
Lines 140-145 void X11Helper::resizeWindow(const IntRect& newRect, const uint32_t windowId) Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp_sec1
140
    XFlush(nativeDisplay());
140
    XFlush(nativeDisplay());
141
}
141
}
142
142
143
void X11Helper::createPixmap(Pixmap* handleId, const XVisualInfo& visualInfo, const IntSize& size)
144
{
145
    Display* display = nativeDisplay();
146
    if (!display)
147
        return;
148
149
    if (!visualInfo.visual) {
150
        LOG_ERROR("Failed to find valid XVisual.");
151
        return;
152
    }
153
154
    Window xWindow = offscreenRootWindow();
155
    if (!xWindow) {
156
        LOG_ERROR("Failed to create offscreen root window.");
157
        return;
158
    }
159
160
    Pixmap tempHandleId = XCreatePixmap(display, xWindow, size.width(), size.height(), visualInfo.depth);
161
162
    if (!tempHandleId) {
163
        LOG_ERROR("Failed to create offscreen pixmap.");
164
        return;
165
    }
166
167
    *handleId = tempHandleId;
168
    XSync(X11Helper::nativeDisplay(), false);
169
}
170
171
void X11Helper::destroyPixmap(const uint32_t pixmapId)
172
{
173
    if (!pixmapId)
174
        return;
175
176
    Display* display = nativeDisplay();
177
    if (!display)
178
        return;
179
180
    XFreePixmap(display, pixmapId);
181
    XSync(X11Helper::nativeDisplay(), false);
182
}
183
143
void X11Helper::createOffScreenWindow(uint32_t* handleId, const XVisualInfo& visInfo, const IntSize& size)
184
void X11Helper::createOffScreenWindow(uint32_t* handleId, const XVisualInfo& visInfo, const IntSize& size)
144
{
185
{
145
#if USE(GRAPHICS_SURFACE)
186
#if USE(GRAPHICS_SURFACE)
Lines 162-169 void X11Helper::createOffScreenWindow(uint32_t* handleId, const XVisualInfo& vis Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp_sec2
162
    attribute.border_pixel = BlackPixel(display, 0);
203
    attribute.border_pixel = BlackPixel(display, 0);
163
    attribute.colormap = cmap;
204
    attribute.colormap = cmap;
164
    attribute.event_mask = ResizeRedirectMask;
205
    attribute.event_mask = ResizeRedirectMask;
165
    uint32_t tempHandleId;
206
    uint32_t tempHandleId = XCreateWindow(display, xWindow, 0, 0, size.width(), size.height(), 0, visInfo.depth, InputOutput, visInfo.visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
166
    tempHandleId = XCreateWindow(display, xWindow, 0, 0, size.width(), size.height(), 0, visInfo.depth, InputOutput, visInfo.visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
167
207
168
    if (!tempHandleId) {
208
    if (!tempHandleId) {
169
        LOG_ERROR("Failed to create offscreen window.");
209
        LOG_ERROR("Failed to create offscreen window.");
- Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h +2 lines
Lines 46-56 namespace WebCore { Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h_sec1
46
class X11Helper {
46
class X11Helper {
47
47
48
public:
48
public:
49
    static void createPixmap(Pixmap*, const XVisualInfo&, const IntSize& = IntSize(1, 1));
49
    static void createOffScreenWindow(uint32_t*, const XVisualInfo&, const IntSize& = IntSize(1, 1));
50
    static void createOffScreenWindow(uint32_t*, const XVisualInfo&, const IntSize& = IntSize(1, 1));
50
#if USE(EGL)
51
#if USE(EGL)
51
    static void createOffScreenWindow(uint32_t*, const EGLint, const IntSize& = IntSize(1, 1));
52
    static void createOffScreenWindow(uint32_t*, const EGLint, const IntSize& = IntSize(1, 1));
52
#endif
53
#endif
53
    static void destroyWindow(const uint32_t);
54
    static void destroyWindow(const uint32_t);
55
    static void destroyPixmap(const uint32_t);
54
    static void resizeWindow(const IntRect&, const uint32_t);
56
    static void resizeWindow(const IntRect&, const uint32_t);
55
    static bool isXRenderExtensionSupported();
57
    static bool isXRenderExtensionSupported();
56
    static Display* nativeDisplay();
58
    static Display* nativeDisplay();

Return to Bug 109988