Changeset 130966 in webkit


Ignore:
Timestamp:
Oct 10, 2012 3:07:42 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL] Use the shareable GraphicsContext3DOpenGL* implementation.
https://bugs.webkit.org/show_bug.cgi?id=96627

Patch by Regina Chung <heejin.r.chung@samsung.com> on 2012-10-10
Reviewed by Kenneth Rohde Christiansen.

Changed EFL implementation of GraphicsContext3D(GC3D) to use GraphicsContext3DOpenGL*.
It was initially implemented in a different way, due to characteristics of Evas,
but it would be better to use the common implementation and find another way
to deal with Evas, especially because all the duplicated code.

No new tests. No functional changes.

  • PlatformEfl.cmake: Removed cairo implementation of GC3D and added efl files to WebCore_SOURCES.
  • platform/graphics/efl/GraphicsContext3DEfl.cpp: Modified code so GC3DOpenGL* can be used.

(WebCore::GraphicsContext3D::create):
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::platformLayer):
(WebCore::GraphicsContext3D::makeContextCurrent):
(WebCore::GraphicsContext3D::setContextLostCallback):
(WebCore::GraphicsContext3D::setErrorMessageCallback):
(WebCore::GraphicsContext3D::paintToCanvas):
(WebCore):
(WebCore::GraphicsContext3D::createGraphicsSurfaces):
(WebCore::GraphicsContext3D::releaseShaderCompiler):
(WebCore::GraphicsContext3D::getImageData):

  • platform/graphics/efl/GraphicsContext3DPrivate.cpp: Removed functions implemented in GC3DOpenGL*

(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore):
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::createSurface):
(WebCore::GraphicsContext3DPrivate::platformGraphicsContext3D):
(WebCore::GraphicsContext3DPrivate::makeContextCurrent):
(WebCore::GraphicsContext3DPrivate::isGLES2Compliant):
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper):

  • platform/graphics/efl/GraphicsContext3DPrivate.h: Removed functions implemented in GC3DOpenGL*

