Changeset 126635 in webkit


Ignore:
Timestamp:
Aug 24, 2012 3:30:16 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Texmap] Move TextureMapperGL to use GraphicsContext3D
https://bugs.webkit.org/show_bug.cgi?id=78672

Patch by Helder Correia <Helder Correia>, Roland Takacs <rtakacs@inf.u-szeged.hu> on 2012-08-24
Reviewed by Noam Rosenthal.

This is part of a several patch-refactoring.

Introduce additional logic in GraphicsContext3DQt to support a
new RenderToCurrentGLContext RenderStyle. This is necessary to
use GC3D for other things than WebGL, like TextureMapper.

The GC3D constructor now accepts a RenderStyle instead of the
boolean renderDirectlyToHostWindow and thus mimics create()'s
signature. This has been changed for all ports in this patch.

A new GC3D::createForCurrentGLContext() builder was
introduced to better abstract the goal of using GC3D with the
current context.

The patch was originally developed by Helder Correia and finished
by Roland Takacs.

No new tests, refactoring.

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126631 r126635  
     12012-08-24  Helder Correia  <helder.correia@nokia.com>, Roland Takacs  <rtakacs@inf.u-szeged.hu>
     2
     3        [Texmap] Move TextureMapperGL to use GraphicsContext3D
     4        https://bugs.webkit.org/show_bug.cgi?id=78672
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        This is part of a several patch-refactoring.
     9
     10        Introduce additional logic in GraphicsContext3DQt to support a
     11        new RenderToCurrentGLContext RenderStyle. This is necessary to
     12        use GC3D for other things than WebGL, like TextureMapper.
     13
     14        The GC3D constructor now accepts a RenderStyle instead of the
     15        boolean renderDirectlyToHostWindow and thus mimics create()'s
     16        signature. This has been changed for all ports in this patch.
     17
     18        A new GC3D::createForCurrentGLContext() builder was
     19        introduced to better abstract the goal of using GC3D with the
     20        current context.
     21
     22        The patch was originally developed by Helder Correia and finished
     23        by Roland Takacs.
     24
     25        No new tests, refactoring.
     26
    1272012-08-24  Sheriff Bot  <webkit.review.bot@gmail.com>
    228
  • trunk/Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp

    r121268 r126635  
    4444namespace WebCore {
    4545
    46 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, bool)
     46GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle)
    4747{
    4848}
  • trunk/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp

    r121268 r126635  
    7878PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, bool preserveDrawingBuffer)
    7979{
    80     RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0, false /* onscreen */));
     80    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0));
    8181
    8282    OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer));
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h

    r125690 r126635  
    459459    enum RenderStyle {
    460460        RenderOffscreen,
    461         RenderDirectlyToHostWindow
     461        RenderDirectlyToHostWindow,
     462        RenderToCurrentGLContext
    462463    };
    463464
     
    478479
    479480    static PassRefPtr<GraphicsContext3D> create(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
     481    static PassRefPtr<GraphicsContext3D> createForCurrentGLContext();
    480482    ~GraphicsContext3D();
    481483
     
    868870
    869871  private:
    870     GraphicsContext3D(Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow);
     872    GraphicsContext3D(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
    871873
    872874    // Each platform must provide an implementation of this method.
     
    983985
    984986    Attributes m_attrs;
     987    RenderStyle m_renderStyle;
    985988    Vector<Vector<float> > m_vertexArray;
    986989
  • trunk/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp

    r125563 r126635  
    4848        return 0;
    4949
    50     return adoptRef(new GraphicsContext3D(attribs, hostWindow, false));
    51 }
    52 
    53 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow*, bool renderDirectlyToHostWindow)
     50    return adoptRef(new GraphicsContext3D(attribs, hostWindow, renderStyle));
     51}
     52
     53GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle)
    5454    : m_currentWidth(0)
    5555    , m_currentHeight(0)
     
    6868    , m_isImaginationHardware(0)
    6969{
    70     if (!renderDirectlyToHostWindow) {
     70    if (renderStyle != RenderDirectlyToHostWindow) {
    7171#if USE(ACCELERATED_COMPOSITING)
    7272        m_compositingLayer = WebGLLayerWebKitThread::create();
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp

    r125203 r126635  
    6262        return 0;
    6363
    64     RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false));
     64    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle));
    6565    return context.release();
    6666}
    6767
    68 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, bool)
     68GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle)
    6969    : m_currentWidth(0)
    7070    , m_currentHeight(0)
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp

    r122250 r126635  
    4343PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
    4444{
    45     RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false));
     45    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle));
    4646    return context.release();
    4747}
    4848
    49 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool)
     49GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
    5050{
    5151    notImplemented();
  • trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp

    r122958 r126635  
    3737        return 0;
    3838
    39     RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderDirectlyToEvasGLObject));
     39    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
    4040    context->m_private = internal.release();
    4141    return context.release();
    4242}
    4343
    44 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
     44GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
    4545    : m_currentWidth(0)
    4646    , m_currentHeight(0)
  • trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm

    r126477 r126635  
    9393    if (renderStyle == RenderDirectlyToHostWindow)
    9494        return 0;
    95     RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false));
     95    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
    9696    return context->m_contextObj ? context.release() : 0;
    9797}
    9898
    99 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool)
     99GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
    100100    : m_currentWidth(0)
    101101    , m_currentHeight(0)
     
    117117{
    118118    UNUSED_PARAM(hostWindow);
     119    UNUSED_PARAM(renderStyle);
    119120
    120121    Vector<CGLPixelFormatAttribute> attribs;
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

    r125617 r126635  
    7171namespace WebCore {
    7272
     73PassRefPtr<GraphicsContext3D> GraphicsContext3D::createForCurrentGLContext()
     74{
     75    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(Attributes(), 0, GraphicsContext3D::RenderToCurrentGLContext));
     76    return context->m_private ? context.release() : 0;
     77}
     78
    7379void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension)
    7480{
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

    r125773 r126635  
    6262{
    6363public:
    64     GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*);
     64    GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle);
    6565    ~GraphicsContext3DPrivate();
    6666
     
    7777    void blitMultisampleFramebufferAndRestoreContext() const;
    7878    bool makeCurrentIfNeeded() const;
     79    void createOffscreenBuffers();
     80    void initializeANGLE();
    7981    void createGraphicsSurfaces(const IntSize&);
    8082
     
    105107#endif
    106108
    107 GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow)
     109GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
    108110    : m_context(context)
    109111    , m_hostWindow(hostWindow)
     
    119121
    120122        makeCurrentIfNeeded();
     123        return;
     124    }
     125
     126    if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext) {
     127        m_platformContext = QOpenGLContext::currentContext();
     128        m_surface = m_platformContext->surface();
    121129        return;
    122130    }
     
    146154}
    147155
     156void GraphicsContext3DPrivate::createOffscreenBuffers()
     157{
     158    glGenFramebuffers(/* count */ 1, &m_context->m_fbo);
     159
     160    glGenTextures(1, &m_context->m_texture);
     161    glBindTexture(GraphicsContext3D::TEXTURE_2D, m_context->m_texture);
     162    glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
     163    glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
     164    glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
     165    glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
     166    glBindTexture(GraphicsContext3D::TEXTURE_2D, 0);
     167
     168    // Create a multisample FBO.
     169    if (m_context->m_attrs.antialias) {
     170        glGenFramebuffers(1, &m_context->m_multisampleFBO);
     171        glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_multisampleFBO);
     172        m_context->m_boundFBO = m_context->m_multisampleFBO;
     173        glGenRenderbuffers(1, &m_context->m_multisampleColorBuffer);
     174        if (m_context->m_attrs.stencil || m_context->m_attrs.depth)
     175            glGenRenderbuffers(1, &m_context->m_multisampleDepthStencilBuffer);
     176    } else {
     177        // Bind canvas FBO.
     178        glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo);
     179        m_context->m_boundFBO = m_context->m_fbo;
     180#if USE(OPENGL_ES_2)
     181        if (m_context->m_attrs.depth)
     182            glGenRenderbuffers(1, &m_context->m_depthBuffer);
     183        if (m_context->m_attrs.stencil)
     184            glGenRenderbuffers(1, &m_context->m_stencilBuffer);
     185#endif
     186        if (m_context->m_attrs.stencil || m_context->m_attrs.depth)
     187            glGenRenderbuffers(1, &m_context->m_depthStencilBuffer);
     188    }
     189}
     190
     191void GraphicsContext3DPrivate::initializeANGLE()
     192{
     193    ShBuiltInResources ANGLEResources;
     194    ShInitBuiltInResources(&ANGLEResources);
     195
     196    m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs);
     197    m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors);
     198    m_context->getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors);
     199    m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits);
     200    m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits);
     201    m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits);
     202    m_context->getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors);
     203
     204    // Always set to 1 for OpenGL ES.
     205    ANGLEResources.MaxDrawBuffers = 1;
     206    m_context->m_compiler.setResources(ANGLEResources);
     207}
     208
    148209GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
    149210{
    150     delete m_surface;
    151     m_surface = 0;
    152     // Platform context is assumed to be owned by surface.
    153     m_platformContext = 0;
     211    if (m_hostWindow) {
     212        delete m_surface;
     213        m_surface = 0;
     214        // Platform context is assumed to be owned by surface.
     215        m_platformContext = 0;
     216    }
    154217}
    155218
     
    292355    if (renderStyle == RenderDirectlyToHostWindow)
    293356        return 0;
    294     RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false));
     357    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
    295358    return context->m_private ? context.release() : 0;
    296359}
    297360
    298 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool)
     361GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
    299362    : m_currentWidth(0)
    300363    , m_currentHeight(0)
    301364    , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
    302365    , m_attrs(attrs)
     366    , m_renderStyle(renderStyle)
    303367    , m_texture(0)
    304368    , m_compositorTexture(0)
     
    317381    , m_multisampleDepthStencilBuffer(0)
    318382    , m_multisampleColorBuffer(0)
    319     , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow)))
     383    , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle)))
    320384{
    321385    validateAttributes();
     
    338402    }
    339403
    340     // Create buffers for the canvas FBO.
    341     glGenFramebuffers(/* count */ 1, &m_fbo);
    342 
    343     glGenTextures(1, &m_texture);
    344     glBindTexture(GraphicsContext3D::TEXTURE_2D, m_texture);
    345     glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
    346     glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
    347     glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
    348     glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
    349     glBindTexture(GraphicsContext3D::TEXTURE_2D, 0);
    350 
    351     // Create a multisample FBO.
    352     if (m_attrs.antialias) {
    353         glGenFramebuffers(1, &m_multisampleFBO);
    354         glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
    355         m_boundFBO = m_multisampleFBO;
    356         glGenRenderbuffers(1, &m_multisampleColorBuffer);
    357         if (m_attrs.stencil || m_attrs.depth)
    358             glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
    359     } else {
    360         // Bind canvas FBO.
    361         glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
    362         m_boundFBO = m_fbo;
    363 #if USE(OPENGL_ES_2)
    364         if (m_attrs.depth)
    365             glGenRenderbuffers(1, &m_depthBuffer);
    366         if (m_attrs.stencil)
    367             glGenRenderbuffers(1, &m_stencilBuffer);
    368 #endif
    369         if (m_attrs.stencil || m_attrs.depth)
    370             glGenRenderbuffers(1, &m_depthStencilBuffer);
    371     }
    372 
    373     // ANGLE initialization.
    374     ShBuiltInResources ANGLEResources;
    375     ShInitBuiltInResources(&ANGLEResources);
    376 
    377     getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs);
    378     getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors);
    379     getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors);
    380     getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits);
    381     getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits);
    382     getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits);
    383     getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors);
    384 
    385     // Always set to 1 for OpenGL ES.
    386     ANGLEResources.MaxDrawBuffers = 1;
    387     m_compiler.setResources(ANGLEResources);
     404    if (renderStyle == RenderOffscreen)
     405        m_private->createOffscreenBuffers();
     406
     407    m_private->initializeANGLE();
    388408
    389409#if !USE(OPENGL_ES_2)
     
    439459bool GraphicsContext3D::makeContextCurrent()
    440460{
    441     if (!m_private)
     461    if (!m_private || m_renderStyle == RenderToCurrentGLContext)
    442462        return false;
    443463    return m_private->makeCurrentIfNeeded();
Note: See TracChangeset for help on using the changeset viewer.