(GraphicsContext3DPrivate):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r130962 r130966  
     12012-10-10  Regina Chung  <heejin.r.chung@samsung.com>
     2
     3        [EFL] Use the shareable GraphicsContext3DOpenGL* implementation.
     4        https://bugs.webkit.org/show_bug.cgi?id=96627
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Changed EFL implementation of GraphicsContext3D(GC3D) to use GraphicsContext3DOpenGL*.
     9        It was initially implemented in a different way, due to characteristics of Evas,
     10        but it would be better to use the common implementation and find another way
     11        to deal with Evas, especially because all the duplicated code.
     12
     13        No new tests. No functional changes.
     14
     15        * PlatformEfl.cmake: Removed cairo implementation of GC3D and added efl files to WebCore_SOURCES.
     16        * platform/graphics/efl/GraphicsContext3DEfl.cpp: Modified code so GC3DOpenGL* can be used.
     17        (WebCore::GraphicsContext3D::create):
     18        (WebCore::GraphicsContext3D::GraphicsContext3D):
     19        (WebCore::GraphicsContext3D::platformLayer):
     20        (WebCore::GraphicsContext3D::makeContextCurrent):
     21        (WebCore::GraphicsContext3D::setContextLostCallback):
     22        (WebCore::GraphicsContext3D::setErrorMessageCallback):
     23        (WebCore::GraphicsContext3D::paintToCanvas):
     24        (WebCore):
     25        (WebCore::GraphicsContext3D::createGraphicsSurfaces):
     26        (WebCore::GraphicsContext3D::releaseShaderCompiler):
     27        (WebCore::GraphicsContext3D::getImageData):
     28        * platform/graphics/efl/GraphicsContext3DPrivate.cpp: Removed functions implemented in GC3DOpenGL*
     29        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
     30        (WebCore):
     31        (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
     32        (WebCore::GraphicsContext3DPrivate::createSurface):
     33        (WebCore::GraphicsContext3DPrivate::platformGraphicsContext3D):
     34        (WebCore::GraphicsContext3DPrivate::makeContextCurrent):
     35        (WebCore::GraphicsContext3DPrivate::isGLES2Compliant):
     36        (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
     37        * platform/graphics/efl/GraphicsContext3DPrivate.h: Removed functions implemented in GC3DOpenGL*
     38        (GraphicsContext3DPrivate):
     39
    1402012-10-10  Tony Chang  <tony@chromium.org>
    241
  • trunk/Source/WebCore/PlatformEfl.cmake

    r130613 r130966  
    290290    platform/graphics/OpenGLShims.cpp
    291291    platform/graphics/cairo/DrawingBufferCairo.cpp
    292     platform/graphics/cairo/GLContext.cpp
    293     platform/graphics/cairo/GraphicsContext3DCairo.cpp
    294     platform/graphics/cairo/GraphicsContext3DPrivate.cpp
     292    platform/graphics/efl/GraphicsContext3DEfl.cpp
     293    platform/graphics/efl/GraphicsContext3DPrivate.cpp
    295294    platform/graphics/opengl/Extensions3DOpenGL.cpp
    296295    platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
  • trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp

    r130525 r130966  
    1919
    2020#include "config.h"
     21#include "GraphicsContext3D.h"
    2122
    2223#if USE(3D_GRAPHICS) || USE(ACCELERATED_COMPOSITING)
    2324
    2425#include "GraphicsContext3DPrivate.h"
    25 
    2626#include "ImageData.h"
    2727#include "NotImplemented.h"
     28#include "OpenGLShims.h"
     29#include "PlatformContextCairo.h"
     30#include <GL/glx.h>
     31
     32#if USE(OPENGL_ES_2)
     33#include "Extensions3DOpenGLES.h"
     34#else
     35#include "Extensions3DOpenGL.h"
     36#endif
    2837
    2938namespace WebCore {
     
    3140PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, RenderStyle renderStyle)
    3241{
    33     bool renderDirectlyToEvasGLObject = (renderStyle == RenderDirectlyToHostWindow);
    34 
    35     OwnPtr<GraphicsContext3DPrivate> internal = GraphicsContext3DPrivate::create(attrs, hostWindow, renderDirectlyToEvasGLObject);
    36     if (!internal)
    37         return 0;
    38 
    3942    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
    40     context->m_private = internal.release();
    41     return context.release();
     43    return context->m_private ? context.release() : 0;
    4244}
    4345
     
    4547    : m_currentWidth(0)
    4648    , m_currentHeight(0)
    47 {
     49    , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
     50    , m_attrs(attrs)
     51    , m_texture(0)
     52    , m_compositorTexture(0)
     53    , m_fbo(0)
     54#if USE(OPENGL_ES_2)
     55    , m_depthBuffer(0)
     56    , m_stencilBuffer(0)
     57#endif
     58    , m_depthStencilBuffer(0)
     59    , m_layerComposited(false)
     60    , m_internalColorFormat(0)
     61    , m_boundFBO(0)
     62    , m_activeTexture(GL_TEXTURE0)
     63    , m_boundTexture0(0)
     64    , m_multisampleFBO(0)
     65    , m_multisampleDepthStencilBuffer(0)
     66    , m_multisampleColorBuffer(0)
     67    , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle)))
     68{
     69    validateAttributes();
     70
     71    if (!m_private)
     72        return;
     73
     74    static bool initializedShims = false;
     75    static bool success = true;
     76    if (!initializedShims) {
     77        success = initializeOpenGLShims();
     78        initializedShims = true;
     79    }
     80    if (!success) {
     81        m_private = nullptr;
     82        return;
     83    }
     84
     85    if (renderStyle == RenderOffscreen) {
     86        // Create buffers for the canvas FBO.
     87        glGenFramebuffers(/* count */ 1, &m_fbo);
     88
     89        // Create a texture to render into.
     90        glGenTextures(1, &m_texture);
     91        glBindTexture(GraphicsContext3D::TEXTURE_2D, m_texture);
     92        glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
     93        glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
     94        glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
     95        glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
     96        glBindTexture(GraphicsContext3D::TEXTURE_2D, 0);
     97
     98        // Create a multisample FBO.
     99        if (m_attrs.antialias) {
     100            glGenFramebuffers(1, &m_multisampleFBO);
     101            glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
     102            m_boundFBO = m_multisampleFBO;
     103            glGenRenderbuffers(1, &m_multisampleColorBuffer);
     104            if (m_attrs.stencil || m_attrs.depth)
     105                glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
     106        } else {
     107            // Bind canvas FBO.
     108            glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     109            m_boundFBO = m_fbo;
     110#if USE(OPENGL_ES_2)
     111            if (m_attrs.depth)
     112                glGenRenderbuffers(1, &m_depthBuffer);
     113            if (m_context->m_attrs.stencil)
     114                glGenRenderbuffers(1, &m_stencilBuffer);
     115#endif
     116            if (m_attrs.stencil || m_attrs.depth)
     117                glGenRenderbuffers(1, &m_depthStencilBuffer);
     118        }
     119    }
     120
     121    // ANGLE initialization.
     122    ShBuiltInResources ANGLEResources;
     123    ShInitBuiltInResources(&ANGLEResources);
     124
     125    getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs);
     126    getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors);
     127    getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors);
     128    getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits);
     129    getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits);
     130    getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits);
     131    getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors);
     132
     133    // Always set to 1 for OpenGL ES.
     134    ANGLEResources.MaxDrawBuffers = 1;
     135    m_compiler.setResources(ANGLEResources);
     136
     137#if !USE(OPENGL_ES_2)
     138    glEnable(GL_POINT_SPRITE);
     139    glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
     140#endif
    48141}
    49142
     
    60153PlatformLayer* GraphicsContext3D::platformLayer() const
    61154{
     155#if USE(TEXTURE_MAPPER_GL)
     156    return m_private.get();
     157#else
    62158    notImplemented();
    63159    return 0;
     160#endif
    64161}
    65162#endif
     
    67164bool GraphicsContext3D::makeContextCurrent()
    68165{
     166    if (!m_private)
     167        return false;
     168
     169    if (m_renderStyle == RenderToCurrentGLContext)
     170        return true;
     171
    69172    return m_private->makeContextCurrent();
    70173}
     
    72175bool GraphicsContext3D::isGLES2Compliant() const
    73176{
    74     return m_private->isGLES2Compliant();
    75 }
    76 
    77 void GraphicsContext3D::activeTexture(GC3Denum texture)
    78 {
    79     m_private->activeTexture(texture);
    80 }
    81 
    82 void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader)
    83 {
    84     m_private->attachShader(program, shader);
    85 }
    86 
    87 void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name)
    88 {
    89     m_private->bindAttribLocation(program, index, name);
    90 }
    91 
    92 void GraphicsContext3D::bindBuffer(GC3Denum target, Platform3DObject buffer)
    93 {
    94     m_private->bindBuffer(target, buffer);
    95 }
    96 
    97 void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer)
    98 {
    99     m_private->bindFramebuffer(target, buffer);
    100 }
    101 
    102 void GraphicsContext3D::bindRenderbuffer(GC3Denum target, Platform3DObject renderbuffer)
    103 {
    104     m_private->bindRenderbuffer(target, renderbuffer);
    105 }
    106 
    107 void GraphicsContext3D::bindTexture(GC3Denum target, Platform3DObject texture)
    108 {
    109     m_private->bindTexture(target, texture);
    110 }
    111 
    112 void GraphicsContext3D::blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha)
    113 {
    114     m_private->blendColor(red, green, blue, alpha);
    115 }
    116 
    117 void GraphicsContext3D::blendEquation(GC3Denum mode)
    118 {
    119     m_private->blendEquation(mode);
    120 }
    121 
    122 void GraphicsContext3D::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha)
    123 {
    124     m_private->blendEquationSeparate(modeRGB, modeAlpha);
    125 }
    126 
    127 void GraphicsContext3D::blendFunc(GC3Denum srcFactor, GC3Denum dstFactor)
    128 {
    129     m_private->blendFunc(srcFactor, dstFactor);
    130 }
    131 
    132 void GraphicsContext3D::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha)
    133 {
    134     m_private->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
    135 }
    136 
    137 void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage)
    138 {
    139     m_private->bufferData(target, size, 0, usage);
    140 }
    141 
    142 void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage)
    143 {
    144     m_private->bufferData(target, size, data, usage);
    145 }
    146 
    147 void GraphicsContext3D::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data)
    148 {
    149     m_private->bufferSubData(target, offset, size, data);
    150 }
    151 
    152 GC3Denum GraphicsContext3D::checkFramebufferStatus(GC3Denum target)
    153 {
    154     return m_private->checkFramebufferStatus(target);
    155 }
    156 
    157 void GraphicsContext3D::clear(GC3Dbitfield mask)
    158 {
    159     m_private->clear(mask);
    160 }
    161 
    162 void GraphicsContext3D::clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha)
    163 {
    164     m_private->clearColor(red, green, blue, alpha);
    165 }
    166 
    167 void GraphicsContext3D::clearDepth(GC3Dclampf depth)
    168 {
    169     m_private->clearDepth(depth);
    170 }
    171 
    172 void GraphicsContext3D::clearStencil(GC3Dint clearValue)
    173 {
    174     m_private->clearStencil(clearValue);
    175 }
    176 
    177 void GraphicsContext3D::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha)
    178 {
    179     m_private->colorMask(red, green, blue, alpha);
    180 }
    181 
    182 void GraphicsContext3D::compileShader(Platform3DObject shader)
    183 {
    184     m_private->compileShader(shader);
    185 }
    186 
    187 void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
    188 {
    189     m_private->copyTexImage2D(target, level, internalformat, x, y, width, height, border);
    190 }
    191 
    192 void GraphicsContext3D::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xOffset, GC3Dint yOffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    193 {
    194     m_private->copyTexSubImage2D(target, level, xOffset, yOffset, x, y, width, height);
    195 }
    196 
    197 void GraphicsContext3D::cullFace(GC3Denum mode)
    198 {
    199     m_private->cullFace(mode);
    200 }
    201 
    202 void GraphicsContext3D::depthFunc(GC3Denum func)
    203 {
    204     m_private->depthFunc(func);
    205 }
    206 
    207 void GraphicsContext3D::depthMask(GC3Dboolean flag)
    208 {
    209     m_private->depthMask(flag);
    210 }
    211 
    212 void GraphicsContext3D::depthRange(GC3Dclampf zNear, GC3Dclampf zFar)
    213 {
    214     m_private->depthRange(zNear, zFar);
    215 }
    216 
    217 void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader)
    218 {
    219     m_private->detachShader(program, shader);
    220 }
    221 
    222 void GraphicsContext3D::disable(GC3Denum cap)
    223 {
    224     m_private->disable(cap);
    225 }
    226 
    227 void GraphicsContext3D::disableVertexAttribArray(GC3Duint index)
    228 {
    229     m_private->disableVertexAttribArray(index);
    230 }
    231 
    232 void GraphicsContext3D::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count)
    233 {
    234     m_private->drawArrays(mode, first, count);
    235 }
    236 
    237 void GraphicsContext3D::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset)
    238 {
    239     m_private->drawElements(mode, count, type, offset);
    240 }
    241 
    242 void GraphicsContext3D::enable(GC3Denum cap)
    243 {
    244     m_private->enable(cap);
    245 }
    246 
    247 void GraphicsContext3D::enableVertexAttribArray(GC3Duint index)
    248 {
    249     m_private->enableVertexAttribArray(index);
    250 }
    251 
    252 void GraphicsContext3D::finish()
    253 {
    254     m_private->finish();
    255 }
    256 
    257 void GraphicsContext3D::flush()
    258 {
    259     m_private->flush();
    260 }
    261 
    262 void GraphicsContext3D::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbufferTarget, Platform3DObject buffer)
    263 {
    264     m_private->framebufferRenderbuffer(target, attachment, renderbufferTarget, buffer);
    265 }
    266 
    267 void GraphicsContext3D::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum texTarget, Platform3DObject texture, GC3Dint level)
    268 {
    269     m_private->framebufferTexture2D(target, attachment, texTarget, texture, level);
    270 }
    271 
    272 void GraphicsContext3D::frontFace(GC3Denum mode)
    273 {
    274     m_private->frontFace(mode);
    275 }
    276 
    277 void GraphicsContext3D::generateMipmap(GC3Denum target)
    278 {
    279     m_private->generateMipmap(target);
    280 }
    281 
    282 bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info)
    283 {
    284     return m_private->getActiveAttrib(program, index, info);
    285 }
    286 
    287 bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info)
    288 {
    289     return m_private->getActiveUniform(program, index, info);
    290 }
    291 
    292 void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders)
    293 {
    294     m_private->getAttachedShaders(program, maxCount, count, shaders);
    295 }
    296 
    297 int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name)
    298 {
    299     return m_private->getAttribLocation(program, name);
    300 }
    301 
    302 void GraphicsContext3D::getBooleanv(GC3Denum paramName, GC3Dboolean* value)
    303 {
    304     m_private->getBooleanv(paramName, value);
    305 }
    306 
    307 void GraphicsContext3D::getBufferParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value)
    308 {
    309     m_private->getBufferParameteriv(target, paramName, value);
    310 }
    311 
    312 GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes()
    313 {
    314     return m_private->getContextAttributes();
    315 }
    316 
    317 GC3Denum GraphicsContext3D::getError()
    318 {
    319     return m_private->getError();
    320 }
    321 
    322 void GraphicsContext3D::getFloatv(GC3Denum paramName, GC3Dfloat* value)
    323 {
    324     m_private->getFloatv(paramName, value);
    325 }
    326 
    327 void GraphicsContext3D::getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum paramName, GC3Dint* value)
    328 {
    329     m_private->getFramebufferAttachmentParameteriv(target, attachment, paramName, value);
    330 }
    331 
    332 void GraphicsContext3D::getIntegerv(GC3Denum paramName, GC3Dint* value)
    333 {
    334     m_private->getIntegerv(paramName, value);
    335 }
    336 
    337 void GraphicsContext3D::getProgramiv(Platform3DObject program, GC3Denum paramName, GC3Dint* value)
    338 {
    339     m_private->getProgramiv(program, paramName, value);
    340 }
    341 
    342 String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)
    343 {
    344     return m_private->getProgramInfoLog(program);
    345 }
    346 
    347 void GraphicsContext3D::getRenderbufferParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value)
    348 {
    349     m_private->getRenderbufferParameteriv(target, paramName, value);
    350 }
    351 
    352 void GraphicsContext3D::getShaderiv(Platform3DObject shader, GC3Denum paramName, GC3Dint* value)
    353 {
    354     m_private->getShaderiv(shader, paramName, value);
    355 }
    356 
    357 String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
    358 {
    359     return m_private->getShaderInfoLog(shader);
    360 }
    361 
    362 String GraphicsContext3D::getShaderSource(Platform3DObject shader)
    363 {
    364     return m_private->getShaderSource(shader);
    365 }
    366 
    367 String GraphicsContext3D::getString(GC3Denum name)
    368 {
    369     return m_private->getString(name);
    370 }
    371 
    372 void GraphicsContext3D::getTexParameterfv(GC3Denum target, GC3Denum paramName, GC3Dfloat* value)
    373 {
    374     m_private->getTexParameterfv(target, paramName, value);
    375 }
    376 
    377 void GraphicsContext3D::getTexParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value)
    378 {
    379     m_private->getTexParameteriv(target, paramName, value);
    380 }
    381 
    382 void GraphicsContext3D::getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value)
    383 {
    384     m_private->getUniformfv(program, location, value);
    385 }
    386 
    387 void GraphicsContext3D::getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value)
    388 {
    389     m_private->getUniformiv(program, location, value);
    390 }
    391 
    392 GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name)
    393 {
    394     return m_private->getUniformLocation(program, name);
    395 }
    396 
    397 void GraphicsContext3D::getVertexAttribfv(GC3Duint index, GC3Denum paramName, GC3Dfloat* value)
    398 {
    399     m_private->getVertexAttribfv(index, paramName, value);
    400 }
    401 
    402 void GraphicsContext3D::getVertexAttribiv(GC3Duint index, GC3Denum paramName, GC3Dint* value)
    403 {
    404     m_private->getVertexAttribiv(index, paramName, value);
    405 }
    406 
    407 long GraphicsContext3D::getVertexAttribOffset(GC3Duint index, GC3Denum paramName)
    408 {
    409     return m_private->getVertexAttribOffset(index, paramName);
    410 }
    411 
    412 void GraphicsContext3D::hint(GC3Denum target, GC3Denum mode)
    413 {
    414     m_private->hint(target, mode);
    415 }
    416 
    417 GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject obj)
    418 {
    419     return m_private->isBuffer(obj);
    420 }
    421 
    422 GC3Dboolean GraphicsContext3D::isEnabled(GC3Denum cap)
    423 {
    424     return m_private->isEnabled(cap);
    425 }
    426 
    427 GC3Dboolean GraphicsContext3D::isFramebuffer(Platform3DObject obj)
    428 {
    429     return m_private->isFramebuffer(obj);
    430 }
    431 
    432 GC3Dboolean GraphicsContext3D::isProgram(Platform3DObject obj)
    433 {
    434     return m_private->isProgram(obj);
    435 }
    436 
    437 GC3Dboolean GraphicsContext3D::isRenderbuffer(Platform3DObject obj)
    438 {
    439     return m_private->isRenderbuffer(obj);
    440 }
    441 
    442 GC3Dboolean GraphicsContext3D::isShader(Platform3DObject obj)
    443 {
    444     return m_private->isShader(obj);
    445 }
    446 
    447 GC3Dboolean GraphicsContext3D::isTexture(Platform3DObject obj)
    448 {
    449     return m_private->isTexture(obj);
    450 }
    451 
    452 void GraphicsContext3D::lineWidth(GC3Dfloat width)
    453 {
    454     m_private->lineWidth(width);
    455 }
    456 
    457 void GraphicsContext3D::linkProgram(Platform3DObject program)
    458 {
    459     m_private->linkProgram(program);
    460 }
    461 
    462 void GraphicsContext3D::pixelStorei(GC3Denum paramName, GC3Dint param)
    463 {
    464     m_private->pixelStorei(paramName, param);
    465 }
    466 
    467 void GraphicsContext3D::polygonOffset(GC3Dfloat factor, GC3Dfloat units)
    468 {
    469     m_private->polygonOffset(factor, units);
    470 }
    471 
    472 void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data)
    473 {
    474     m_private->readPixels(x, y, width, height, format, type, data);
    475 }
    476 
    477 void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height)
    478 {
    479     m_private->renderbufferStorage(target, internalformat, width, height);
    480 }
    481 
    482 void GraphicsContext3D::sampleCoverage(GC3Dclampf value, GC3Dboolean invert)
    483 {
    484     m_private->sampleCoverage(value, invert);
    485 }
    486 
    487 void GraphicsContext3D::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    488 {
    489     m_private->scissor(x, y, width, height);
    490 }
    491 
    492 void GraphicsContext3D::shaderSource(Platform3DObject program, const String& string)
    493 {
    494     m_private->shaderSource(program, string);
    495 }
    496 
    497 void GraphicsContext3D::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask)
    498 {
    499     m_private->stencilFunc(func, ref, mask);
    500 }
    501 
    502 void GraphicsContext3D::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask)
    503 {
    504     m_private->stencilFuncSeparate(face, func, ref, mask);
    505 }
    506 
    507 void GraphicsContext3D::stencilMask(GC3Duint mask)
    508 {
    509     m_private->stencilMask(mask);
    510 }
    511 
    512 void GraphicsContext3D::stencilMaskSeparate(GC3Denum face, GC3Duint mask)
    513 {
    514     m_private->stencilMaskSeparate(face, mask);
    515 }
    516 
    517 void GraphicsContext3D::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass)
    518 {
    519     m_private->stencilOp(fail, zfail, zpass);
    520 }
    521 
    522 void GraphicsContext3D::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass)
    523 {
    524     m_private->stencilOpSeparate(face, fail, zfail, zpass);
    525 }
    526 
    527 bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
    528 {
    529     return m_private->texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
    530 }
    531 
    532 void GraphicsContext3D::texParameterf(GC3Denum target, GC3Denum paramName, GC3Dfloat param)
    533 {
    534     m_private->texParameterf(target, paramName, param);
    535 }
    536 
    537 void GraphicsContext3D::texParameteri(GC3Denum target, GC3Denum paramName, GC3Dint param)
    538 {
    539     m_private->texParameteri(target, paramName, param);
    540 }
    541 
    542 void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xOffset, GC3Dint yOffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels)
    543 {
    544     m_private->texSubImage2D(target, level, xOffset, yOffset, width, height, format, type, pixels);
    545 }
    546 
    547 void GraphicsContext3D::uniform1f(GC3Dint location, GC3Dfloat x)
    548 {
    549     m_private->uniform1f(location, x);
    550 }
    551 
    552 void GraphicsContext3D::uniform1fv(GC3Dint location, GGC3Dsizei size, C3Dfloat* v)
    553 {
    554     m_private->uniform1fv(location, size, v);
    555 }
    556 
    557 void GraphicsContext3D::uniform1i(GC3Dint location, GC3Dint x)
    558 {
    559     m_private->uniform1i(location, x);
    560 }
    561 
    562 void GraphicsContext3D::uniform1iv(GC3Dint location, GGC3Dsizei size, C3Dint* v)
    563 {
    564     m_private->uniform1iv(location, size, v);
    565 }
    566 
    567 void GraphicsContext3D::uniform2f(GC3Dint location, GC3Dfloat x, float y)
    568 {
    569     m_private->uniform2f(location, x, y);
    570 }
    571 
    572 void GraphicsContext3D::uniform2fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v)
    573 {
    574     m_private->uniform2fv(location, size, v);
    575 }
    576 
    577 void GraphicsContext3D::uniform2i(GC3Dint location, GC3Dint x, GC3Dint y)
    578 {
    579     m_private->uniform2i(location, x, y);
    580 }
    581 
    582 void GraphicsContext3D::uniform2iv(GC3Dint location, GC3Dsizei size, GC3Dint* v)
    583 {
    584     m_private->uniform2iv(location, size, v);
    585 }
    586 
    587 void GraphicsContext3D::uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z)
    588 {
    589     m_private->uniform3f(location, x, y, z);
    590 }
    591 
    592 void GraphicsContext3D::uniform3fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v)
    593 {
    594     m_private->uniform3fv(location, size, v);
    595 }
    596 
    597 void GraphicsContext3D::uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z)
    598 {
    599     m_private->uniform3i(location, x, y, z);
    600 }
    601 
    602 void GraphicsContext3D::uniform3iv(GC3Dint location, GC3Dsizei size, GC3Dint* v)
    603 {
    604     m_private->uniform3iv(location, size, v);
    605 }
    606 
    607 void GraphicsContext3D::uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w)
    608 {
    609     m_private->uniform4f(location, x, y, z, w);
    610 }
    611 
    612 void GraphicsContext3D::uniform4fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* v)
    613 {
    614     m_private->uniform4fv(location, size, v);
    615 }
    616 
    617 void GraphicsContext3D::uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w)
    618 {
    619     m_private->uniform4i(location, x, y, z, w);
    620 }
    621 
    622 void GraphicsContext3D::uniform4iv(GC3Dint location, GC3Dsizei size, GC3Dint* v)
    623 {
    624     m_private->uniform4iv(location, size, v);
    625 }
    626 
    627 void GraphicsContext3D::uniformMatrix2fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value)
    628 {
    629     m_private->uniformMatrix2fv(location, size, transpose, value);
    630 }
    631 
    632 void GraphicsContext3D::uniformMatrix3fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value)
    633 {
    634     m_private->uniformMatrix3fv(location, size, transpose, value);
    635 }
    636 
    637 void GraphicsContext3D::uniformMatrix4fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value)
    638 {
    639     m_private->uniformMatrix4fv(location, size, transpose, value);
    640 }
    641 
    642 void GraphicsContext3D::useProgram(Platform3DObject program)
    643 {
    644     m_private->useProgram(program);
    645 }
    646 
    647 void GraphicsContext3D::validateProgram(Platform3DObject program)
    648 {
    649     m_private->validateProgram(program);
    650 }
    651 
    652 void GraphicsContext3D::vertexAttrib1f(GC3Duint index, GC3Dfloat x)
    653 {
    654     m_private->vertexAttrib1f(index, x);
    655 }
    656 
    657 void GraphicsContext3D::vertexAttrib1fv(GC3Duint index, GC3Dfloat* values)
    658 {
    659     m_private->vertexAttrib1fv(index, values);
    660 }
    661 
    662 void GraphicsContext3D::vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y)
    663 {
    664     m_private->vertexAttrib2f(index, x, y);
    665 }
    666 
    667 void GraphicsContext3D::vertexAttrib2fv(GC3Duint index, GC3Dfloat* values)
    668 {
    669     m_private->vertexAttrib2fv(index, values);
    670 }
    671 
    672 void GraphicsContext3D::vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z)
    673 {
    674     m_private->vertexAttrib3f(index, x, y, z);
    675 }
    676 
    677 void GraphicsContext3D::vertexAttrib3fv(GC3Duint index, GC3Dfloat* values)
    678 {
    679     m_private->vertexAttrib3fv(index, values);
    680 }
    681 
    682 void GraphicsContext3D::vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w)
    683 {
    684     m_private->vertexAttrib4f(index, x, y, z, w);
    685 }
    686 
    687 void GraphicsContext3D::vertexAttrib4fv(GC3Duint index, GC3Dfloat* values)
    688 {
    689     m_private->vertexAttrib4fv(index, values);
    690 }
    691 
    692 void GraphicsContext3D::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset)
    693 {
    694     m_private->vertexAttribPointer(index, size, type, normalized, stride, offset);
    695 }
    696 
    697 void GraphicsContext3D::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    698 {
    699     m_private->viewport(x, y, width, height);
    700 }
    701 
    702 void GraphicsContext3D::reshape(int width, int height)
    703 {
    704     notImplemented();
    705 }
    706 
    707 void GraphicsContext3D::markContextChanged()
    708 {
    709     notImplemented();
    710 }
    711 
    712 void GraphicsContext3D::markLayerComposited()
    713 {
    714     notImplemented();
    715 }
    716 
    717 bool GraphicsContext3D::layerComposited() const
    718 {
    719     notImplemented();
     177#if USE(OPENGL_ES_2)
     178    return true;
     179#else
    720180    return false;
    721 }
    722 
    723 void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer*, DrawingBuffer* drawingBuffer)
    724 {
    725     notImplemented();
    726 }
    727 
    728 PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(DrawingBuffer* drawingBuffer)
    729 {
    730     notImplemented();
    731     return 0;
    732 }
    733 
    734 bool GraphicsContext3D::paintCompositedResultsToCanvas(ImageBuffer*)
    735 {
    736     return false;
    737 }
    738 
    739 Platform3DObject GraphicsContext3D::createBuffer()
    740 {
    741     return m_private->createBuffer();
    742 }
    743 
    744 Platform3DObject GraphicsContext3D::createFramebuffer()
    745 {
    746     return m_private->createFramebuffer();
    747 }
    748 
    749 Platform3DObject GraphicsContext3D::createProgram()
    750 {
    751     return m_private->createProgram();
    752 }
    753 
    754 Platform3DObject GraphicsContext3D::createRenderbuffer()
    755 {
    756     return m_private->createRenderbuffer();
    757 }
    758 
    759 Platform3DObject GraphicsContext3D::createShader(GC3Denum type)
    760 {
    761     return m_private->createShader(type);
    762 }
    763 
    764 Platform3DObject GraphicsContext3D::createTexture()
    765 {
    766     return m_private->createTexture();
    767 }
    768 
    769 void GraphicsContext3D::deleteBuffer(Platform3DObject buffer)
    770 {
    771     m_private->deleteBuffer(buffer);
    772 }
    773 
    774 void GraphicsContext3D::deleteFramebuffer(Platform3DObject buffer)
    775 {
    776     m_private->deleteFramebuffer(buffer);
    777 }
    778 
    779 void GraphicsContext3D::deleteProgram(Platform3DObject program)
    780 {
    781     m_private->deleteProgram(program);
    782 }
    783 
    784 void GraphicsContext3D::deleteRenderbuffer(Platform3DObject buffer)
    785 {
    786     m_private->deleteRenderbuffer(buffer);
    787 }
    788 
    789 void GraphicsContext3D::deleteShader(Platform3DObject shader)
    790 {
    791     m_private->deleteShader(shader);
    792 }
    793 
    794 void GraphicsContext3D::deleteTexture(Platform3DObject texture)
    795 {
    796     m_private->deleteTexture(texture);
    797 }
    798 
    799 void GraphicsContext3D::synthesizeGLError(GC3Denum error)
    800 {
    801     m_private->synthesizeGLError(error);
    802 }
    803 
    804 Extensions3D* GraphicsContext3D::getExtensions()
    805 {
    806     return m_private->getExtensions();
    807 }
    808 
    809 IntSize GraphicsContext3D::getInternalFramebufferSize() const
    810 {
    811     notImplemented();
    812     return IntSize();
    813 }
    814 
    815 void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>)
    816 {
    817     notImplemented();
    818 }
     181#endif
     182}
     183
     184void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>)
     185{
     186    notImplemented();
     187}
     188
     189void GraphicsContext3D::setErrorMessageCallback(PassOwnPtr<ErrorMessageCallback>)
     190{
     191    notImplemented();
     192}
     193
     194void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, PlatformContextCairo* context)
     195{
     196    if (!imagePixels || imageWidth <= 0 || imageHeight <= 0 || canvasWidth <= 0 || canvasHeight <= 0 || !context)
     197        return;
     198
     199    cairo_t* cr = context->cr();
     200    context->save();
     201
     202    RefPtr<cairo_surface_t> imageSurface = adoptRef(cairo_image_surface_create_for_data(
     203        const_cast<unsigned char*>(imagePixels), CAIRO_FORMAT_ARGB32, imageWidth, imageHeight, imageWidth * 4));
     204
     205    // OpenGL keeps the pixels stored bottom up, so we need to flip the image here.
     206    cairo_translate(cr, 0, imageHeight);
     207    cairo_scale(cr, 1, -1);
     208
     209    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
     210    cairo_set_source_surface(cr, imageSurface.get(), 0, 0);
     211    cairo_rectangle(cr, 0, 0, canvasWidth, -canvasHeight);
     212
     213    cairo_fill(cr);
     214    context->restore();
     215}
     216
     217#if USE(GRAPHICS_SURFACE)
     218void GraphicsContext3D::createGraphicsSurfaces(const IntSize& size)
     219{
     220    notImplemented();
     221}
     222#endif
    819223
    820224bool GraphicsContext3D::getImageData(Image* image, GC3Denum format, GC3Denum type, bool premultiplyAlpha,
     
    825229}
    826230
    827 void GraphicsContext3D::validateAttributes()
    828 {
    829     notImplemented();
    830 }
    831 
    832 void GraphicsContext3D::readRenderingResults(unsigned char* pixels, int pixelsSize)
    833 {
    834     notImplemented();
    835 }
    836 
    837 bool GraphicsContext3D::reshapeFBOs(const IntSize&)
    838 {
    839     notImplemented();
    840 }
    841 
    842 void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect&)
    843 {
    844     notImplemented();
    845 }
    846 
    847 bool GraphicsContext3D::isResourceSafe()
    848 {
    849     notImplemented();
    850     return false;
    851 }
    852 
    853231} // namespace WebCore
    854232
  • trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp

    r125617 r130966  
    2121
    2222#if USE(3D_GRAPHICS) || USE(ACCELERATED_COMPOSITING)
    23 
    2423#include "GraphicsContext3DPrivate.h"
    2524
     25#include "GraphicsContext.h"
    2626#include "HostWindow.h"
    2727#include "NotImplemented.h"
    28 #include "PageClientEfl.h"
    29 
     28#include <Ecore_Evas.h>
     29#include <Evas_GL.h>
    3030#include <wtf/OwnArrayPtr.h>
    3131#include <wtf/text/CString.h>
     
    3333namespace WebCore {
    3434
    35 PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
     35GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
     36    : m_context(context)
     37    , m_hostWindow(hostWindow)
     38    , m_evasGL(0)
     39    , m_evasGLContext(0)
     40    , m_evasGLSurface(0)
     41    , m_glContext(0)
     42    , m_glSurface(0)
     43    , m_api(0)
     44    , m_renderStyle(renderStyle)
    3645{
    37     OwnPtr<GraphicsContext3DPrivate> internal = adoptPtr(new GraphicsContext3DPrivate());
     46    if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext)
     47        return;
    3848
    39     if (!internal->initialize(attributes, hostWindow, renderDirectlyToHostWindow))
    40         return nullptr;
     49    if (m_hostWindow && m_hostWindow->platformPageClient()) {
     50        // FIXME: Implement this code path for WebKit1.
     51        // Get Evas object from platformPageClient and set EvasGL related members.
     52        return;
     53    }
    4154
    42     return internal.release();
    43 }
     55    // For WebKit2, we need to create a dummy ecoreEvas object for the WebProcess in order to use EvasGL APIs.
     56#ifdef HAVE_ECORE_X
     57    ecore_evas_init();
     58    m_ecoreEvas = adoptPtr(ecore_evas_gl_x11_new(0, 0, 0, 0, 1, 1));
     59    if (!m_ecoreEvas)
     60        return;
     61#else
     62    return;
     63#endif
    4464
    45 GraphicsContext3DPrivate::GraphicsContext3DPrivate()
    46     : m_boundFBO(0)
    47     , m_boundTexture(0)
    48     , m_boundArrayBuffer(0)
    49     , m_evasGL(0)
    50     , m_context(0)
    51     , m_surface(0)
    52     , m_api(0)
    53 {
     65    Evas* evas = ecore_evas_get(m_ecoreEvas.get());
     66    if (!evas)
     67        return;
     68
     69    // Create a new Evas_GL object for gl rendering on efl.
     70    m_evasGL = evas_gl_new(evas);
     71    if (!m_evasGL)
     72        return;
     73
     74    // Get the API for rendering using OpenGL.
     75    // This returns a structure that contains all the OpenGL functions we can use to render in Evas
     76    m_api = evas_gl_api_get(m_evasGL);
     77    if (!m_api)
     78        return;
     79
     80    // Create a context
     81    m_evasGLContext = evas_gl_context_create(m_evasGL, 0);
     82    if (!m_evasGLContext)
     83        return;
     84
     85    // Create a surface
     86    if (!createSurface(0, renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow))
     87        return;
     88
     89    makeContextCurrent();
    5490}
    5591
     
    5995        return;
    6096
    61     if (m_surface)
    62         evas_gl_surface_destroy(m_evasGL, m_surface);
     97    if (m_evasGLSurface)
     98        evas_gl_surface_destroy(m_evasGL, m_evasGLSurface);
    6399
    64     if (m_context)
    65         evas_gl_context_destroy(m_evasGL, m_context);
     100    if (m_evasGLContext)
     101        evas_gl_context_destroy(m_evasGL, m_evasGLContext);
    66102
    67103    evas_gl_free(m_evasGL);
    68104}
    69105
    70 bool GraphicsContext3DPrivate::initialize(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
    71 {
    72     PageClientEfl* pageClient = static_cast<PageClientEfl*>(hostWindow->platformPageClient());
    73 
    74     Evas* evas = evas_object_evas_get(pageClient->view());
    75 
    76     // Create a new Evas_GL object for gl rendering on efl.
    77     m_evasGL = evas_gl_new(evas);
    78     if (!m_evasGL)
    79         return false;
    80 
    81     // Get the API for rendering using OpenGL.
    82     // This returns a structure that contains all the OpenGL functions we can use to render in Evas
    83     m_api = evas_gl_api_get(m_evasGL);
    84     if (!m_api)
    85         return false;
    86 
    87     Evas_GL_Context* shareContext = 0;
    88 
    89 #if USE(ACCELERATED_COMPOSITING)
    90     // GC3D with RenderOffscreen style for WebGL has to be shared with AC's context when AC is enabled.
    91     if (!renderDirectlyToHostWindow) {
    92         GraphicsContext3D* context = pageClient->acceleratedCompositingContext();
    93         if (context)
    94             shareContext = static_cast<Evas_GL_Context*>(context->platformGraphicsContext3D());
    95     }
    96 #endif
    97 
    98     // Create a context
    99     m_context = evas_gl_context_create(m_evasGL, shareContext);
    100     if (!m_context)
    101         return false;
    102 
    103     // Create a surface
    104     if (!createSurface(pageClient, renderDirectlyToHostWindow))
    105         return false;
    106 
    107     return makeContextCurrent();
    108 }
    109106
    110107bool GraphicsContext3DPrivate::createSurface(PageClientEfl* pageClient, bool renderDirectlyToHostWindow)
     
    118115
    119116    // But, in case of RenderDirectlyToHostWindow, we have to render to a render target surface with the same size as our webView.
    120     if (renderDirectlyToHostWindow)
    121         evas_object_geometry_get(pageClient->view(), &x, &y, &width, &height);
     117    if (renderDirectlyToHostWindow) {
     118        if (!pageClient)
     119            return false;
     120        // FIXME: Get geometry of webView and set size of target surface.
     121    }
    122122
    123123    Evas_GL_Config config = {
     
    129129
    130130    // Create a new Evas_GL_Surface object
    131     m_surface = evas_gl_surface_create(m_evasGL, &config, width, height);
    132     if (!m_surface)
     131    m_evasGLSurface = evas_gl_surface_create(m_evasGL, &config, width, height);
     132    if (!m_evasGLSurface)
    133133        return false;
    134134
     
    137137        Evas_Native_Surface nativeSurface;
    138138        // Fill in the Native Surface information from the given Evas GL surface.
    139         evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface);
     139        evas_gl_native_surface_get(m_evasGL, m_evasGLSurface, &nativeSurface);
    140140
    141         // Create and specially set up a evas_object which act as the render targer surface.
    142         if (!pageClient->createEvasObjectForAcceleratedCompositing(&nativeSurface, IntRect(x, y, width, height)))
    143             return false;
     141        // FIXME: Create and specially set up a evas_object which act as the render targer surface.
    144142    }
    145143#endif
     144
    146145    return true;
     146}
     147
     148void GraphicsContext3DPrivate::setCurrentGLContext(void* context, void* surface)
     149{
     150    m_glContext = context;
     151    m_glSurface = surface;
    147152}
    148153
    149154PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const
    150155{
    151     return m_context;
     156    if (m_renderStyle == GraphicsContext3D::RenderToCurrentGLContext)
     157        return m_glContext;
     158
     159    return m_evasGLContext;
    152160}
    153161
    154162bool GraphicsContext3DPrivate::makeContextCurrent()
    155163{
    156     return evas_gl_make_current(m_evasGL, m_surface, m_context);
     164    return evas_gl_make_current(m_evasGL, m_evasGLSurface, m_evasGLContext);
    157165}
    158166
    159 bool GraphicsContext3DPrivate::isGLES2Compliant() const
    160 {
    161     return true;
    162 }
    163 
    164 void GraphicsContext3DPrivate::activeTexture(GC3Denum texture)
    165 {
    166     makeContextCurrent();
    167     m_api->glActiveTexture(texture);
    168 }
    169 
    170 void GraphicsContext3DPrivate::attachShader(Platform3DObject program, Platform3DObject shader)
    171 {
    172     makeContextCurrent();
    173     m_api->glAttachShader(program, shader);
    174 }
    175 
    176 void GraphicsContext3DPrivate::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name)
    177 {
    178     makeContextCurrent();
    179     m_api->glBindAttribLocation(program, index, name.utf8().data());
    180 }
    181 
    182 void GraphicsContext3DPrivate::bindBuffer(GC3Denum target, Platform3DObject buffer)
    183 {
    184     makeContextCurrent();
    185     m_api->glBindBuffer(target, buffer);
    186 
    187     if (target == GL_ARRAY_BUFFER)
    188         m_boundArrayBuffer = buffer;
    189 }
    190 
    191 void GraphicsContext3DPrivate::bindFramebuffer(GC3Denum target, Platform3DObject framebuffer)
    192 {
    193     makeContextCurrent();
    194 
    195     if (framebuffer != m_boundFBO) {
    196         m_api->glBindFramebuffer(target, framebuffer);
    197         m_boundFBO = framebuffer;
    198     }
    199 }
    200 
    201 void GraphicsContext3DPrivate::bindRenderbuffer(GC3Denum target, Platform3DObject buffer)
    202 {
    203     makeContextCurrent();
    204     m_api->glBindRenderbuffer(target, buffer);
    205 }
    206 
    207 void GraphicsContext3DPrivate::bindTexture(GC3Denum target, Platform3DObject texture)
    208 {
    209     makeContextCurrent();
    210     m_api->glBindTexture(target, texture);
    211     m_boundTexture = texture;
    212 }
    213 
    214 void GraphicsContext3DPrivate::blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha)
    215 {
    216     makeContextCurrent();
    217     m_api->glBlendColor(red, green, blue, alpha);
    218 }
    219 
    220 void GraphicsContext3DPrivate::blendEquation(GC3Denum mode)
    221 {
    222     makeContextCurrent();
    223     m_api->glBlendEquation(mode);
    224 }
    225 
    226 void GraphicsContext3DPrivate::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha)
    227 {
    228     makeContextCurrent();
    229     m_api->glBlendEquationSeparate(modeRGB, modeAlpha);
    230 }
    231 
    232 void GraphicsContext3DPrivate::blendFunc(GC3Denum srcFactor, GC3Denum dstFactor)
    233 {
    234     makeContextCurrent();
    235     m_api->glBlendFunc(srcFactor, dstFactor);
    236 }
    237 
    238 void GraphicsContext3DPrivate::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha)
    239 {
    240     makeContextCurrent();
    241     m_api->glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
    242 }
    243 
    244 void GraphicsContext3DPrivate::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage)
    245 {
    246     makeContextCurrent();
    247     m_api->glBufferData(target, size, data, usage);
    248 }
    249 
    250 void GraphicsContext3DPrivate::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data)
    251 {
    252     makeContextCurrent();
    253     m_api->glBufferSubData(target, offset, size, data);
    254 }
    255 
    256 GC3Denum GraphicsContext3DPrivate::checkFramebufferStatus(GC3Denum target)
    257 {
    258     makeContextCurrent();
    259     return m_api->glCheckFramebufferStatus(target);
    260 }
    261 
    262 void GraphicsContext3DPrivate::clear(GC3Dbitfield mask)
    263 {
    264     makeContextCurrent();
    265     m_api->glClear(mask);
    266 }
    267 
    268 void GraphicsContext3DPrivate::clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha)
    269 {
    270     makeContextCurrent();
    271     m_api->glClearColor(red, green, blue, alpha);
    272 }
    273 
    274 void GraphicsContext3DPrivate::clearDepth(GC3Dclampf depth)
    275 {
    276     makeContextCurrent();
    277     m_api->glClearDepthf(depth);
    278 }
    279 
    280 void GraphicsContext3DPrivate::clearStencil(GC3Dint clearValue)
    281 {
    282     makeContextCurrent();
    283     m_api->glClearStencil(clearValue);
    284 }
    285 
    286 void GraphicsContext3DPrivate::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha)
    287 {
    288     makeContextCurrent();
    289     m_api->glColorMask(red, green, blue, alpha);
    290 }
    291 
    292 void GraphicsContext3DPrivate::compileShader(Platform3DObject shader)
    293 {
    294     makeContextCurrent();
    295     m_api->glCompileShader(shader);
    296 }
    297 
    298 void GraphicsContext3DPrivate::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
    299 {
    300     makeContextCurrent();
    301     m_api->glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
    302 }
    303 
    304 void GraphicsContext3DPrivate::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xOffset, GC3Dint yOffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    305 {
    306     makeContextCurrent();
    307     m_api->glCopyTexSubImage2D(target, level, xOffset, yOffset, x, y, width, height);
    308 }
    309 
    310 void GraphicsContext3DPrivate::cullFace(GC3Denum mode)
    311 {
    312     makeContextCurrent();
    313     m_api->glCullFace(mode);
    314 }
    315 
    316 void GraphicsContext3DPrivate::depthFunc(GC3Denum func)
    317 {
    318     makeContextCurrent();
    319     m_api->glDepthFunc(func);
    320 }
    321 
    322 void GraphicsContext3DPrivate::depthMask(GC3Dboolean flag)
    323 {
    324     makeContextCurrent();
    325     m_api->glDepthMask(flag);
    326 }
    327 
    328 void GraphicsContext3DPrivate::depthRange(GC3Dclampf zNear, GC3Dclampf zFar)
    329 {
    330     makeContextCurrent();
    331     m_api->glDepthRangef(zNear, zFar);
    332 }
    333 
    334 void GraphicsContext3DPrivate::detachShader(Platform3DObject program, Platform3DObject shader)
    335 {
    336     makeContextCurrent();
    337     m_api->glDetachShader(program, shader);
    338 }
    339 
    340 void GraphicsContext3DPrivate::disable(GC3Denum cap)
    341 {
    342     makeContextCurrent();
    343     m_api->glDisable(cap);
    344 }
    345 
    346 void GraphicsContext3DPrivate::disableVertexAttribArray(GC3Duint index)
    347 {
    348     makeContextCurrent();
    349     m_api->glDisableVertexAttribArray(index);
    350 }
    351 
    352 void GraphicsContext3DPrivate::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count)
    353 {
    354     makeContextCurrent();
    355     m_api->glDrawArrays(mode, first, count);
    356 }
    357 
    358 void GraphicsContext3DPrivate::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset)
    359 {
    360     makeContextCurrent();
    361     m_api->glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
    362 }
    363 
    364 void GraphicsContext3DPrivate::enable(GC3Denum cap)
    365 {
    366     makeContextCurrent();
    367     m_api->glEnable(cap);
    368 }
    369 
    370 void GraphicsContext3DPrivate::enableVertexAttribArray(GC3Duint index)
    371 {
    372     makeContextCurrent();
    373     m_api->glEnableVertexAttribArray(index);
    374 }
    375 
    376 void GraphicsContext3DPrivate::finish()
    377 {
    378     makeContextCurrent();
    379     m_api->glFinish();
    380 }
    381 
    382 void GraphicsContext3DPrivate::flush()
    383 {
    384     makeContextCurrent();
    385     m_api->glFlush();
    386 }
    387 
    388 void GraphicsContext3DPrivate::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbufferTarget, Platform3DObject renderbuffer)
    389 {
    390     makeContextCurrent();
    391     m_api->glFramebufferRenderbuffer(target, attachment, renderbufferTarget, renderbuffer);
    392 }
    393 
    394 void GraphicsContext3DPrivate::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum texTarget, Platform3DObject texture, GC3Dint level)
    395 {
    396     makeContextCurrent();
    397     m_api->glFramebufferTexture2D(target, attachment, texTarget, texture, level);
    398 }
    399 
    400 void GraphicsContext3DPrivate::frontFace(GC3Denum mode)
    401 {
    402     makeContextCurrent();
    403     m_api->glFrontFace(mode);
    404 }
    405 
    406 void GraphicsContext3DPrivate::generateMipmap(GC3Denum target)
    407 {
    408     makeContextCurrent();
    409     m_api->glGenerateMipmap(target);
    410 }
    411 
    412 bool GraphicsContext3DPrivate::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info)
    413 {
    414     if (!program) {
    415         synthesizeGLError(GL_INVALID_VALUE);
    416         return false;
    417     }
    418 
    419     makeContextCurrent();
    420 
    421     GLint maxNameLength = 0;
    422     m_api->glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxNameLength);
    423     if (!maxNameLength)
    424         return false;
    425 
    426     OwnArrayPtr<char> name = adoptArrayPtr(new char[maxNameLength]);
    427     if (!name) {
    428         synthesizeGLError(GL_OUT_OF_MEMORY);
    429         return false;
    430     }
    431 
    432     GLsizei length = 0;
    433     GLint size = 0;
    434     GLenum type = 0;
    435     m_api->glGetActiveAttrib(program, index, maxNameLength, &length, &size, &type, name.get());
    436     if (!length)
    437         return false;
    438 
    439     info.name = String::fromUTF8(name.get(), length);
    440     info.type = type;
    441     info.size = size;
    442     return true;
    443 }
    444 
    445 bool GraphicsContext3DPrivate::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info)
    446 {
    447     if (!program) {
    448         synthesizeGLError(GL_INVALID_VALUE);
    449         return false;
    450     }
    451 
    452     makeContextCurrent();
    453 
    454     GLint maxNameLength = 0;
    455     m_api->glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxNameLength);
    456     if (!maxNameLength)
    457         return false;
    458 
    459     OwnArrayPtr<char> name = adoptArrayPtr(new char[maxNameLength]);
    460     if (!name) {
    461         synthesizeGLError(GL_OUT_OF_MEMORY);
    462         return false;
    463     }
    464 
    465     GLsizei length = 0;
    466     GLint size = 0;
    467     GLenum type = 0;
    468     m_api->glGetActiveUniform(program, index, maxNameLength, &length, &size, &type, name.get());
    469     if (!length)
    470         return false;
    471 
    472     info.name = String::fromUTF8(name.get(), length);
    473     info.type = type;
    474     info.size = size;
    475     return true;
    476 }
    477 
    478 void GraphicsContext3DPrivate::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders)
    479 {
    480     makeContextCurrent();
    481     m_api->glGetAttachedShaders(program, maxCount, count, shaders);
    482 }
    483 
    484 int GraphicsContext3DPrivate::getAttribLocation(Platform3DObject program, const String& name)
    485 {
    486     makeContextCurrent();
    487     return m_api->glGetAttribLocation(program, name.utf8().data());
    488 }
    489 
    490 void GraphicsContext3DPrivate::getBooleanv(GC3Denum paramName, GC3Dboolean* value)
    491 {
    492     makeContextCurrent();
    493     m_api->glGetBooleanv(paramName, value);
    494 }
    495 
    496 void GraphicsContext3DPrivate::getBufferParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value)
    497 {
    498     makeContextCurrent();
    499     m_api->glGetBufferParameteriv(target, paramName, value);
    500 }
    501 
    502 GraphicsContext3D::Attributes GraphicsContext3DPrivate::getContextAttributes()
    503 {
    504     return m_attributes;
    505 }
    506 
    507 GC3Denum GraphicsContext3DPrivate::getError()
    508 {
    509     if (!m_syntheticErrors.isEmpty()) {
    510         GC3Denum error = m_syntheticErrors.first();
    511         m_syntheticErrors.remove(m_syntheticErrors.begin());
    512         return error;
    513     }
    514 
    515     makeContextCurrent();
    516     return m_api->glGetError();
    517 }
    518 
    519 void GraphicsContext3DPrivate::getFloatv(GC3Denum paramName, GC3Dfloat* value)
    520 {
    521     makeContextCurrent();
    522     m_api->glGetFloatv(paramName, value);
    523 }
    524 
    525 void GraphicsContext3DPrivate::getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum paramName, GC3Dint* value)
    526 {
    527     makeContextCurrent();
    528     m_api->glGetFramebufferAttachmentParameteriv(target, attachment, paramName, value);
    529 }
    530 
    531 void GraphicsContext3DPrivate::getIntegerv(GC3Denum paramName, GC3Dint* value)
    532 {
    533     makeContextCurrent();
    534     m_api->glGetIntegerv(paramName, value);
    535 }
    536 
    537 void GraphicsContext3DPrivate::getProgramiv(Platform3DObject program, GC3Denum paramName, GC3Dint* value)
    538 {
    539     makeContextCurrent();
    540     m_api->glGetProgramiv(program, paramName, value);
    541 }
    542 
    543 String GraphicsContext3DPrivate::getProgramInfoLog(Platform3DObject program)
    544 {
    545     makeContextCurrent();
    546 
    547     GLint logLength = 0;
    548     m_api->glGetProgramiv(program, GraphicsContext3D::INFO_LOG_LENGTH, &logLength);
    549     if (!logLength)
    550         return String();
    551 
    552     OwnArrayPtr<char> log = adoptArrayPtr(new char[logLength]);
    553     if (!log)
    554         return String();
    555 
    556     GLint returnedLogLength = 0;
    557     m_api->glGetProgramInfoLog(program, logLength, &returnedLogLength, log.get());
    558     ASSERT(logLength == returnedLogLength + 1);
    559 
    560     String result = String::fromUTF8(log.get(), returnedLogLength);
    561     return result;
    562 }
    563 
    564 void GraphicsContext3DPrivate::getRenderbufferParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value)
    565 {
    566     makeContextCurrent();
    567     m_api->glGetRenderbufferParameteriv(target, paramName, value);
    568 }
    569 
    570 void GraphicsContext3DPrivate::getShaderiv(Platform3DObject shader, GC3Denum paramName, GC3Dint* value)
    571 {
    572     makeContextCurrent();
    573     m_api->glGetShaderiv(shader, paramName, value);
    574 }
    575 
    576 String GraphicsContext3DPrivate::getShaderInfoLog(Platform3DObject shader)
    577 {
    578     makeContextCurrent();
    579 
    580     GLint logLength = 0;
    581     m_api->glGetShaderiv(shader, GraphicsContext3D::INFO_LOG_LENGTH, &logLength);
    582     if (logLength <= 1)
    583         return String();
    584 
    585     OwnArrayPtr<char> log = adoptArrayPtr(new char[logLength]);
    586     if (!log)
    587         return String();
    588 
    589     GLint returnedLogLength = 0;
    590     m_api->glGetShaderInfoLog(shader, logLength, &returnedLogLength, log.get());
    591     ASSERT(logLength == returnedLogLength + 1);
    592 
    593     String result = String::fromUTF8(log.get(), returnedLogLength);
    594     return result;
    595 }
    596 
    597 String GraphicsContext3DPrivate::getShaderSource(Platform3DObject shader)
    598 {
    599     makeContextCurrent();
    600 
    601     GLint logLength = 0;
    602     m_api->glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength);
    603     if (logLength <= 1)
    604         return String();
    605 
    606     OwnArrayPtr<char> log = adoptArrayPtr(new char[logLength]);
    607     if (!log)
    608         return String();
    609 
    610     GLint returnedLogLength = 0;
    611     m_api->glGetShaderSource(shader, logLength, &returnedLogLength, log.get());
    612     ASSERT(logLength == returnedLogLength + 1);
    613 
    614     String result = String::fromUTF8(log.get(), returnedLogLength);
    615     return result;
    616 }
    617 
    618 String GraphicsContext3DPrivate::getString(GC3Denum name)
    619 {
    620     makeContextCurrent();
    621     return String(reinterpret_cast<const char*>(m_api->glGetString(name)));
    622 }
    623 
    624 void GraphicsContext3DPrivate::getTexParameterfv(GC3Denum target, GC3Denum paramName, GC3Dfloat* value)
    625 {
    626     makeContextCurrent();
    627     m_api->glGetTexParameterfv(target, paramName, value);
    628 }
    629 
    630 void GraphicsContext3DPrivate::getTexParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value)
    631 {
    632     makeContextCurrent();
    633     m_api->glGetTexParameteriv(target, paramName, value);
    634 }
    635 
    636 void GraphicsContext3DPrivate::getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value)
    637 {
    638     makeContextCurrent();
    639     m_api->glGetUniformfv(program, location, value);
    640 }
    641 
    642 void GraphicsContext3DPrivate::getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value)
    643 {
    644     makeContextCurrent();
    645     m_api->glGetUniformiv(program, location, value);
    646 }
    647 
    648 GC3Dint GraphicsContext3DPrivate::getUniformLocation(Platform3DObject program, const String& name)
    649 {
    650     makeContextCurrent();
    651     return m_api->glGetUniformLocation(program, name.utf8().data());
    652 }
    653 
    654 void GraphicsContext3DPrivate::getVertexAttribfv(GC3Duint index, GC3Denum paramName, GC3Dfloat* value)
    655 {
    656     makeContextCurrent();
    657     m_api->glGetVertexAttribfv(index, paramName, value);
    658 }
    659 
    660 void GraphicsContext3DPrivate::getVertexAttribiv(GC3Duint index, GC3Denum paramName, GC3Dint* value)
    661 {
    662     makeContextCurrent();
    663     m_api->glGetVertexAttribiv(index, paramName, value);
    664 }
    665 
    666 GC3Dsizeiptr GraphicsContext3DPrivate::getVertexAttribOffset(GC3Duint index, GC3Denum paramName)
    667 {
    668     makeContextCurrent();
    669     void* pointer = 0;
    670     m_api->glGetVertexAttribPointerv(index, paramName, &pointer);
    671     return reinterpret_cast<GC3Dsizeiptr>(pointer);
    672 }
    673 
    674 void GraphicsContext3DPrivate::hint(GC3Denum target, GC3Denum mode)
    675 {
    676     makeContextCurrent();
    677     m_api->glHint(target, mode);
    678 }
    679 
    680 GC3Dboolean GraphicsContext3DPrivate::isBuffer(Platform3DObject buffer)
    681 {
    682     makeContextCurrent();
    683     return m_api->glIsBuffer(buffer);
    684 }
    685 
    686 GC3Dboolean GraphicsContext3DPrivate::isEnabled(GC3Denum cap)
    687 {
    688     makeContextCurrent();
    689     return m_api->glIsEnabled(cap);
    690 }
    691 
    692 GC3Dboolean GraphicsContext3DPrivate::isFramebuffer(Platform3DObject framebuffer)
    693 {
    694     makeContextCurrent();
    695     return m_api->glIsFramebuffer(framebuffer);
    696 }
    697 
    698 GC3Dboolean GraphicsContext3DPrivate::isProgram(Platform3DObject program)
    699 {
    700     makeContextCurrent();
    701     return m_api->glIsProgram(program);
    702 }
    703 
    704 GC3Dboolean GraphicsContext3DPrivate::isRenderbuffer(Platform3DObject renderbuffer)
    705 {
    706     makeContextCurrent();
    707     return m_api->glIsRenderbuffer(renderbuffer);
    708 }
    709 
    710 GC3Dboolean GraphicsContext3DPrivate::isShader(Platform3DObject shader)
    711 {
    712     makeContextCurrent();
    713     return m_api->glIsShader(shader);
    714 }
    715 
    716 GC3Dboolean GraphicsContext3DPrivate::isTexture(Platform3DObject texture)
    717 {
    718     makeContextCurrent();
    719     return m_api->glIsTexture(texture);
    720 }
    721 
    722 void GraphicsContext3DPrivate::lineWidth(GC3Dfloat width)
    723 {
    724     makeContextCurrent();
    725     m_api->glLineWidth(width);
    726 }
    727 
    728 void GraphicsContext3DPrivate::linkProgram(Platform3DObject program)
    729 {
    730     makeContextCurrent();
    731     m_api->glLinkProgram(program);
    732 }
    733 
    734 void GraphicsContext3DPrivate::pixelStorei(GC3Denum paramName, GC3Dint param)
    735 {
    736     makeContextCurrent();
    737     m_api->glPixelStorei(paramName, param);
    738 }
    739 
    740 void GraphicsContext3DPrivate::polygonOffset(GC3Dfloat factor, GC3Dfloat units)
    741 {
    742     makeContextCurrent();
    743     m_api->glPolygonOffset(factor, units);
    744 }
    745 
    746 void GraphicsContext3DPrivate::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data)
    747 {
    748     makeContextCurrent();
    749 
    750     m_api->glFlush();
    751     m_api->glReadPixels(x, y, width, height, format, type, data);
    752 }
    753 
    754 void GraphicsContext3DPrivate::renderbufferStorage(GC3Denum target, GC3Denum internalFormat, GC3Dsizei width, GC3Dsizei height)
    755 {
    756     makeContextCurrent();
    757     m_api->glRenderbufferStorage(target, internalFormat, width, height);
    758 }
    759 
    760 void GraphicsContext3DPrivate::sampleCoverage(GC3Dclampf value, GC3Dboolean invert)
    761 {
    762     makeContextCurrent();
    763     m_api->glSampleCoverage(value, invert);
    764 }
    765 
    766 void GraphicsContext3DPrivate::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    767 {
    768     makeContextCurrent();
    769     m_api->glScissor(x, y, width, height);
    770 }
    771 
    772 void GraphicsContext3DPrivate::shaderSource(Platform3DObject shader, const String& string)
    773 {
    774     makeContextCurrent();
    775     const char* str = string.utf8().data();
    776     int length = string.length();
    777     m_api->glShaderSource(shader, 1, &str, &length);
    778 }
    779 
    780 void GraphicsContext3DPrivate::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask)
    781 {
    782     makeContextCurrent();
    783     m_api->glStencilFunc(func, ref, mask);
    784 }
    785 
    786 void GraphicsContext3DPrivate::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask)
    787 {
    788     makeContextCurrent();
    789     m_api->glStencilFuncSeparate(face, func, ref, mask);
    790 }
    791 
    792 void GraphicsContext3DPrivate::stencilMask(GC3Duint mask)
    793 {
    794     makeContextCurrent();
    795     m_api->glStencilMask(mask);
    796 }
    797 
    798 void GraphicsContext3DPrivate::stencilMaskSeparate(GC3Denum face, GC3Duint mask)
    799 {
    800     makeContextCurrent();
    801     m_api->glStencilMaskSeparate(face, mask);
    802 }
    803 
    804 void GraphicsContext3DPrivate::stencilOp(GC3Denum fail, GC3Denum zFail, GC3Denum zPass)
    805 {
    806     makeContextCurrent();
    807     m_api->glStencilOp(fail, zFail, zPass);
    808 }
    809 
    810 void GraphicsContext3DPrivate::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zFail, GC3Denum zPass)
    811 {
    812     makeContextCurrent();
    813     m_api->glStencilOpSeparate(face, fail, zFail, zPass);
    814 }
    815 
    816 bool GraphicsContext3DPrivate::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
    817 {
    818     makeContextCurrent();
    819     m_api->glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
    820     return true;
    821 }
    822 
    823 void GraphicsContext3DPrivate::texParameterf(GC3Denum target, GC3Denum paramName, GC3Dfloat param)
    824 {
    825     makeContextCurrent();
    826     m_api->glTexParameterf(target, paramName, param);
    827 }
    828 
    829 void GraphicsContext3DPrivate::texParameteri(GC3Denum target, GC3Denum paramName, GC3Dint param)
    830 {
    831     makeContextCurrent();
    832     m_api->glTexParameteri(target, paramName, param);
    833 }
    834 
    835 void GraphicsContext3DPrivate::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xOffset, GC3Dint yOffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels)
    836 {
    837     makeContextCurrent();
    838     m_api->glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, pixels);
    839 }
    840 
    841 void GraphicsContext3DPrivate::uniform1f(GC3Dint location, GC3Dfloat x)
    842 {
    843     makeContextCurrent();
    844     m_api->glUniform1f(location, x);
    845 }
    846 
    847 void GraphicsContext3DPrivate::uniform1fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* array)
    848 {
    849     makeContextCurrent();
    850     m_api->glUniform1fv(location, size, array);
    851 }
    852 
    853 void GraphicsContext3DPrivate::uniform1i(GC3Dint location, GC3Dint x)
    854 {
    855     makeContextCurrent();
    856     m_api->glUniform1i(location, x);
    857 }
    858 
    859 void GraphicsContext3DPrivate::uniform1iv(GC3Dint location, GC3Dsizei size, GC3Dint* array)
    860 {
    861     makeContextCurrent();
    862     m_api->glUniform1iv(location, size, array);
    863 }
    864 
    865 void GraphicsContext3DPrivate::uniform2f(GC3Dint location, GC3Dfloat x, GC3Dfloat y)
    866 {
    867     makeContextCurrent();
    868     m_api->glUniform2f(location, x, y);
    869 }
    870 
    871 void GraphicsContext3DPrivate::uniform2fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* array)
    872 {
    873     makeContextCurrent();
    874     m_api->glUniform2fv(location, size, array);
    875 }
    876 
    877 void GraphicsContext3DPrivate::uniform2i(GC3Dint location, GC3Dint x, GC3Dint y)
    878 {
    879     makeContextCurrent();
    880     m_api->glUniform2i(location, x, y);
    881 }
    882 
    883 void GraphicsContext3DPrivate::uniform2iv(GC3Dint location, GC3Dsizei size, GC3Dint* array)
    884 {
    885     makeContextCurrent();
    886     m_api->glUniform2iv(location, size, array);
    887 }
    888 
    889 void GraphicsContext3DPrivate::uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z)
    890 {
    891     makeContextCurrent();
    892     m_api->glUniform3f(location, x, y, z);
    893 }
    894 
    895 void GraphicsContext3DPrivate::uniform3fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* array)
    896 {
    897     makeContextCurrent();
    898     m_api->glUniform3fv(location, size, array);
    899 }
    900 
    901 void GraphicsContext3DPrivate::uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z)
    902 {
    903     makeContextCurrent();
    904     m_api->glUniform3i(location, x, y, z);
    905 }
    906 
    907 void GraphicsContext3DPrivate::uniform3iv(GC3Dint location, GC3Dsizei size, GC3Dint* array)
    908 {
    909     makeContextCurrent();
    910     m_api->glUniform3iv(location, size, array);
    911 }
    912 
    913 void GraphicsContext3DPrivate::uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w)
    914 {
    915     makeContextCurrent();
    916     m_api->glUniform4f(location, x, y, z, w);
    917 }
    918 
    919 void GraphicsContext3DPrivate::uniform4fv(GC3Dint location, GC3Dsizei size, GC3Dfloat* array)
    920 {
    921     makeContextCurrent();
    922     m_api->glUniform4fv(location, size, array);
    923 }
    924 
    925 void GraphicsContext3DPrivate::uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w)
    926 {
    927     makeContextCurrent();
    928     m_api->glUniform4i(location, x, y, z, w);
    929 }
    930 
    931 void GraphicsContext3DPrivate::uniform4iv(GC3Dint location, GC3Dsizei size, GC3Dint* array)
    932 {
    933     makeContextCurrent();
    934     m_api->glUniform4iv(location, size, array);
    935 }
    936 
    937 void GraphicsContext3DPrivate::uniformMatrix2fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value)
    938 {
    939     makeContextCurrent();
    940     m_api->glUniformMatrix2fv(location, size, transpose, value);
    941 }
    942 
    943 void GraphicsContext3DPrivate::uniformMatrix3fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value)
    944 {
    945     makeContextCurrent();
    946     m_api->glUniformMatrix3fv(location, size, transpose, value);
    947 }
    948 
    949 void GraphicsContext3DPrivate::uniformMatrix4fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, GC3Dfloat* value)
    950 {
    951     makeContextCurrent();
    952     m_api->glUniformMatrix4fv(location, size, transpose, value);
    953 }
    954 
    955 void GraphicsContext3DPrivate::useProgram(Platform3DObject program)
    956 {
    957     makeContextCurrent();
    958     m_api->glUseProgram(program);
    959 }
    960 
    961 void GraphicsContext3DPrivate::validateProgram(Platform3DObject program)
    962 {
    963     makeContextCurrent();
    964     m_api->glValidateProgram(program);
    965 }
    966 
    967 void GraphicsContext3DPrivate::vertexAttrib1f(GC3Duint index, GC3Dfloat x)
    968 {
    969     makeContextCurrent();
    970     m_api->glVertexAttrib1f(index, x);
    971 }
    972 
    973 void GraphicsContext3DPrivate::vertexAttrib1fv(GC3Duint index, GC3Dfloat* values)
    974 {
    975     makeContextCurrent();
    976     m_api->glVertexAttrib1fv(index, values);
    977 }
    978 
    979 void GraphicsContext3DPrivate::vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y)
    980 {
    981     makeContextCurrent();
    982     m_api->glVertexAttrib2f(index, x, y);
    983 }
    984 
    985 void GraphicsContext3DPrivate::vertexAttrib2fv(GC3Duint index, GC3Dfloat* values)
    986 {
    987     makeContextCurrent();
    988     m_api->glVertexAttrib2fv(index, values);
    989 }
    990 
    991 void GraphicsContext3DPrivate::vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z)
    992 {
    993     makeContextCurrent();
    994     m_api->glVertexAttrib3f(index, x, y, z);
    995 }
    996 
    997 void GraphicsContext3DPrivate::vertexAttrib3fv(GC3Duint index, GC3Dfloat* values)
    998 {
    999     makeContextCurrent();
    1000     m_api->glVertexAttrib3fv(index, values);
    1001 }
    1002 
    1003 void GraphicsContext3DPrivate::vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w)
    1004 {
    1005     makeContextCurrent();
    1006     m_api->glVertexAttrib4f(index, x, y, z, w);
    1007 }
    1008 
    1009 void GraphicsContext3DPrivate::vertexAttrib4fv(GC3Duint index, GC3Dfloat* values)
    1010 {
    1011     makeContextCurrent();
    1012     m_api->glVertexAttrib4fv(index, values);
    1013 }
    1014 
    1015 void GraphicsContext3DPrivate::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset)
    1016 {
    1017     makeContextCurrent();
    1018 
    1019     if (m_boundArrayBuffer <= 0)
    1020         return;
    1021 
    1022     m_api->glVertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
    1023 }
    1024 
    1025 void GraphicsContext3DPrivate::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    1026 {
    1027     makeContextCurrent();
    1028     m_api->glViewport(x, y, width, height);
    1029 }
    1030 
    1031 Platform3DObject GraphicsContext3DPrivate::createBuffer()
    1032 {
    1033     makeContextCurrent();
    1034     Platform3DObject buffer = 0;
    1035     m_api->glGenBuffers(1, &buffer);
    1036     return buffer;
    1037 }
    1038 
    1039 Platform3DObject GraphicsContext3DPrivate::createFramebuffer()
    1040 {
    1041     makeContextCurrent();
    1042     Platform3DObject buffer = 0;
    1043     m_api->glGenFramebuffers(1, &buffer);
    1044     return buffer;
    1045 }
    1046 
    1047 Platform3DObject GraphicsContext3DPrivate::createProgram()
    1048 {
    1049     makeContextCurrent();
    1050     return m_api->glCreateProgram();
    1051 }
    1052 
    1053 Platform3DObject GraphicsContext3DPrivate::createRenderbuffer()
    1054 {
    1055     makeContextCurrent();
    1056     Platform3DObject buffer;
    1057     m_api->glGenRenderbuffers(1, &buffer);
    1058     return buffer;
    1059 }
    1060 
    1061 Platform3DObject GraphicsContext3DPrivate::createShader(GC3Denum shaderType)
    1062 {
    1063     makeContextCurrent();
    1064     return m_api->glCreateShader(shaderType);
    1065 }
    1066 
    1067 Platform3DObject GraphicsContext3DPrivate::createTexture()
    1068 {
    1069     makeContextCurrent();
    1070     Platform3DObject texture;
    1071     m_api->glGenTextures(1, &texture);
    1072     return texture;
    1073 }
    1074 
    1075 void GraphicsContext3DPrivate::deleteBuffer(Platform3DObject buffer)
    1076 {
    1077     makeContextCurrent();
    1078     m_api->glDeleteBuffers(1, &buffer);
    1079 }
    1080 
    1081 void GraphicsContext3DPrivate::deleteFramebuffer(Platform3DObject framebuffer)
    1082 {
    1083     makeContextCurrent();
    1084     if (framebuffer == m_boundFBO) {
    1085         // Make sure the framebuffer is not going to be used for drawing
    1086         // operations after it gets deleted.
    1087         bindFramebuffer(FRAMEBUFFER, 0);
    1088     }
    1089     m_api->glDeleteFramebuffers(1, &framebuffer);
    1090 }
    1091 
    1092 void GraphicsContext3DPrivate::deleteProgram(Platform3DObject program)
    1093 {
    1094     makeContextCurrent();
    1095     m_api->glDeleteProgram(program);
    1096 }
    1097 
    1098 void GraphicsContext3DPrivate::deleteRenderbuffer(Platform3DObject renderbuffer)
    1099 {
    1100     makeContextCurrent();
    1101     m_api->glDeleteRenderbuffers(1, &renderbuffer);
    1102 }
    1103 
    1104 void GraphicsContext3DPrivate::deleteShader(Platform3DObject shader)
    1105 {
    1106     makeContextCurrent();
    1107     m_api->glDeleteShader(shader);
    1108 }
    1109 
    1110 void GraphicsContext3DPrivate::deleteTexture(Platform3DObject texture)
    1111 {
    1112     makeContextCurrent();
    1113     m_api->glDeleteTextures(1, &texture);
    1114 }
    1115 
    1116 void GraphicsContext3DPrivate::synthesizeGLError(GC3Denum error)
    1117 {
    1118     m_syntheticErrors.add(error);
    1119 }
    1120 
    1121 Extensions3D* GraphicsContext3DPrivate::getExtensions()
     167#if USE(TEXTURE_MAPPER_GL)
     168void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask)
    1122169{
    1123170    notImplemented();
    1124     return 0;
    1125171}
    1126 
     172#endif
    1127173} // namespace WebCore
    1128174
  • trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h

    r109696 r130966  
    2323#include "GraphicsContext3D.h"
    2424
    25 #include <Evas_GL.h>
     25#if USE(TEXTURE_MAPPER_GL)
     26#include <texmap/TextureMapperPlatformLayer.h>
     27#endif
    2628
    27 namespace WebCore {
     29typedef struct _Evas_GL               Evas_GL;
     30typedef struct _Evas_GL_Surface       Evas_GL_Surface;
     31typedef struct _Evas_GL_Context       Evas_GL_Context;
     32typedef struct _Evas_GL_Config        Evas_GL_Config;
     33typedef struct _Evas_GL_API           Evas_GL_API;
    2834
    2935class PageClientEfl;
    3036
    31 class GraphicsContext3DPrivate {
     37namespace WebCore {
     38class GraphicsContext3DPrivate
     39#if USE(TEXTURE_MAPPER_GL)
     40        : public TextureMapperPlatformLayer
     41#endif
     42{
    3243public:
    33     static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D::Attributes attrs, HostWindow*, bool renderDirectlyToEvasGLObject);
     44    GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle);
    3445    ~GraphicsContext3DPrivate();
    3546
     
    3950    PlatformLayer* platformLayer() const;
    4051#endif
    41 
     52#if USE(TEXTURE_MAPPER_GL)
     53    virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
     54#endif
    4255    bool makeContextCurrent();
    43 
    44     bool isGLES2Compliant() const;
    45 
    46     void activeTexture(GC3Denum texture);
    47     void attachShader(Platform3DObject program, Platform3DObject shader);
    48     void bindAttribLocation(Platform3DObject, GC3Duint index, const String& name);
    49     void bindBuffer(GC3Denum target, Platform3DObject);
    50     void bindFramebuffer(GC3Denum target, Platform3DObject);
    51     void bindRenderbuffer(GC3Denum target, Platform3DObject);
    52     void bindTexture(GC3Denum target, Platform3DObject);
    53     void blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha);
    54     void blendEquation(GC3Denum mode);
    55     void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha);
    56     void blendFunc(GC3Denum srcFactor, GC3Denum dstFactor);
    57     void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha);
    58 
    59     void bufferData(GC3Denum target, GC3Dsizeiptr, const void* data, GC3Denum usage);
    60     void bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr, const void* data);
    61 
    62     GC3Denum checkFramebufferStatus(GC3Denum target);
    63     void clear(GC3Dbitfield mask);
    64     void clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha);
    65     void clearDepth(GC3Dclampf depth);
    66     void clearStencil(GC3Dint clearValue);
    67     void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha);
    68     void compileShader(Platform3DObject);
    69 
    70     void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border);
    71     void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xOffset, GC3Dint yOffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
    72     void cullFace(GC3Denum mode);
    73     void depthFunc(GC3Denum func);
    74     void depthMask(GC3Dboolean flag);
    75     void depthRange(GC3Dclampf zNear, GC3Dclampf zFar);
    76     void detachShader(Platform3DObject, Platform3DObject);
    77     void disable(GC3Denum cap);
    78     void disableVertexAttribArray(GC3Duint index);
    79     void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count);
    80     void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset);
    81 
    82     void enable(GC3Denum cap);
    83     void enableVertexAttribArray(GC3Duint index);
    84     void finish();
    85     void flush();
    86     void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbufferTarget, Platform3DObject);
    87     void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum texTarget, Platform3DObject, GC3Dint level);
    88     void frontFace(GC3Denum mode);
    89     void generateMipmap(GC3Denum target);
    90 
    91     bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&);
    92     bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&);
    93     void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders);
    94     GC3Dint getAttribLocation(Platform3DObject, const String& name);
    95     void getBooleanv(GC3Denum paramName, GC3Dboolean* value);
    96     void getBufferParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value);
    97     GraphicsContext3D::Attributes getContextAttributes();
    98     GC3Denum getError();
    99     void getFloatv(GC3Denum paramName, GC3Dfloat* value);
    100     void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum paramName, GC3Dint* value);
    101     void getIntegerv(GC3Denum paramName, GC3Dint* value);
    102     void getProgramiv(Platform3DObject program, GC3Denum paramName, GC3Dint* value);
    103     String getProgramInfoLog(Platform3DObject);
    104     void getRenderbufferParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value);
    105     void getShaderiv(Platform3DObject, GC3Denum paramName, GC3Dint* value);
    106     String getShaderInfoLog(Platform3DObject);
    107 
    108     String getShaderSource(Platform3DObject);
    109     String getString(GC3Denum name);
    110     void getTexParameterfv(GC3Denum target, GC3Denum paramName, GC3Dfloat* value);
    111     void getTexParameteriv(GC3Denum target, GC3Denum paramName, GC3Dint* value);
    112     void getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value);
    113     void getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value);
    114     GC3Dint getUniformLocation(Platform3DObject, const String& name);
    115     void getVertexAttribfv(GC3Duint index, GC3Denum paramName, GC3Dfloat* value);
    116     void getVertexAttribiv(GC3Duint index, GC3Denum paramName, GC3Dint* value);
    117     GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum paramName);
    118 
    119     void hint(GC3Denum target, GC3Denum mode);
    120     GC3Dboolean isBuffer(Platform3DObject);
    121     GC3Dboolean isEnabled(GC3Denum cap);
    122     GC3Dboolean isFramebuffer(Platform3DObject);
    123     GC3Dboolean isProgram(Platform3DObject);
    124     GC3Dboolean isRenderbuffer(Platform3DObject);
    125     GC3Dboolean isShader(Platform3DObject);
    126     GC3Dboolean isTexture(Platform3DObject);
    127     void lineWidth(GC3Dfloat);
    128     void linkProgram(Platform3DObject);
    129     void pixelStorei(GC3Denum paramName, GC3Dint param);
    130     void polygonOffset(GC3Dfloat factor, GC3Dfloat units);
    131 
    132     void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data);
    133 
    134     void renderbufferStorage(GC3Denum target, GC3Denum internalFormat, GC3Dsizei width, GC3Dsizei height);
    135     void sampleCoverage(GC3Dclampf value, GC3Dboolean invert);
    136     void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
    137     void shaderSource(Platform3DObject, const String&);
    138     void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask);
    139     void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask);
    140     void stencilMask(GC3Duint mask);
    141     void stencilMaskSeparate(GC3Denum face, GC3Duint mask);
    142     void stencilOp(GC3Denum fail, GC3Denum zFail, GC3Denum zPass);
    143     void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zFail, GC3Denum zPass);
    144 
    145     bool texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalFormat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels);
    146     void texParameterf(GC3Denum target, GC3Denum paramName, GC3Dfloat param);
    147     void texParameteri(GC3Denum target, GC3Denum paramName, GC3Dint param);
    148     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xOffset, GC3Dint yOffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels);
    149 
    150     void uniform1f(GC3Dint location, GC3Dfloat x);
    151     void uniform1fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v);
    152     void uniform1i(GC3Dint location, GC3Dint x);
    153     void uniform1iv(GC3Dint location, GC3Dsizei, GC3Dint* v);
    154     void uniform2f(GC3Dint location, GC3Dfloat x, float y);
    155     void uniform2fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v);
    156     void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y);
    157     void uniform2iv(GC3Dint location, GC3Dsizei, GC3Dint* v);
    158     void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z);
    159     void uniform3fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v);
    160     void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z);
    161     void uniform3iv(GC3Dint location, GC3Dsizei, GC3Dint* v);
    162     void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w);
    163     void uniform4fv(GC3Dint location, GC3Dsizei, GC3Dfloat* v);
    164     void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w);
    165     void uniform4iv(GC3Dint location, GC3Dsizei, GC3Dint* v);
    166     void uniformMatrix2fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value);
    167     void uniformMatrix3fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value);
    168     void uniformMatrix4fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, GC3Dfloat* value);
    169 
    170     void useProgram(Platform3DObject);
    171     void validateProgram(Platform3DObject);
    172 
    173     void vertexAttrib1f(GC3Duint index, GC3Dfloat x);
    174     void vertexAttrib1fv(GC3Duint index, GC3Dfloat* values);
    175     void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y);
    176     void vertexAttrib2fv(GC3Duint index, GC3Dfloat* values);
    177     void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z);
    178     void vertexAttrib3fv(GC3Duint index, GC3Dfloat* values);
    179     void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w);
    180     void vertexAttrib4fv(GC3Duint index, GC3Dfloat* values);
    181     void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized,
    182                              GC3Dsizei stride, GC3Dintptr offset);
    183 
    184     void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
    185 
    186     Platform3DObject createBuffer();
    187     Platform3DObject createFramebuffer();
    188     Platform3DObject createProgram();
    189     Platform3DObject createRenderbuffer();
    190     Platform3DObject createShader(GC3Denum);
    191     Platform3DObject createTexture();
    192 
    193     void deleteBuffer(Platform3DObject);
    194     void deleteFramebuffer(Platform3DObject);
    195     void deleteProgram(Platform3DObject);
    196     void deleteRenderbuffer(Platform3DObject);
    197     void deleteShader(Platform3DObject);
    198     void deleteTexture(Platform3DObject);
    199 
    200     void synthesizeGLError(GC3Denum error);
    201 
    202     Extensions3D* getExtensions();
    203 
    204 private:
    205     GraphicsContext3DPrivate();
    206 
    207     bool initialize(GraphicsContext3D::Attributes attrs, HostWindow*, bool renderDirectlyToHostWindow);
    208 
    20956    bool createSurface(PageClientEfl*, bool renderDirectlyToEvasGLObject);
     57    void setCurrentGLContext(void*, void*);
    21058
    21159    GraphicsContext3D::Attributes m_attributes;
    212 
    213     Platform3DObject m_boundFBO;
    214     Platform3DObject m_boundTexture;
    215     Platform3DObject m_boundArrayBuffer;
     60    GraphicsContext3D* m_context;
     61    HostWindow* m_hostWindow;
    21662
    21763    ListHashSet<GC3Denum> m_syntheticErrors;
    21864
     65    OwnPtr<Ecore_Evas> m_ecoreEvas;
    21966    Evas_GL* m_evasGL;
    220     Evas_GL_Context* m_context;
    221     Evas_GL_Surface* m_surface;
     67    Evas_GL_Context* m_evasGLContext;
     68    Evas_GL_Surface* m_evasGLSurface;
     69    void* m_glContext;
     70    void* m_glSurface;
    22271    Evas_GL_API* m_api;
     72    GraphicsContext3D::RenderStyle m_renderStyle;
    22373};
    22474
Note: See TracChangeset for help on using the changeset viewer.