Changeset 127063 in webkit


Ignore:
Timestamp:
Aug 29, 2012 4:12:45 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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

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

It is based on a previous patch by Helder Correia.

TextureMapperGL (TMGL) includes direct GL calls and
GraphicsContext3D (GC3D) offers many conveniences over the
former approach: using existing CSS shader code, ANGLE for
shader compilation, reusing WebCore::Texture, having shaders and
textures that can delete themselves.

A GC3D object is created by TMGL with the newly introduced
builder createForCurrentGLContext(), which in turn uses
the new RenderToCurrentGLContext flag underneath.

TMGL's dependency on OpenGLShims.h was completely removed.
However, GC3D does not map every single GL constant. Thus, it's
important to document the following:

  • GL_FALSE was mapped to false.
  • GL_UNPACK_ROW_LENGTH, GL_UNPACK_SKIP_PIXELS, GL_UNPACK_SKIP_ROWS, GL_TEXTURE_RECTANGLE_ARB, and GL_UNSIGNED_INT_8_8_8_8_REV were locally defined in TMGL.

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

No new tests, refactoring.

  • platform/graphics/GraphicsContext3D.h:
  • platform/graphics/texmap/TextureMapperGL.cpp:

(SharedGLData):
(WebCore::TextureMapperGLData::SharedGLData::currentSharedGLData):
(WebCore::TextureMapperGLData::SharedGLData::SharedGLData):
(WebCore::TextureMapperGLData::sharedGLData):
(WebCore::TextureMapperGLData::TextureMapperGLData):
(TextureMapperGLData):
(WebCore::scissorClip):
(WebCore::TextureMapperGL::ClipStack::apply):
(WebCore::TextureMapperGLData::initializeStencil):
(WebCore::TextureMapperGL::TextureMapperGL):
(WebCore::TextureMapperGL::beginPainting):
(WebCore::TextureMapperGL::endPainting):
(WebCore::TextureMapperGL::drawQuad):
(WebCore::TextureMapperGL::drawBorder):
(WebCore):
(WebCore::TextureMapperGL::drawTextureRectangleARB):
(WebCore::TextureMapperGL::drawTexture):
(WebCore::viewportMatrix):
(WebCore::TextureMapperGL::drawTextureWithAntialiasing):
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
(WebCore::BitmapTextureGL::didReset):
(WebCore::BitmapTextureGL::updateContents):
(WebCore::TextureMapperGL::drawFiltered):
(WebCore::BitmapTextureGL::initializeStencil):
(WebCore::BitmapTextureGL::clearIfNeeded):
(WebCore::BitmapTextureGL::createFboIfNeeded):
(WebCore::BitmapTextureGL::bind):
(WebCore::BitmapTextureGL::~BitmapTextureGL):
(WebCore::TextureMapperGL::bindDefaultSurface):
(WebCore::TextureMapperGL::beginScissorClip):
(WebCore::TextureMapperGL::beginClip):
(WebCore::TextureMapperGL::endClip):
(WebCore::TextureMapperGL::createTexture):

  • platform/graphics/texmap/TextureMapperGL.h:

(WebCore::TextureMapperGL::graphicsContext3D):
(TextureMapperGL):
(ClipStack):
(WebCore::BitmapTextureGL::textureTarget):
(BitmapTextureGL):
(WebCore::BitmapTextureGL::BitmapTextureGL):

  • platform/graphics/texmap/TextureMapperShaderManager.cpp:

(WebCore):
(WebCore::TextureMapperShaderManager::getShaderProgram):
(WebCore::TextureMapperShaderProgram::TextureMapperShaderProgram):
(WebCore::TextureMapperShaderProgram::initializeProgram):
(WebCore::TextureMapperShaderProgram::getUniformLocation):
(WebCore::TextureMapperShaderProgram::~TextureMapperShaderProgram):
(WebCore::TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple):
(WebCore::TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor):
(WebCore::TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple):
(WebCore::TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask):
(WebCore::TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask):
(WebCore::TextureMapperShaderProgramAntialiasingNoMask::TextureMapperShaderProgramAntialiasingNoMask):
(WebCore::TextureMapperShaderManager::TextureMapperShaderManager):
(WebCore::StandardFilterProgram::~StandardFilterProgram):
(WebCore::StandardFilterProgram::StandardFilterProgram):
(WebCore::StandardFilterProgram::create):
(WebCore::StandardFilterProgram::prepare):
(WebCore::TextureMapperShaderManager::getShaderForFilter):

  • platform/graphics/texmap/TextureMapperShaderManager.h:

(WebCore::TextureMapperShaderProgram::id):
(WebCore::TextureMapperShaderProgram::vertexAttrib):
(TextureMapperShaderProgram):
(WebCore::TextureMapperShaderProgram::matrixLocation):
(WebCore::TextureMapperShaderProgram::flipLocation):
(WebCore::TextureMapperShaderProgram::textureSizeLocation):
(WebCore::TextureMapperShaderProgram::sourceTextureLocation):
(WebCore::TextureMapperShaderProgram::maskTextureLocation):
(WebCore::TextureMapperShaderProgram::opacityLocation):
(WebCore::TextureMapperShaderProgram::isValidUniformLocation):
(StandardFilterProgram):
(WebCore::StandardFilterProgram::vertexAttrib):
(WebCore::StandardFilterProgram::texCoordAttrib):
(WebCore::StandardFilterProgram::textureUniform):
(WebCore::TextureMapperShaderProgramSimple::create):
(TextureMapperShaderProgramSimple):
(WebCore::TextureMapperShaderProgramRectSimple::create):
(TextureMapperShaderProgramRectSimple):
(WebCore::TextureMapperShaderProgramOpacityAndMask::create):
(TextureMapperShaderProgramOpacityAndMask):
(WebCore::TextureMapperShaderProgramRectOpacityAndMask::create):
(TextureMapperShaderProgramRectOpacityAndMask):
(WebCore::TextureMapperShaderProgramSolidColor::create):
(WebCore::TextureMapperShaderProgramSolidColor::colorLocation):
(TextureMapperShaderProgramSolidColor):
(WebCore::TextureMapperShaderProgramAntialiasingNoMask::create):
(WebCore::TextureMapperShaderProgramAntialiasingNoMask::expandedQuadVerticesInTextureCoordinatesLocation):
(WebCore::TextureMapperShaderProgramAntialiasingNoMask::expandedQuadEdgesInScreenSpaceLocation):
(TextureMapperShaderProgramAntialiasingNoMask):
(WebCore::TextureMapperShaderManager::TextureMapperShaderManager):
(TextureMapperShaderManager):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r127062 r127063  
     12012-08-29  Roland Takacs  <rtakacs@inf.u-szeged.hu>, Helder Correia  <helder.correia@nokia.com>
     2
     3        [Texmap] Move TextureMapperGL to use GraphicsContext3D
     4        https://bugs.webkit.org/show_bug.cgi?id=78672
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        It is based on a previous patch by Helder Correia.
     9
     10        TextureMapperGL (TMGL) includes direct GL calls and
     11        GraphicsContext3D (GC3D) offers many conveniences over the
     12        former approach: using existing CSS shader code, ANGLE for
     13        shader compilation, reusing WebCore::Texture, having shaders and
     14        textures that can delete themselves.
     15
     16        A GC3D object is created by TMGL with the newly introduced
     17        builder createForCurrentGLContext(), which in turn uses
     18        the new RenderToCurrentGLContext flag underneath.
     19
     20        TMGL's dependency on OpenGLShims.h was completely removed.
     21        However, GC3D does not map every single GL constant. Thus, it's
     22        important to document the following:
     23            - GL_FALSE was mapped to false.
     24            - GL_UNPACK_ROW_LENGTH, GL_UNPACK_SKIP_PIXELS,
     25            GL_UNPACK_SKIP_ROWS, GL_TEXTURE_RECTANGLE_ARB, and
     26            GL_UNSIGNED_INT_8_8_8_8_REV were locally defined in TMGL.
     27
     28        The patch was originally developed by Helder Correia and finished
     29        by Roland Takacs.
     30
     31        No new tests, refactoring.
     32
     33        * platform/graphics/GraphicsContext3D.h:
     34        * platform/graphics/texmap/TextureMapperGL.cpp:
     35        (SharedGLData):
     36        (WebCore::TextureMapperGLData::SharedGLData::currentSharedGLData):
     37        (WebCore::TextureMapperGLData::SharedGLData::SharedGLData):
     38        (WebCore::TextureMapperGLData::sharedGLData):
     39        (WebCore::TextureMapperGLData::TextureMapperGLData):
     40        (TextureMapperGLData):
     41        (WebCore::scissorClip):
     42        (WebCore::TextureMapperGL::ClipStack::apply):
     43        (WebCore::TextureMapperGLData::initializeStencil):
     44        (WebCore::TextureMapperGL::TextureMapperGL):
     45        (WebCore::TextureMapperGL::beginPainting):
     46        (WebCore::TextureMapperGL::endPainting):
     47        (WebCore::TextureMapperGL::drawQuad):
     48        (WebCore::TextureMapperGL::drawBorder):
     49        (WebCore):
     50        (WebCore::TextureMapperGL::drawTextureRectangleARB):
     51        (WebCore::TextureMapperGL::drawTexture):
     52        (WebCore::viewportMatrix):
     53        (WebCore::TextureMapperGL::drawTextureWithAntialiasing):
     54        (WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
     55        (WebCore::BitmapTextureGL::didReset):
     56        (WebCore::BitmapTextureGL::updateContents):
     57        (WebCore::TextureMapperGL::drawFiltered):
     58        (WebCore::BitmapTextureGL::initializeStencil):
     59        (WebCore::BitmapTextureGL::clearIfNeeded):
     60        (WebCore::BitmapTextureGL::createFboIfNeeded):
     61        (WebCore::BitmapTextureGL::bind):
     62        (WebCore::BitmapTextureGL::~BitmapTextureGL):
     63        (WebCore::TextureMapperGL::bindDefaultSurface):
     64        (WebCore::TextureMapperGL::beginScissorClip):
     65        (WebCore::TextureMapperGL::beginClip):
     66        (WebCore::TextureMapperGL::endClip):
     67        (WebCore::TextureMapperGL::createTexture):
     68        * platform/graphics/texmap/TextureMapperGL.h:
     69        (WebCore::TextureMapperGL::graphicsContext3D):
     70        (TextureMapperGL):
     71        (ClipStack):
     72        (WebCore::BitmapTextureGL::textureTarget):
     73        (BitmapTextureGL):
     74        (WebCore::BitmapTextureGL::BitmapTextureGL):
     75        * platform/graphics/texmap/TextureMapperShaderManager.cpp:
     76        (WebCore):
     77        (WebCore::TextureMapperShaderManager::getShaderProgram):
     78        (WebCore::TextureMapperShaderProgram::TextureMapperShaderProgram):
     79        (WebCore::TextureMapperShaderProgram::initializeProgram):
     80        (WebCore::TextureMapperShaderProgram::getUniformLocation):
     81        (WebCore::TextureMapperShaderProgram::~TextureMapperShaderProgram):
     82        (WebCore::TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple):
     83        (WebCore::TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor):
     84        (WebCore::TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple):
     85        (WebCore::TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask):
     86        (WebCore::TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask):
     87        (WebCore::TextureMapperShaderProgramAntialiasingNoMask::TextureMapperShaderProgramAntialiasingNoMask):
     88        (WebCore::TextureMapperShaderManager::TextureMapperShaderManager):
     89        (WebCore::StandardFilterProgram::~StandardFilterProgram):
     90        (WebCore::StandardFilterProgram::StandardFilterProgram):
     91        (WebCore::StandardFilterProgram::create):
     92        (WebCore::StandardFilterProgram::prepare):
     93        (WebCore::TextureMapperShaderManager::getShaderForFilter):
     94        * platform/graphics/texmap/TextureMapperShaderManager.h:
     95        (WebCore::TextureMapperShaderProgram::id):
     96        (WebCore::TextureMapperShaderProgram::vertexAttrib):
     97        (TextureMapperShaderProgram):
     98        (WebCore::TextureMapperShaderProgram::matrixLocation):
     99        (WebCore::TextureMapperShaderProgram::flipLocation):
     100        (WebCore::TextureMapperShaderProgram::textureSizeLocation):
     101        (WebCore::TextureMapperShaderProgram::sourceTextureLocation):
     102        (WebCore::TextureMapperShaderProgram::maskTextureLocation):
     103        (WebCore::TextureMapperShaderProgram::opacityLocation):
     104        (WebCore::TextureMapperShaderProgram::isValidUniformLocation):
     105        (StandardFilterProgram):
     106        (WebCore::StandardFilterProgram::vertexAttrib):
     107        (WebCore::StandardFilterProgram::texCoordAttrib):
     108        (WebCore::StandardFilterProgram::textureUniform):
     109        (WebCore::TextureMapperShaderProgramSimple::create):
     110        (TextureMapperShaderProgramSimple):
     111        (WebCore::TextureMapperShaderProgramRectSimple::create):
     112        (TextureMapperShaderProgramRectSimple):
     113        (WebCore::TextureMapperShaderProgramOpacityAndMask::create):
     114        (TextureMapperShaderProgramOpacityAndMask):
     115        (WebCore::TextureMapperShaderProgramRectOpacityAndMask::create):
     116        (TextureMapperShaderProgramRectOpacityAndMask):
     117        (WebCore::TextureMapperShaderProgramSolidColor::create):
     118        (WebCore::TextureMapperShaderProgramSolidColor::colorLocation):
     119        (TextureMapperShaderProgramSolidColor):
     120        (WebCore::TextureMapperShaderProgramAntialiasingNoMask::create):
     121        (WebCore::TextureMapperShaderProgramAntialiasingNoMask::expandedQuadVerticesInTextureCoordinatesLocation):
     122        (WebCore::TextureMapperShaderProgramAntialiasingNoMask::expandedQuadEdgesInScreenSpaceLocation):
     123        (TextureMapperShaderProgramAntialiasingNoMask):
     124        (WebCore::TextureMapperShaderManager::TextureMapperShaderManager):
     125        (TextureMapperShaderManager):
     126
    11272012-08-29  Adam Barth  <abarth@webkit.org>
    2128
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h

    r126743 r127063  
    251251        RGB = 0x1907,
    252252        RGBA = 0x1908,
     253        BGRA = 0x80E1,
    253254        LUMINANCE = 0x1909,
    254255        LUMINANCE_ALPHA = 0x190A,
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp

    r126926 r127063  
    3939#if PLATFORM(QT)
    4040#include "NativeImageQt.h"
    41 #include <QOpenGLContext>
    42 #elif OS(WINDOWS)
    43 #include <windows.h>
    44 #elif OS(MAC_OS_X)
    45 #include <AGL/agl.h>
    46 #elif defined(XP_UNIX)
    47 #include <GL/glx.h>
    4841#endif
    4942
     
    5447#endif
    5548
    56 #define GL_CMD(...) do { __VA_ARGS__; ASSERT_ARG(__VA_ARGS__, !glGetError()); } while (0)
     49#if !USE(TEXMAP_OPENGL_ES_2)
     50// FIXME: Move to Extensions3D.h.
     51#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
     52#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
     53#define GL_UNPACK_ROW_LENGTH 0x0CF2
     54#define GL_UNPACK_SKIP_PIXELS 0x0CF4
     55#define GL_UNPACK_SKIP_ROWS 0x0CF3
     56#endif
     57
    5758namespace WebCore {
    5859struct TextureMapperGLData {
    5960    struct SharedGLData : public RefCounted<SharedGLData> {
    60 #if PLATFORM(QT)
    61         typedef QOpenGLContext* GLContext;
    62         static GLContext getCurrentGLContext()
    63         {
    64             return QOpenGLContext::currentContext();
    65         }
    66 #elif OS(WINDOWS)
    67         typedef HGLRC GLContext;
    68         static GLContext getCurrentGLContext()
    69         {
    70             return wglGetCurrentContext();
    71         }
    72 #elif OS(MAC_OS_X)
    73         typedef AGLContext GLContext;
    74         static GLContext getCurrentGLContext()
    75         {
    76             return aglGetCurrentContext();
    77         }
    78 #elif defined(XP_UNIX)
    79         typedef GLXContext GLContext;
    80         static GLContext getCurrentGLContext()
    81         {
    82             return glXGetCurrentContext();
    83         }
    84 #else
    85         // Default implementation for unknown opengl.
    86         // Returns always increasing number and disables GL context data sharing.
    87         typedef unsigned int GLContext;
    88         static GLContext getCurrentGLContext()
    89         {
    90             static GLContext dummyContextCounter = 0;
    91             return ++dummyContextCounter;
    92         }
    93 
    94 #endif
    95 
    96         typedef HashMap<GLContext, SharedGLData*> GLContextDataMap;
     61
     62        typedef HashMap<PlatformGraphicsContext3D, SharedGLData*> GLContextDataMap;
    9763        static GLContextDataMap& glContextDataMap()
    9864        {
     
    10167        }
    10268
    103         static PassRefPtr<SharedGLData> currentSharedGLData()
     69        static PassRefPtr<SharedGLData> currentSharedGLData(GraphicsContext3D* context)
    10470        {
    105             GLContext currentGLConext = getCurrentGLContext();
    106             GLContextDataMap::iterator it = glContextDataMap().find(currentGLConext);
     71            GLContextDataMap::iterator it = glContextDataMap().find(context->platformGraphicsContext3D());
    10772            if (it != glContextDataMap().end())
    10873                return it->second;
    10974
    110             return adoptRef(new SharedGLData(getCurrentGLContext()));
     75            return adoptRef(new SharedGLData(context));
    11176        }
    11277
     
    11580        TextureMapperShaderManager textureMapperShaderManager;
    11681
    117         SharedGLData(GLContext glContext)
     82        SharedGLData(GraphicsContext3D* context)
     83            : textureMapperShaderManager(context)
    11884        {
    119             glContextDataMap().add(glContext, this);
     85            glContextDataMap().add(context->platformGraphicsContext3D(), this);
    12086        }
    12187
     
    136102    SharedGLData& sharedGLData() const
    137103    {
    138         return *(m_sharedGLData.get());
     104        return *m_sharedGLData;
    139105    }
    140106
    141107    void initializeStencil();
    142108
    143     TextureMapperGLData()
    144         : PaintFlags(0)
     109    TextureMapperGLData(GraphicsContext3D* context)
     110        : context(context)
     111        , PaintFlags(0)
    145112        , previousProgram(0)
    146113        , targetFrameBuffer(0)
     
    148115        , previousScissorState(0)
    149116        , previousDepthState(0)
    150         , m_sharedGLData(TextureMapperGLData::SharedGLData::currentSharedGLData())
     117        , m_sharedGLData(TextureMapperGLData::SharedGLData::currentSharedGLData(this->context))
    151118    { }
    152119
     120    GraphicsContext3D* context;
    153121    TransformationMatrix projectionMatrix;
    154122    TextureMapper::PaintFlags PaintFlags;
    155     GLint previousProgram;
    156     GLint targetFrameBuffer;
     123    GC3Dint previousProgram;
     124    GC3Dint targetFrameBuffer;
    157125    bool didModifyStencil;
    158     GLint previousScissorState;
    159     GLint previousDepthState;
    160     GLint viewport[4];
    161     GLint previousScissor[4];
     126    GC3Dint previousScissorState;
     127    GC3Dint previousDepthState;
     128    GC3Dint viewport[4];
     129    GC3Dint previousScissor[4];
    162130    RefPtr<SharedGLData> m_sharedGLData;
    163131    RefPtr<BitmapTexture> currentSurface;
     
    183151}
    184152
    185 static void scissorClip(const IntRect& rect)
     153static void scissorClip(GraphicsContext3D* context, const IntRect& rect)
    186154{
    187155    if (rect.isEmpty())
    188156        return;
    189157
    190     GLint viewport[4];
    191     GL_CMD(glGetIntegerv(GL_VIEWPORT, viewport));
    192     GL_CMD(glScissor(rect.x(), viewport[3] - rect.maxY(), rect.width(), rect.height()));
    193 }
    194 
    195 void TextureMapperGL::ClipStack::apply()
    196 {
    197     scissorClip(clipState.scissorBox);
    198     GL_CMD(glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP));
    199     GL_CMD(glStencilFunc(GL_EQUAL, clipState.stencilIndex - 1, clipState.stencilIndex - 1));
     158    GC3Dint viewport[4];
     159    context->getIntegerv(GraphicsContext3D::VIEWPORT, viewport);
     160    context->scissor(rect.x(), viewport[3] - rect.maxY(), rect.width(), rect.height());
     161}
     162
     163void TextureMapperGL::ClipStack::apply(GraphicsContext3D* context)
     164{
     165    scissorClip(context, clipState.scissorBox);
     166    context->stencilOp(GraphicsContext3D::KEEP, GraphicsContext3D::KEEP, GraphicsContext3D::KEEP);
     167    context->stencilFunc(GraphicsContext3D::EQUAL, clipState.stencilIndex - 1, clipState.stencilIndex - 1);
    200168    if (clipState.stencilIndex == 1)
    201         GL_CMD(glDisable(GL_STENCIL_TEST));
     169        context->disable(GraphicsContext3D::STENCIL_TEST);
    202170    else
    203         GL_CMD(glEnable(GL_STENCIL_TEST));
     171        context->enable(GraphicsContext3D::STENCIL_TEST);
    204172}
    205173
     
    215183        return;
    216184
    217     GL_CMD(glClearStencil(0));
    218     GL_CMD(glClear(GL_STENCIL_BUFFER_BIT));
     185    context->clearStencil(0);
     186    context->clear(GraphicsContext3D::STENCIL_BUFFER_BIT);
    219187    didModifyStencil = true;
    220188}
     
    230198TextureMapperGL::TextureMapperGL()
    231199    : TextureMapper(OpenGLMode)
    232     , m_data(new TextureMapperGLData)
    233200    , m_context(0)
    234201    , m_enableEdgeDistanceAntialiasing(false)
    235202{
     203    m_context3D = GraphicsContext3D::createForCurrentGLContext();
     204    m_data = new TextureMapperGLData(m_context3D.get());
    236205}
    237206
     
    243212void TextureMapperGL::beginPainting(PaintFlags flags)
    244213{
    245     // Make sure that no GL error code stays from previous operations.
    246     glGetError();
    247 
    248     if (!initializeOpenGLShims())
    249         return;
    250 
    251     GL_CMD(glGetIntegerv(GL_CURRENT_PROGRAM, &data().previousProgram));
    252     data().previousScissorState = glIsEnabled(GL_SCISSOR_TEST);
    253     data().previousDepthState = glIsEnabled(GL_DEPTH_TEST);
     214    m_context3D->getIntegerv(GraphicsContext3D::CURRENT_PROGRAM, &data().previousProgram);
     215    data().previousScissorState = m_context3D->isEnabled(GraphicsContext3D::SCISSOR_TEST);
     216    data().previousDepthState = m_context3D->isEnabled(GraphicsContext3D::DEPTH_TEST);
    254217#if PLATFORM(QT)
    255218    if (m_context) {
     
    259222    }
    260223#endif
    261     glDisable(GL_DEPTH_TEST);
    262     glEnable(GL_SCISSOR_TEST);
     224    m_context3D->disable(GraphicsContext3D::DEPTH_TEST);
     225    m_context3D->enable(GraphicsContext3D::SCISSOR_TEST);
    263226    data().didModifyStencil = false;
    264     GL_CMD(glDepthMask(0));
    265     GL_CMD(glGetIntegerv(GL_VIEWPORT, data().viewport));
    266     GL_CMD(glGetIntegerv(GL_SCISSOR_BOX, data().previousScissor));
     227    m_context3D->depthMask(0);
     228    m_context3D->getIntegerv(GraphicsContext3D::VIEWPORT, data().viewport);
     229    m_context3D->getIntegerv(GraphicsContext3D::SCISSOR_BOX, data().previousScissor);
    267230    m_clipStack.init(IntRect(0, 0, data().viewport[2], data().viewport[3]));
    268     GL_CMD(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &data().targetFrameBuffer));
     231    m_context3D->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &data().targetFrameBuffer);
    269232    data().PaintFlags = flags;
    270233    bindSurface(0);
     
    274237{
    275238    if (data().didModifyStencil) {
    276         glClearStencil(1);
    277         glClear(GL_STENCIL_BUFFER_BIT);
    278     }
    279 
    280     glUseProgram(data().previousProgram);
    281 
    282     glScissor(data().previousScissor[0], data().previousScissor[1], data().previousScissor[2], data().previousScissor[3]);
     239        m_context3D->clearStencil(1);
     240        m_context3D->clear(GraphicsContext3D::STENCIL_BUFFER_BIT);
     241    }
     242
     243    m_context3D->useProgram(data().previousProgram);
     244
     245    m_context3D->scissor(data().previousScissor[0], data().previousScissor[1], data().previousScissor[2], data().previousScissor[3]);
    283246    if (data().previousScissorState)
    284         glEnable(GL_SCISSOR_TEST);
     247        m_context3D->enable(GraphicsContext3D::SCISSOR_TEST);
    285248    else
    286         glDisable(GL_SCISSOR_TEST);
     249        m_context3D->disable(GraphicsContext3D::SCISSOR_TEST);
    287250
    288251    if (data().previousDepthState)
    289         glEnable(GL_DEPTH_TEST);
     252        m_context3D->enable(GraphicsContext3D::DEPTH_TEST);
    290253    else
    291         glDisable(GL_DEPTH_TEST);
     254        m_context3D->disable(GraphicsContext3D::DEPTH_TEST);
    292255
    293256#if PLATFORM(QT)
     
    300263}
    301264
    302 void TextureMapperGL::drawQuad(const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GLenum drawingMode, bool needsBlending)
    303 {
    304     GL_CMD(glEnableVertexAttribArray(shaderProgram->vertexAttrib()));
    305     GL_CMD(glBindBuffer(GL_ARRAY_BUFFER, 0));
    306 
    307     const GLfloat quad[] = {
     265void TextureMapperGL::drawQuad(const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GC3Denum drawingMode, bool needsBlending)
     266{
     267    m_context3D->enableVertexAttribArray(shaderProgram->vertexAttrib());
     268    m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0);
     269
     270    const GC3Dfloat quad[] = {
    308271        quadToDraw.targetRectMappedToUnitSquare.p1().x(), quadToDraw.targetRectMappedToUnitSquare.p1().y(),
    309272        quadToDraw.targetRectMappedToUnitSquare.p2().x(), quadToDraw.targetRectMappedToUnitSquare.p2().y(),
     
    311274        quadToDraw.targetRectMappedToUnitSquare.p4().x(), quadToDraw.targetRectMappedToUnitSquare.p4().y()
    312275    };
    313     GL_CMD(glVertexAttribPointer(shaderProgram->vertexAttrib(), 2, GL_FLOAT, GL_FALSE, 0, quad));
     276    m_context3D->vertexAttribPointer(shaderProgram->vertexAttrib(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(quad));
    314277
    315278    TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix).multiply(modelViewMatrix).multiply(TransformationMatrix(
     
    318281            0, 0, 1, 0,
    319282            quadToDraw.originalTargetRect.x(), quadToDraw.originalTargetRect.y(), 0, 1));
    320     const GLfloat m4[] = {
     283    GC3Dfloat m4[] = {
    321284        matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(),
    322285        matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(),
     
    324287        matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44()
    325288    };
    326     GL_CMD(glUniformMatrix4fv(shaderProgram->matrixLocation(), 1, GL_FALSE, m4));
     289    m_context3D->uniformMatrix4fv(shaderProgram->matrixLocation(), 1, false, m4);
    327290
    328291    if (needsBlending) {
    329         GL_CMD(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
    330         GL_CMD(glEnable(GL_BLEND));
     292        m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
     293        m_context3D->enable(GraphicsContext3D::BLEND);
    331294    } else
    332         GL_CMD(glDisable(GL_BLEND));
    333 
    334     GL_CMD(glDrawArrays(drawingMode, 0, 4));
    335     GL_CMD(glDisableVertexAttribArray(shaderProgram->vertexAttrib()));
     295        m_context3D->disable(GraphicsContext3D::BLEND);
     296
     297    m_context3D->drawArrays(drawingMode, 0, 4);
     298    m_context3D->disableVertexAttribArray(shaderProgram->vertexAttrib());
    336299}
    337300
     
    342305
    343306    RefPtr<TextureMapperShaderProgramSolidColor> program = data().sharedGLData().textureMapperShaderManager.solidColorProgram();
    344     GL_CMD(glUseProgram(program->id()));
     307    m_context3D->useProgram(program->id());
    345308
    346309    float alpha = color.alpha() / 255.0;
    347     GL_CMD(glUniform4f(program->colorLocation(),
     310    m_context3D->uniform4f(program->colorLocation(),
    348311                       (color.red() / 255.0) * alpha,
    349312                       (color.green() / 255.0) * alpha,
    350313                       (color.blue() / 255.0) * alpha,
    351                        alpha));
    352     GL_CMD(glLineWidth(width));
    353 
    354     drawQuad(targetRect, modelViewMatrix, program.get(), GL_LINE_LOOP, color.hasAlpha());
     314                       alpha);
     315    m_context3D->lineWidth(width);
     316
     317    drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::LINE_LOOP, color.hasAlpha());
    355318}
    356319
     
    399362}
    400363
    401 #if defined(GL_ARB_texture_rectangle)
     364#if !USE(TEXMAP_OPENGL_ES_2)
    402365void TextureMapperGL::drawTextureRectangleARB(uint32_t texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
    403366{
     
    407370    else
    408371        program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::RectSimple);
    409     GL_CMD(glUseProgram(program->id()));
    410 
    411     GL_CMD(glEnableVertexAttribArray(program->vertexAttrib()));
    412     GL_CMD(glActiveTexture(GL_TEXTURE0));
    413     GL_CMD(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture));
    414     GL_CMD(glUniform1i(program->sourceTextureLocation(), 0));
    415 
    416     GL_CMD(glUniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture)));
    417     GL_CMD(glUniform2f(program->textureSizeLocation(), textureSize.width(), textureSize.height()));
     372    m_context3D->useProgram(program->id());
     373
     374    m_context3D->enableVertexAttribArray(program->vertexAttrib());
     375    m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
     376    m_context3D->bindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
     377    m_context3D->uniform1i(program->sourceTextureLocation(), 0);
     378
     379    m_context3D->uniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture));
     380    m_context3D->uniform2f(program->textureSizeLocation(), textureSize.width(), textureSize.height());
    418381
    419382    if (TextureMapperShaderProgram::isValidUniformLocation(program->opacityLocation()))
    420         GL_CMD(glUniform1f(program->opacityLocation(), opacity));
     383        m_context3D->uniform1f(program->opacityLocation(), opacity);
    421384
    422385    if (maskTexture && maskTexture->isValid() && TextureMapperShaderProgram::isValidUniformLocation(program->maskTextureLocation())) {
    423386        const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture);
    424         GL_CMD(glActiveTexture(GL_TEXTURE1));
    425         GL_CMD(glBindTexture(GL_TEXTURE_2D, maskTextureGL->id()));
    426         GL_CMD(glUniform1i(program->maskTextureLocation(), 1));
    427         GL_CMD(glActiveTexture(GL_TEXTURE0));
     387        m_context3D->activeTexture(GraphicsContext3D::TEXTURE1);
     388        m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureGL->id());
     389        m_context3D->uniform1i(program->maskTextureLocation(), 1);
     390        m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
    428391    }
    429392
    430393    bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture;
    431     drawQuad(targetRect, modelViewMatrix, program.get(), GL_TRIANGLE_FAN, needsBlending);
    432 }
    433 #endif // defined(GL_ARB_texture_rectangle)
     394    drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, needsBlending);
     395}
     396#endif // !USE(TEXMAP_OPENGL_ES_2)
    434397
    435398void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const IntSize& /* textureSize */, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges)
    436399{
    437     bool needsAntiliaing = m_enableEdgeDistanceAntialiasing && !modelViewMatrix.isIntegerTranslation();
    438     if (needsAntiliaing && drawTextureWithAntialiasing(texture, flags, targetRect, modelViewMatrix, opacity, maskTexture, exposedEdges))
     400    bool needsAntialiasing = m_enableEdgeDistanceAntialiasing && !modelViewMatrix.isIntegerTranslation();
     401    if (needsAntialiasing && drawTextureWithAntialiasing(texture, flags, targetRect, modelViewMatrix, opacity, maskTexture, exposedEdges))
    439402       return;
    440403
     
    444407    else
    445408        program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Simple);
    446     GL_CMD(glUseProgram(program->id()));
     409    m_context3D->useProgram(program->id());
    447410
    448411    drawTexturedQuadWithProgram(program.get(), texture, flags, targetRect, modelViewMatrix, opacity, maskTexture);
    449412}
    450413
    451 static TransformationMatrix viewportMatrix()
    452 {
    453     GLint viewport[4];
    454     GL_CMD(glGetIntegerv(GL_VIEWPORT, viewport));
     414static TransformationMatrix viewportMatrix(GraphicsContext3D* context3D)
     415{
     416    GC3Dint viewport[4];
     417    context3D->getIntegerv(GraphicsContext3D::VIEWPORT, viewport);
    455418
    456419    TransformationMatrix matrix;
     
    549512    // translates from normalized device coordinates to screen coordinates), because these
    550513    // values are consumed in the fragment shader, which works in screen coordinates.
    551     TransformationMatrix screenSpaceTransform = viewportMatrix().multiply(TransformationMatrix(data().projectionMatrix)).multiply(modelViewMatrix).to2dTransform();
     514    TransformationMatrix screenSpaceTransform = viewportMatrix(m_context3D.get()).multiply(TransformationMatrix(data().projectionMatrix)).multiply(modelViewMatrix).to2dTransform();
    552515    if (!screenSpaceTransform.isInvertible())
    553516        return false;
     
    573536
    574537    RefPtr<TextureMapperShaderProgramAntialiasingNoMask> program = data().sharedGLData().textureMapperShaderManager.antialiasingNoMaskProgram();
    575     GL_CMD(glUseProgram(program->id()));
    576     GL_CMD(glUniform3fv(program->expandedQuadEdgesInScreenSpaceLocation(), 8, targetQuadEdges));
     538    m_context3D->useProgram(program->id());
     539    m_context3D->uniform3fv(program->expandedQuadEdgesInScreenSpaceLocation(), 8, targetQuadEdges);
    577540
    578541    drawTexturedQuadWithProgram(program.get(), texture, flags, DrawQuad(originalTargetRect, expandedQuadInTextureCoordinates), modelViewMatrix, opacity, 0 /* maskTexture */);
     
    582545void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
    583546{
    584     GL_CMD(glEnableVertexAttribArray(program->vertexAttrib()));
    585     GL_CMD(glActiveTexture(GL_TEXTURE0));
    586     GL_CMD(glBindTexture(GL_TEXTURE_2D, texture));
    587     GL_CMD(glUniform1i(program->sourceTextureLocation(), 0));
    588 
    589     GL_CMD(glUniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture)));
     547    m_context3D->enableVertexAttribArray(program->vertexAttrib());
     548    m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
     549    m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, texture);
     550    m_context3D->uniform1i(program->sourceTextureLocation(), 0);
     551
     552    m_context3D->uniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture));
    590553
    591554    if (TextureMapperShaderProgram::isValidUniformLocation(program->opacityLocation()))
    592         GL_CMD(glUniform1f(program->opacityLocation(), opacity));
     555        m_context3D->uniform1f(program->opacityLocation(), opacity);
    593556
    594557    if (maskTexture && maskTexture->isValid() && TextureMapperShaderProgram::isValidUniformLocation(program->maskTextureLocation())) {
    595558        const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture);
    596         GL_CMD(glActiveTexture(GL_TEXTURE1));
    597         GL_CMD(glBindTexture(GL_TEXTURE_2D, maskTextureGL->id()));
    598         GL_CMD(glUniform1i(program->maskTextureLocation(), 1));
    599         GL_CMD(glActiveTexture(GL_TEXTURE0));
     559        m_context3D->activeTexture(GraphicsContext3D::TEXTURE1);
     560        m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureGL->id());
     561        m_context3D->uniform1i(program->maskTextureLocation(), 1);
     562        m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
    600563    }
    601564
    602565    bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture;
    603     drawQuad(quadToDraw, modelViewMatrix, program, GL_TRIANGLE_FAN, needsBlending);
     566    drawQuad(quadToDraw, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, needsBlending);
    604567}
    605568
     
    612575#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
    613576#else
    614 #define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_BYTE
     577#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GraphicsContext3D::UNSIGNED_BYTE
    615578#endif
    616579
     
    647610void BitmapTextureGL::didReset()
    648611{
     612    GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D();
     613
    649614    if (!m_id)
    650         GL_CMD(glGenTextures(1, &m_id));
     615        m_id = context3D->createTexture();
    651616
    652617    m_shouldClear = true;
     
    654619        return;
    655620
    656     GLuint format = driverSupportsBGRASwizzling() ? GL_BGRA : GL_RGBA;
     621    Platform3DObject format = driverSupportsBGRASwizzling() ? GraphicsContext3D::BGRA : GraphicsContext3D::RGBA;
    657622
    658623    m_textureSize = contentSize();
    659     GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id));
    660     GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
    661     GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
    662     GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
    663     GL_CMD(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
    664     GL_CMD(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_textureSize.width(), m_textureSize.height(), 0, format, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0));
     624    context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
     625    context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
     626    context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
     627    context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
     628    context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
     629    context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, m_textureSize.width(), m_textureSize.height(), 0, format, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0);
    665630}
    666631
     
    668633void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine)
    669634{
    670     GLuint glFormat = GL_RGBA;
    671     GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id));
     635    GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D();
     636
     637    Platform3DObject glFormat = GraphicsContext3D::RGBA;
     638    context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
    672639
    673640    const unsigned bytesPerPixel = 4;
    674641    if (driverSupportsBGRASwizzling())
    675         glFormat = GL_BGRA;
     642        glFormat = GraphicsContext3D::BGRA;
    676643    else
    677644        swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(const_cast<void*>(data)), IntRect(sourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);
    678645
    679646    if (bytesPerLine == targetRect.width() / 4 && sourceOffset == IntPoint::zero()) {
    680         GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data));
     647        context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data);
    681648        return;
    682649    }
     
    696663        }
    697664
    698         GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, temporaryData.data()));
     665        context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, temporaryData.data());
    699666        return;
    700667    }
     
    702669#if !defined(TEXMAP_OPENGL_ES_2)
    703670    // Use the OpenGL sub-image extension, now that we know it's available.
    704     GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel));
    705     GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y()));
    706     GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x()));
    707     GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data));
    708     GL_CMD(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
    709     GL_CMD(glPixelStorei(GL_UNPACK_SKIP_ROWS, 0));
    710     GL_CMD(glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0));
     671    context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel);
     672    context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y());
     673    context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x());
     674    context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, (const char*)data);
     675    context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, 0);
     676    context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, 0);
     677    context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
    711678#endif
    712679}
     
    744711    program->prepare(filter, pass, sourceTexture.contentSize(), static_cast<const BitmapTextureGL&>(contentTexture).id());
    745712
    746     GL_CMD(glEnableVertexAttribArray(program->vertexAttrib()));
    747     GL_CMD(glEnableVertexAttribArray(program->texCoordAttrib()));
    748     GL_CMD(glActiveTexture(GL_TEXTURE0));
    749     GL_CMD(glBindTexture(GL_TEXTURE_2D, static_cast<const BitmapTextureGL&>(sourceTexture).id()));
    750     glUniform1i(program->textureUniform(), 0);
    751     const GLfloat targetVertices[] = {-1, -1, 1, -1, 1, 1, -1, 1};
    752     const GLfloat sourceVertices[] = {0, 0, 1, 0, 1, 1, 0, 1};
    753     GL_CMD(glVertexAttribPointer(program->vertexAttrib(), 2, GL_FLOAT, GL_FALSE, 0, targetVertices));
    754     GL_CMD(glVertexAttribPointer(program->texCoordAttrib(), 2, GL_FLOAT, GL_FALSE, 0, sourceVertices));
    755     GL_CMD(glDisable(GL_BLEND));
    756     GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));
    757     GL_CMD(glDisableVertexAttribArray(program->vertexAttrib()));
    758     GL_CMD(glDisableVertexAttribArray(program->texCoordAttrib()));
     713    m_context3D->enableVertexAttribArray(program->vertexAttrib());
     714    m_context3D->enableVertexAttribArray(program->texCoordAttrib());
     715    m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
     716    m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, static_cast<const BitmapTextureGL&>(sourceTexture).id());
     717    m_context3D->uniform1i(program->textureUniform(), 0);
     718    const GC3Dfloat targetVertices[] = {-1, -1, 1, -1, 1, 1, -1, 1};
     719    const GC3Dfloat sourceVertices[] = {0, 0, 1, 0, 1, 1, 0, 1};
     720    m_context3D->vertexAttribPointer(program->vertexAttrib(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(targetVertices));
     721    m_context3D->vertexAttribPointer(program->texCoordAttrib(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(sourceVertices));
     722    m_context3D->disable(GraphicsContext3D::BLEND);
     723    m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4);
     724    m_context3D->disableVertexAttribArray(program->vertexAttrib());
     725    m_context3D->disableVertexAttribArray(program->texCoordAttrib());
    759726}
    760727
     
    797764    if (m_rbo)
    798765        return;
    799     GL_CMD(glGenRenderbuffers(1, &m_rbo));
    800     GL_CMD(glBindRenderbuffer(GL_RENDERBUFFER, m_rbo));
     766
     767    GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D();
     768    m_rbo = context3D->createRenderbuffer();
     769    context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_rbo);
    801770#ifdef TEXMAP_OPENGL_ES_2
    802     GL_CMD(glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, m_textureSize.width(), m_textureSize.height()));
     771    context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::STENCIL_INDEX8, m_textureSize.width(), m_textureSize.height());
    803772#else
    804     GL_CMD(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, m_textureSize.width(), m_textureSize.height()));
    805 #endif
    806     GL_CMD(glBindRenderbuffer(GL_RENDERBUFFER, 0));
    807     GL_CMD(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_rbo));
    808     GL_CMD(glClearStencil(0));
    809     GL_CMD(glClear(GL_STENCIL_BUFFER_BIT));
     773    context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_STENCIL, m_textureSize.width(), m_textureSize.height());
     774#endif
     775    context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0);
     776    context3D->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_rbo);
     777    context3D->clearStencil(0);
     778    context3D->clear(GraphicsContext3D::STENCIL_BUFFER_BIT);
    810779}
    811780
     
    815784        return;
    816785
     786    GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D();
     787
    817788    m_clipStack.init(IntRect(IntPoint::zero(), m_textureSize));
    818     m_clipStack.apply();
    819     GL_CMD(glClearColor(0, 0, 0, 0));
    820     GL_CMD(glClear(GL_COLOR_BUFFER_BIT));
     789    m_clipStack.apply(context3D);
     790    context3D->clearColor(0, 0, 0, 0);
     791    context3D->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
    821792    m_shouldClear = false;
    822793}
     
    827798        return;
    828799
    829     GL_CMD(glGenFramebuffers(1, &m_fbo));
    830     GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo));
    831     GL_CMD(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id(), 0));
     800    GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D();
     801    m_fbo = context3D->createFramebuffer();
     802    context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     803    context3D->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, id(), 0);
    832804    m_shouldClear = true;
    833805}
     
    835807void BitmapTextureGL::bind()
    836808{
    837     GL_CMD(glBindTexture(GL_TEXTURE_2D, 0));
     809    GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D();
     810    context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
    838811    createFboIfNeeded();
    839     GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo));
    840     GL_CMD(glViewport(0, 0, m_textureSize.width(), m_textureSize.height()));
     812    context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     813    context3D->viewport(0, 0, m_textureSize.width(), m_textureSize.height());
    841814    clearIfNeeded();
    842815    m_textureMapper->data().projectionMatrix = createProjectionMatrix(m_textureSize, true /* mirrored */);
    843     m_clipStack.apply();
     816    m_clipStack.apply(context3D);
    844817}
    845818
    846819BitmapTextureGL::~BitmapTextureGL()
    847820{
     821    GraphicsContext3D* context3D = m_textureMapper->graphicsContext3D();
     822
    848823    if (m_id)
    849         GL_CMD(glDeleteTextures(1, &m_id));
     824        context3D->deleteTexture(m_id);
    850825
    851826    if (m_fbo)
    852         GL_CMD(glDeleteFramebuffers(1, &m_fbo));
     827        context3D->deleteFramebuffer(m_fbo);
    853828
    854829    if (m_rbo)
    855         GL_CMD(glDeleteRenderbuffers(1, &m_rbo));
     830        context3D->deleteRenderbuffer(m_rbo);
    856831}
    857832
     
    873848void TextureMapperGL::bindDefaultSurface()
    874849{
    875     GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, data().targetFrameBuffer));
     850    m_context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, data().targetFrameBuffer);
    876851    IntSize viewportSize(data().viewport[2], data().viewport[3]);
    877852    data().projectionMatrix = createProjectionMatrix(viewportSize, data().PaintFlags & PaintingMirrored);
    878     GL_CMD(glViewport(data().viewport[0], data().viewport[1], viewportSize.width(), viewportSize.height()));
    879     m_clipStack.apply();
     853    m_context3D->viewport(data().viewport[0], data().viewport[1], viewportSize.width(), viewportSize.height());
     854    m_clipStack.apply(m_context3D.get());
    880855    data().currentSurface.clear();
    881856}
     
    907882
    908883    clipStack().current().scissorBox.intersect(rect);
    909     clipStack().apply();
     884    clipStack().apply(m_context3D.get());
    910885    return true;
    911886}
     
    921896    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Simple);
    922897
    923     GL_CMD(glUseProgram(program->id()));
    924     GL_CMD(glEnableVertexAttribArray(program->vertexAttrib()));
    925     const GLfloat unitRect[] = {0, 0, 1, 0, 1, 1, 0, 1};
    926     GL_CMD(glVertexAttribPointer(program->vertexAttrib(), 2, GL_FLOAT, GL_FALSE, 0, unitRect));
     898    m_context3D->useProgram(program->id());
     899    m_context3D->enableVertexAttribArray(program->vertexAttrib());
     900    const GC3Dfloat unitRect[] = {0, 0, 1, 0, 1, 1, 0, 1};
     901    m_context3D->vertexAttribPointer(program->vertexAttrib(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(unitRect));
    927902
    928903    TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix)
     
    933908                targetRect.x(), targetRect.y(), 0, 1));
    934909
    935     const GLfloat m4[] = {
     910    const GC3Dfloat m4[] = {
    936911        matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(),
    937912        matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(),
     
    940915    };
    941916
    942     const GLfloat m4all[] = {
     917    const GC3Dfloat m4all[] = {
    943918        2, 0, 0, 0,
    944919        0, 2, 0, 0,
     
    949924    int& stencilIndex = clipStack().current().stencilIndex;
    950925
    951     GL_CMD(glEnable(GL_STENCIL_TEST));
     926    m_context3D->enable(GraphicsContext3D::STENCIL_TEST);
    952927
    953928    // Make sure we don't do any actual drawing.
    954     GL_CMD(glStencilFunc(GL_NEVER, stencilIndex, stencilIndex));
     929    m_context3D->stencilFunc(GraphicsContext3D::NEVER, stencilIndex, stencilIndex);
    955930
    956931    // Operate only on the stencilIndex and above.
    957     GL_CMD(glStencilMask(0xff & ~(stencilIndex - 1)));
     932    m_context3D->stencilMask(0xff & ~(stencilIndex - 1));
    958933
    959934    // First clear the entire buffer at the current index.
    960     GL_CMD(glUniformMatrix4fv(program->matrixLocation(), 1, GL_FALSE, m4all));
    961     GL_CMD(glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO));
    962     GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));
     935    m_context3D->uniformMatrix4fv(program->matrixLocation(), 1, false, const_cast<GC3Dfloat*>(m4all));
     936    m_context3D->stencilOp(GraphicsContext3D::ZERO, GraphicsContext3D::ZERO, GraphicsContext3D::ZERO);
     937    m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4);
    963938
    964939    // Now apply the current index to the new quad.
    965     GL_CMD(glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE));
    966     GL_CMD(glUniformMatrix4fv(program->matrixLocation(), 1, GL_FALSE, m4));
    967     GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));
     940    m_context3D->stencilOp(GraphicsContext3D::REPLACE, GraphicsContext3D::REPLACE, GraphicsContext3D::REPLACE);
     941    m_context3D->uniformMatrix4fv(program->matrixLocation(), 1, false, const_cast<GC3Dfloat*>(m4));
     942    m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4);
    968943
    969944    // Clear the state.
    970     GL_CMD(glDisableVertexAttribArray(program->vertexAttrib()));
    971     GL_CMD(glStencilMask(0));
     945    m_context3D->disableVertexAttribArray(program->vertexAttrib());
     946    m_context3D->stencilMask(0);
    972947
    973948    // Increase stencilIndex and apply stencil testing.
    974949    stencilIndex *= 2;
    975     clipStack().apply();
     950    clipStack().apply(m_context3D.get());
    976951}
    977952
     
    979954{
    980955    clipStack().pop();
    981     clipStack().apply();
     956    clipStack().apply(m_context3D.get());
    982957}
    983958
    984959PassRefPtr<BitmapTexture> TextureMapperGL::createTexture()
    985960{
    986     BitmapTextureGL* texture = new BitmapTextureGL();
    987     texture->setTextureMapper(this);
     961    BitmapTextureGL* texture = new BitmapTextureGL(this);
    988962    return adoptRef(texture);
    989963}
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h

    r126743 r127063  
    2424
    2525#include "FloatQuad.h"
     26#include "GraphicsContext3D.h"
    2627#include "IntSize.h"
    27 #include "OpenGLShims.h"
    2828#include "TextureMapper.h"
    2929#include "TransformationMatrix.h"
     
    3939public:
    4040    static PassOwnPtr<TextureMapperGL> create() { return adoptPtr(new TextureMapperGL); }
    41     TextureMapperGL();
    4241    virtual ~TextureMapperGL();
    4342
     
    5554    virtual void drawTexture(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges);
    5655
    57 #if defined(GL_ARB_texture_rectangle)
     56#if !USE(TEXMAP_OPENGL_ES_2)
    5857    virtual void drawTextureRectangleARB(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
    5958#endif
     
    6766    virtual PassRefPtr<BitmapTexture> createTexture() OVERRIDE;
    6867    virtual GraphicsContext* graphicsContext() OVERRIDE { return m_context; }
     68    inline GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); }
    6969    virtual void setGraphicsContext(GraphicsContext* context) OVERRIDE { m_context = context; }
    7070
     
    7676
    7777private:
    78 
    7978    struct ClipState {
    8079        IntRect scissorBox;
     
    9089        void push();
    9190        void pop();
    92         void apply();
     91        void apply(GraphicsContext3D*);
    9392        inline ClipState& current() { return clipState; }
    9493        void init(const IntRect&);
     
    110109    };
    111110
     111    TextureMapperGL();
     112
    112113    bool drawTextureWithAntialiasing(uint32_t texture, Flags, const FloatRect& originalTargetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges);
    113114    void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const DrawQuad&, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
    114     void drawQuad(const DrawQuad&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GLenum drawingMode, bool needsBlending);
     115    void drawQuad(const DrawQuad&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, bool needsBlending);
    115116
    116117    bool beginScissorClip(const TransformationMatrix&, const FloatRect&);
     
    118119    ClipStack& clipStack();
    119120    inline TextureMapperGLData& data() { return *m_data; }
     121    GraphicsContext* m_context;
     122    RefPtr<GraphicsContext3D> m_context3D;
    120123    TextureMapperGLData* m_data;
    121     GraphicsContext* m_context;
    122124    ClipStack m_clipStack;
    123125    bool m_enableEdgeDistanceAntialiasing;
     
    136138    ~BitmapTextureGL();
    137139    virtual uint32_t id() const { return m_id; }
    138     uint32_t textureTarget() const { return GL_TEXTURE_2D; }
     140    uint32_t textureTarget() const { return GraphicsContext3D::TEXTURE_2D; }
    139141    IntSize textureSize() const { return m_textureSize; }
    140142    void setTextureMapper(TextureMapperGL* texmap) { m_textureMapper = texmap; }
     
    148150
    149151private:
    150     GLuint m_id;
     152    Platform3DObject m_id;
    151153    IntSize m_textureSize;
    152154    IntRect m_dirtyRect;
    153     GLuint m_fbo;
    154     GLuint m_rbo;
     155    Platform3DObject m_fbo;
     156    Platform3DObject m_rbo;
    155157    bool m_shouldClear;
     158    TextureMapperGL::ClipStack m_clipStack;
    156159    TextureMapperGL* m_textureMapper;
    157     TextureMapperGL::ClipStack m_clipStack;
    158     BitmapTextureGL()
     160
     161    BitmapTextureGL();
     162    BitmapTextureGL(TextureMapperGL* textureMapper)
    159163        : m_id(0)
    160164        , m_fbo(0)
    161165        , m_rbo(0)
    162166        , m_shouldClear(true)
    163         , m_textureMapper(0)
     167        , m_textureMapper(textureMapper)
    164168    {
    165169    }
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp

    r126926 r127063  
    3131namespace WebCore {
    3232
    33 #ifndef TEXMAP_OPENGL_ES_2
    34 #define OES2_PRECISION_DEFINITIONS \
    35     "#define lowp\n#define highp\n"
    36 #define OES2_FRAGMENT_SHADER_DEFAULT_PRECISION
    37 #else
    38 #define OES2_PRECISION_DEFINITIONS
    39 #define OES2_FRAGMENT_SHADER_DEFAULT_PRECISION \
    40     "precision mediump float; \n"
    41 #endif
    42 
    43 #define STRINGIFY_VAL(src...) #src
    44 #define VERTEX_SHADER(src...) OES2_PRECISION_DEFINITIONS\
    45                               STRINGIFY_VAL(src)
    46 #define FRAGMENT_SHADER(src...) OES2_PRECISION_DEFINITIONS\
    47                                 OES2_FRAGMENT_SHADER_DEFAULT_PRECISION\
    48                                 STRINGIFY_VAL(src)
     33#define STRINGIFY(src...) #src
    4934
    5035static const char* fragmentShaderSourceOpacityAndMask =
    51     FRAGMENT_SHADER(
     36    STRINGIFY(
     37        precision mediump float;
    5238        uniform sampler2D s_source;
    5339        uniform sampler2D s_mask;
     
    6551
    6652static const char* fragmentShaderSourceRectOpacityAndMask =
    67     FRAGMENT_SHADER(
     53    STRINGIFY(
     54        precision mediump float;
    6855        uniform sampler2DRect s_source;
    6956        uniform sampler2DRect s_mask;
     
    8168
    8269static const char* vertexShaderSourceOpacityAndMask =
    83     VERTEX_SHADER(
     70    STRINGIFY(
    8471        uniform mat4 u_matrix;
    8572        uniform lowp float u_flip;
     
    9683
    9784static const char* fragmentShaderSourceSimple =
    98     FRAGMENT_SHADER(
     85    STRINGIFY(
     86        precision mediump float;
    9987        uniform sampler2D s_source;
    10088        uniform lowp float u_opacity;
     
    10896
    10997static const char* fragmentShaderSourceAntialiasingNoMask =
    110     FRAGMENT_SHADER(
     98    STRINGIFY(
     99        precision mediump float;
    111100        uniform sampler2D s_source;
    112101        varying highp vec2 v_sourceTexCoord;
     
    146135
    147136static const char* fragmentShaderSourceRectSimple =
    148     FRAGMENT_SHADER(
     137    STRINGIFY(
     138        precision mediump float;
    149139        uniform sampler2DRect s_source;
    150140        uniform lowp vec2 u_textureSize;
     
    159149
    160150static const char* vertexShaderSourceSimple =
    161     VERTEX_SHADER(
     151    STRINGIFY(
    162152        uniform mat4 u_matrix;
    163153        uniform lowp float u_flip;
     
    172162
    173163static const char* vertexShaderSourceSolidColor =
    174     VERTEX_SHADER(
     164    STRINGIFY(
    175165        uniform mat4 u_matrix;
    176166        attribute vec4 a_vertex;
     
    183173
    184174static const char* fragmentShaderSourceSolidColor =
    185     VERTEX_SHADER(
     175    STRINGIFY(
     176        precision mediump float;
    186177        uniform vec4 u_color;
    187178        void main(void)
     
    213204    switch (shaderType) {
    214205    case Simple:
    215         program = TextureMapperShaderProgramSimple::create();
     206        program = TextureMapperShaderProgramSimple::create(m_context);
    216207        break;
    217208    case RectSimple:
    218         program = TextureMapperShaderProgramRectSimple::create();
     209        program = TextureMapperShaderProgramRectSimple::create(m_context);
    219210        break;
    220211    case AntialiasingNoMask:
    221         program = TextureMapperShaderProgramAntialiasingNoMask::create();
     212        program = TextureMapperShaderProgramAntialiasingNoMask::create(m_context);
    222213        break;
    223214    case OpacityAndMask:
    224         program = TextureMapperShaderProgramOpacityAndMask::create();
     215        program = TextureMapperShaderProgramOpacityAndMask::create(m_context);
    225216        break;
    226217    case RectOpacityAndMask:
    227         program = TextureMapperShaderProgramRectOpacityAndMask::create();
     218        program = TextureMapperShaderProgramRectOpacityAndMask::create(m_context);
    228219        break;
    229220    case SolidColor:
    230         program = TextureMapperShaderProgramSolidColor::create();
     221        program = TextureMapperShaderProgramSolidColor::create(m_context);
    231222        break;
    232223    case Invalid:
     
    237228}
    238229
    239 TextureMapperShaderProgram::TextureMapperShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource)
    240     : m_id(0)
     230TextureMapperShaderProgram::TextureMapperShaderProgram(GraphicsContext3D* context, const char* vertexShaderSource, const char* fragmentShaderSource)
     231    : m_context(context)
     232    , m_id(0)
    241233    , m_vertexAttrib(0)
    242234    , m_vertexShader(0)
     
    257249    const char* vertexShaderSourceProgram = vertexShaderSource();
    258250    const char* fragmentShaderSourceProgram = fragmentShaderSource();
    259     GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    260     GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    261     glShaderSource(vertexShader, 1, &vertexShaderSourceProgram, 0);
    262     glShaderSource(fragmentShader, 1, &fragmentShaderSourceProgram, 0);
    263     GLuint programID = glCreateProgram();
    264     glCompileShader(vertexShader);
    265     glCompileShader(fragmentShader);
    266 
    267     glAttachShader(programID, vertexShader);
    268     glAttachShader(programID, fragmentShader);
    269     glLinkProgram(programID);
    270 
    271     m_vertexAttrib = glGetAttribLocation(programID, "a_vertex");
     251    Platform3DObject vertexShader = m_context->createShader(GraphicsContext3D::VERTEX_SHADER);
     252    Platform3DObject fragmentShader = m_context->createShader(GraphicsContext3D::FRAGMENT_SHADER);
     253    m_context->shaderSource(vertexShader, vertexShaderSourceProgram);
     254    m_context->shaderSource(fragmentShader, fragmentShaderSourceProgram);
     255    Platform3DObject programID = m_context->createProgram();
     256    m_context->compileShader(vertexShader);
     257    m_context->compileShader(fragmentShader);
     258
     259    m_context->attachShader(programID, vertexShader);
     260    m_context->attachShader(programID, fragmentShader);
     261    m_context->linkProgram(programID);
     262
     263    m_vertexAttrib = m_context->getAttribLocation(programID, "a_vertex");
    272264
    273265    m_id = programID;
     
    276268}
    277269
    278 void TextureMapperShaderProgram::getUniformLocation(GLint &variable, const char* name)
    279 {
    280     variable = glGetUniformLocation(m_id, name);
     270void TextureMapperShaderProgram::getUniformLocation(GC3Dint &variable, const char* name)
     271{
     272    variable = m_context->getUniformLocation(m_id, name);
    281273    ASSERT(variable >= 0);
    282274}
     
    284276TextureMapperShaderProgram::~TextureMapperShaderProgram()
    285277{
    286     GLuint programID = m_id;
     278    Platform3DObject programID = m_id;
    287279    if (!programID)
    288280        return;
    289281
    290     glDetachShader(programID, m_vertexShader);
    291     glDeleteShader(m_vertexShader);
    292     glDetachShader(programID, m_fragmentShader);
    293     glDeleteShader(m_fragmentShader);
    294     glDeleteProgram(programID);
    295 }
    296 
    297 TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple()
    298     : TextureMapperShaderProgram(vertexShaderSourceSimple, fragmentShaderSourceSimple)
     282    m_context->detachShader(programID, m_vertexShader);
     283    m_context->deleteShader(m_vertexShader);
     284    m_context->detachShader(programID, m_fragmentShader);
     285    m_context->deleteShader(m_fragmentShader);
     286    m_context->deleteProgram(programID);
     287}
     288
     289TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple(GraphicsContext3D* context)
     290    : TextureMapperShaderProgram(context, vertexShaderSourceSimple, fragmentShaderSourceSimple)
    299291{
    300292    initializeProgram();
     
    305297}
    306298
    307 TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor()
    308     : TextureMapperShaderProgram(vertexShaderSourceSolidColor, fragmentShaderSourceSolidColor)
     299TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor(GraphicsContext3D* context)
     300    : TextureMapperShaderProgram(context, vertexShaderSourceSolidColor, fragmentShaderSourceSolidColor)
    309301{
    310302    initializeProgram();
     
    313305}
    314306
    315 TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple()
    316     : TextureMapperShaderProgram(vertexShaderSourceSimple, fragmentShaderSourceRectSimple)
     307TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple(GraphicsContext3D* context)
     308    : TextureMapperShaderProgram(context, vertexShaderSourceSimple, fragmentShaderSourceRectSimple)
    317309{
    318310    initializeProgram();
     
    324316}
    325317
    326 TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask()
    327     : TextureMapperShaderProgram(vertexShaderSourceOpacityAndMask, fragmentShaderSourceOpacityAndMask)
     318TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask(GraphicsContext3D* context)
     319    : TextureMapperShaderProgram(context, vertexShaderSourceOpacityAndMask, fragmentShaderSourceOpacityAndMask)
    328320{
    329321    initializeProgram();
     
    335327}
    336328
    337 TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask()
    338     : TextureMapperShaderProgram(vertexShaderSourceOpacityAndMask, fragmentShaderSourceRectOpacityAndMask)
     329TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask(GraphicsContext3D* context)
     330    : TextureMapperShaderProgram(context, vertexShaderSourceOpacityAndMask, fragmentShaderSourceRectOpacityAndMask)
    339331{
    340332    initializeProgram();
     
    346338}
    347339
    348 TextureMapperShaderProgramAntialiasingNoMask::TextureMapperShaderProgramAntialiasingNoMask()
    349     : TextureMapperShaderProgram(vertexShaderSourceSimple, fragmentShaderSourceAntialiasingNoMask)
     340TextureMapperShaderProgramAntialiasingNoMask::TextureMapperShaderProgramAntialiasingNoMask(GraphicsContext3D* context)
     341    : TextureMapperShaderProgram(context, vertexShaderSourceSimple, fragmentShaderSourceAntialiasingNoMask)
    350342{
    351343    initializeProgram();
     
    357349}
    358350
    359 TextureMapperShaderManager::TextureMapperShaderManager()
    360 {
    361     ASSERT(initializeOpenGLShims());
     351TextureMapperShaderManager::TextureMapperShaderManager(GraphicsContext3D* context)
     352    : m_context(context)
     353{
    362354}
    363355
     
    374366StandardFilterProgram::~StandardFilterProgram()
    375367{
    376     glDetachShader(m_id, m_vertexShader);
    377     glDeleteShader(m_vertexShader);
    378     glDetachShader(m_id, m_fragmentShader);
    379     glDeleteShader(m_fragmentShader);
    380     glDeleteProgram(m_id);
    381 }
    382 
    383 StandardFilterProgram::StandardFilterProgram(FilterOperation::OperationType type, unsigned pass)
    384     : m_id(0)
     368    m_context->detachShader(m_id, m_vertexShader);
     369    m_context->deleteShader(m_vertexShader);
     370    m_context->detachShader(m_id, m_fragmentShader);
     371    m_context->deleteShader(m_fragmentShader);
     372    m_context->deleteProgram(m_id);
     373}
     374
     375StandardFilterProgram::StandardFilterProgram(GraphicsContext3D* context, FilterOperation::OperationType type, unsigned pass)
     376    : m_context(context)
     377    , m_id(0)
    385378{
    386379    const char* vertexShaderSource =
    387             VERTEX_SHADER(
     380            STRINGIFY(
    388381                attribute vec4 a_vertex;
    389382                attribute vec4 a_texCoord;
     
    397390
    398391#define STANDARD_FILTER(x...) \
    399         OES2_PRECISION_DEFINITIONS\
    400         OES2_FRAGMENT_SHADER_DEFAULT_PRECISION\
     392        "precision mediump float;\n"\
    401393        "varying highp vec2 v_texCoord;\n"\
    402394        "uniform highp float u_amount;\n"\
     
    491483        break;
    492484    case FilterOperation::BLUR:
    493         fragmentShaderSource = FRAGMENT_SHADER(
     485        fragmentShaderSource = STRINGIFY(
     486            precision mediump float;
    494487            varying highp vec2 v_texCoord;
    495488            uniform lowp vec2 u_blurRadius;
     
    524517        case 0: {
    525518            // First pass: horizontal alpha blur.
    526             fragmentShaderSource = FRAGMENT_SHADER(
     519            fragmentShaderSource = STRINGIFY(
     520                precision mediump float;
    527521                varying highp vec2 v_texCoord;
    528522                uniform lowp float u_shadowBlurRadius;
     
    557551        case 1: {
    558552            // Second pass: vertical alpha blur and composite with origin.
    559             fragmentShaderSource = FRAGMENT_SHADER(
     553            fragmentShaderSource = STRINGIFY(
     554                precision mediump float;
    560555                varying highp vec2 v_texCoord;
    561556                uniform lowp float u_shadowBlurRadius;
     
    603598    if (!fragmentShaderSource)
    604599        return;
    605     GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    606     GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    607     glShaderSource(vertexShader, 1, &vertexShaderSource, 0);
    608     glShaderSource(fragmentShader, 1, &fragmentShaderSource, 0);
    609     GLuint programID = glCreateProgram();
    610     glCompileShader(vertexShader);
    611     glCompileShader(fragmentShader);
     600    Platform3DObject vertexShader = m_context->createShader(GraphicsContext3D::VERTEX_SHADER);
     601    Platform3DObject fragmentShader = m_context->createShader(GraphicsContext3D::FRAGMENT_SHADER);
     602    m_context->shaderSource(vertexShader, vertexShaderSource);
     603    m_context->shaderSource(fragmentShader, fragmentShaderSource);
     604    Platform3DObject programID = m_context->createProgram();
     605    m_context->compileShader(vertexShader);
     606    m_context->compileShader(fragmentShader);
    612607#if !LOG_DISABLED
    613     GLchar log[100];
    614     GLint len;
    615     glGetShaderInfoLog(fragmentShader, 100, &len, log);
     608    String log;
     609    m_context->getShaderInfoLog(fragmentShader);
    616610    WTFLog(&LogCompositing, "%s\n", log);
    617611#endif
    618     glAttachShader(programID, vertexShader);
    619     glAttachShader(programID, fragmentShader);
    620     glLinkProgram(programID);
    621 
    622     m_vertexAttrib = glGetAttribLocation(programID, "a_vertex");
    623     m_texCoordAttrib = glGetAttribLocation(programID, "a_texCoord");
    624     m_textureUniformLocation = glGetUniformLocation(programID, "u_texture");
     612    m_context->attachShader(programID, vertexShader);
     613    m_context->attachShader(programID, fragmentShader);
     614    m_context->linkProgram(programID);
     615
     616    m_vertexAttrib = m_context->getAttribLocation(programID, "a_vertex");
     617    m_texCoordAttrib = m_context->getAttribLocation(programID, "a_texCoord");
     618    m_textureUniformLocation = m_context->getUniformLocation(programID, "u_texture");
    625619    switch (type) {
    626620    case FilterOperation::GRAYSCALE:
     
    632626    case FilterOperation::CONTRAST:
    633627    case FilterOperation::OPACITY:
    634         m_uniformLocations.amount = glGetUniformLocation(programID, "u_amount");
     628        m_uniformLocations.amount = m_context->getUniformLocation(programID, "u_amount");
    635629        break;
    636630    case FilterOperation::BLUR:
    637         m_uniformLocations.blur.radius = glGetUniformLocation(programID, "u_blurRadius");
    638         m_uniformLocations.blur.gaussianKernel = glGetUniformLocation(programID, "u_gaussianKernel");
     631        m_uniformLocations.blur.radius = m_context->getUniformLocation(programID, "u_blurRadius");
     632        m_uniformLocations.blur.gaussianKernel = m_context->getUniformLocation(programID, "u_gaussianKernel");
    639633        break;
    640634    case FilterOperation::DROP_SHADOW:
    641         m_uniformLocations.shadow.blurRadius = glGetUniformLocation(programID, "u_shadowBlurRadius");
    642         m_uniformLocations.shadow.gaussianKernel = glGetUniformLocation(programID, "u_gaussianKernel");
     635        m_uniformLocations.shadow.blurRadius = m_context->getUniformLocation(programID, "u_shadowBlurRadius");
     636        m_uniformLocations.shadow.gaussianKernel = m_context->getUniformLocation(programID, "u_gaussianKernel");
    643637        if (!pass)
    644             m_uniformLocations.shadow.offset = glGetUniformLocation(programID, "u_shadowOffset");
     638            m_uniformLocations.shadow.offset = m_context->getUniformLocation(programID, "u_shadowOffset");
    645639        else {
    646640            // We only need the color and the content texture in the second pass, the first pass is only a horizontal alpha blur.
    647             m_uniformLocations.shadow.color = glGetUniformLocation(programID, "u_shadowColor");
    648             m_uniformLocations.shadow.contentTexture = glGetUniformLocation(programID, "u_contentTexture");
     641            m_uniformLocations.shadow.color = m_context->getUniformLocation(programID, "u_shadowColor");
     642            m_uniformLocations.shadow.contentTexture = m_context->getUniformLocation(programID, "u_contentTexture");
    649643        }
    650644        break;
     
    657651}
    658652
    659 PassRefPtr<StandardFilterProgram> StandardFilterProgram::create(FilterOperation::OperationType type, unsigned pass)
    660 {
    661     RefPtr<StandardFilterProgram> program = adoptRef(new StandardFilterProgram(type, pass));
     653PassRefPtr<StandardFilterProgram> StandardFilterProgram::create(GraphicsContext3D* context, FilterOperation::OperationType type, unsigned pass)
     654{
     655    RefPtr<StandardFilterProgram> program = adoptRef(new StandardFilterProgram(context, type, pass));
    662656    if (!program->m_id)
    663657        return 0;
     
    695689}
    696690
    697 void StandardFilterProgram::prepare(const FilterOperation& operation, unsigned pass, const IntSize& size, GLuint contentTexture)
    698 {
    699     glUseProgram(m_id);
     691void StandardFilterProgram::prepare(const FilterOperation& operation, unsigned pass, const IntSize& size, GC3Duint contentTexture)
     692{
     693    m_context->useProgram(m_id);
    700694    switch (operation.getOperationType()) {
    701695    case FilterOperation::GRAYSCALE:
     
    703697    case FilterOperation::SATURATE:
    704698    case FilterOperation::HUE_ROTATE:
    705         glUniform1f(m_uniformLocations.amount, static_cast<const BasicColorMatrixFilterOperation&>(operation).amount());
     699        m_context->uniform1f(m_uniformLocations.amount, static_cast<const BasicColorMatrixFilterOperation&>(operation).amount());
    706700        break;
    707701    case FilterOperation::INVERT:
     
    709703    case FilterOperation::CONTRAST:
    710704    case FilterOperation::OPACITY:
    711         glUniform1f(m_uniformLocations.amount, static_cast<const BasicComponentTransferFilterOperation&>(operation).amount());
     705        m_context->uniform1f(m_uniformLocations.amount, static_cast<const BasicComponentTransferFilterOperation&>(operation).amount());
    712706        break;
    713707    case FilterOperation::BLUR: {
     
    721715            radius.setWidth(floatValueForLength(blur.stdDeviation(), size.width()) / size.width());
    722716
    723         glUniform2f(m_uniformLocations.blur.radius, radius.width(), radius.height());
    724         glUniform1fv(m_uniformLocations.blur.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel());
     717        m_context->uniform2f(m_uniformLocations.blur.radius, radius.width(), radius.height());
     718        m_context->uniform1fv(m_uniformLocations.blur.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel());
    725719        break;
    726720    }
     
    730724        case 0:
    731725            // First pass: vertical alpha blur.
    732             glUniform2f(m_uniformLocations.shadow.offset, float(shadow.location().x()) / float(size.width()), float(shadow.location().y()) / float(size.height()));
    733             glUniform1f(m_uniformLocations.shadow.blurRadius, shadow.stdDeviation() / float(size.width()));
    734             glUniform1fv(m_uniformLocations.shadow.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel());
     726            m_context->uniform2f(m_uniformLocations.shadow.offset, float(shadow.location().x()) / float(size.width()), float(shadow.location().y()) / float(size.height()));
     727            m_context->uniform1f(m_uniformLocations.shadow.blurRadius, shadow.stdDeviation() / float(size.width()));
     728            m_context->uniform1fv(m_uniformLocations.shadow.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel());
    735729            break;
    736730        case 1:
    737731            // Second pass: we need the shadow color and the content texture for compositing.
    738             glUniform1f(m_uniformLocations.shadow.blurRadius, shadow.stdDeviation() / float(size.height()));
    739             glUniform1fv(m_uniformLocations.shadow.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel());
    740             glActiveTexture(GL_TEXTURE1);
    741             glBindTexture(GL_TEXTURE_2D, contentTexture);
    742             glUniform1i(m_uniformLocations.shadow.contentTexture, 1);
     732            m_context->uniform1f(m_uniformLocations.shadow.blurRadius, shadow.stdDeviation() / float(size.height()));
     733            m_context->uniform1fv(m_uniformLocations.shadow.gaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH, gaussianKernel());
     734            m_context->activeTexture(GraphicsContext3D::TEXTURE1);
     735            m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, contentTexture);
     736            m_context->uniform1i(m_uniformLocations.shadow.contentTexture, 1);
    743737            float r, g, b, a;
    744738            shadow.color().getRGBA(r, g, b, a);
    745             glUniform4f(m_uniformLocations.shadow.color, r, g, b, a);
     739            m_context->uniform4f(m_uniformLocations.shadow.color, r, g, b, a);
    746740            break;
    747741        }
     
    760754    FilterMap::iterator iterator = m_filterMap.find(key);
    761755    if (iterator == m_filterMap.end()) {
    762         program = StandardFilterProgram::create(type, pass);
     756        program = StandardFilterProgram::create(m_context, type, pass);
    763757        if (!program)
    764758            return 0;
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h

    r126743 r127063  
    2525
    2626#include "FloatQuad.h"
     27#include "GraphicsContext3D.h"
    2728#include "IntSize.h"
    28 #include "OpenGLShims.h"
    29 #include "TextureMapper.h"
     29#include "TextureMapperGL.h"
    3030#include "TransformationMatrix.h"
    3131#include <wtf/HashMap.h>
     
    4545class TextureMapperShaderProgram : public RefCounted<TextureMapperShaderProgram> {
    4646public:
    47     GLuint id() { return m_id; }
    48     GLuint vertexAttrib() { return m_vertexAttrib; }
    49 
    50     TextureMapperShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource);
     47    Platform3DObject id() { return m_id; }
     48    GC3Duint vertexAttrib() { return m_vertexAttrib; }
     49
     50    TextureMapperShaderProgram(GraphicsContext3D*, const char* vertexShaderSource, const char* fragmentShaderSource);
    5151    virtual ~TextureMapperShaderProgram();
    5252
    5353    virtual void prepare(float opacity, const BitmapTexture*) { }
    54     GLint matrixLocation() const { return m_matrixLocation; }
    55     GLint flipLocation() const { return m_flipLocation; }
    56     GLint textureSizeLocation() const { return m_textureSizeLocation; }
    57     GLint sourceTextureLocation() const { return m_sourceTextureLocation; }
    58     GLint maskTextureLocation() const { return m_maskTextureLocation; }
    59     GLint opacityLocation() const { return m_opacityLocation; }
    60 
    61     static bool isValidUniformLocation(GLint location) { return location >= 0; }
    62 
    63 protected:
    64     void getUniformLocation(GLint& var, const char* name);
     54    GC3Dint matrixLocation() const { return m_matrixLocation; }
     55    GC3Dint flipLocation() const { return m_flipLocation; }
     56    GC3Dint textureSizeLocation() const { return m_textureSizeLocation; }
     57    GC3Dint sourceTextureLocation() const { return m_sourceTextureLocation; }
     58    GC3Dint maskTextureLocation() const { return m_maskTextureLocation; }
     59    GC3Dint opacityLocation() const { return m_opacityLocation; }
     60
     61    static bool isValidUniformLocation(GC3Dint location) { return location >= 0; }
     62
     63protected:
     64    void getUniformLocation(GC3Dint& var, const char* name);
    6565    void initializeProgram();
    6666    virtual void initialize() { }
     
    6868    const char* fragmentShaderSource() const { return m_fragmentShaderSource.data(); }
    6969
    70     GLuint m_id;
    71     GLuint m_vertexAttrib;
    72     GLuint m_vertexShader;
    73     GLuint m_fragmentShader;
    74     GLint m_matrixLocation;
    75     GLint m_flipLocation;
    76     GLint m_textureSizeLocation;
    77     GLint m_sourceTextureLocation;
    78     GLint m_opacityLocation;
    79     GLint m_maskTextureLocation;
     70    GraphicsContext3D* m_context;
     71    Platform3DObject m_id;
     72    GC3Duint m_vertexAttrib;
     73    Platform3DObject m_vertexShader;
     74    Platform3DObject m_fragmentShader;
     75    GC3Dint m_matrixLocation;
     76    GC3Dint m_flipLocation;
     77    GC3Dint m_textureSizeLocation;
     78    GC3Dint m_sourceTextureLocation;
     79    GC3Dint m_opacityLocation;
     80    GC3Dint m_maskTextureLocation;
    8081
    8182private:
     
    8889public:
    8990    virtual ~StandardFilterProgram();
    90     virtual void prepare(const FilterOperation&, unsigned pass, const IntSize&, GLuint contentTexture);
    91     static PassRefPtr<StandardFilterProgram> create(FilterOperation::OperationType, unsigned pass);
    92     GLuint vertexAttrib() const { return m_vertexAttrib; }
    93     GLuint texCoordAttrib() const { return m_texCoordAttrib; }
    94     GLuint textureUniform() const { return m_textureUniformLocation; }
    95 private:
    96     StandardFilterProgram(FilterOperation::OperationType, unsigned pass);
    97     GLuint m_id;
    98     GLuint m_vertexShader;
    99     GLuint m_fragmentShader;
    100     GLuint m_vertexAttrib;
    101     GLuint m_texCoordAttrib;
    102     GLuint m_textureUniformLocation;
     91    virtual void prepare(const FilterOperation&, unsigned pass, const IntSize&, GC3Duint contentTexture);
     92    static PassRefPtr<StandardFilterProgram> create(GraphicsContext3D*, FilterOperation::OperationType, unsigned pass);
     93    GC3Duint vertexAttrib() const { return m_vertexAttrib; }
     94    GC3Duint texCoordAttrib() const { return m_texCoordAttrib; }
     95    GC3Duint textureUniform() const { return m_textureUniformLocation; }
     96protected:
     97    GraphicsContext3D* m_context;
     98private:
     99    StandardFilterProgram();
     100    StandardFilterProgram(GraphicsContext3D*, FilterOperation::OperationType, unsigned pass);
     101    Platform3DObject m_id;
     102    Platform3DObject m_vertexShader;
     103    Platform3DObject m_fragmentShader;
     104    GC3Duint m_vertexAttrib;
     105    GC3Duint m_texCoordAttrib;
     106    GC3Duint m_textureUniformLocation;
    103107    union {
    104         GLuint amount;
     108        GC3Duint amount;
    105109
    106110        struct {
    107             GLuint radius;
    108             GLuint gaussianKernel;
     111            GC3Duint radius;
     112            GC3Duint gaussianKernel;
    109113        } blur;
    110114
    111115        struct {
    112             GLuint blurRadius;
    113             GLuint color;
    114             GLuint offset;
    115             GLuint contentTexture;
    116             GLuint gaussianKernel;
     116            GC3Duint blurRadius;
     117            GC3Duint color;
     118            GC3Duint offset;
     119            GC3Duint contentTexture;
     120            GC3Duint gaussianKernel;
    117121        } shadow;
    118122    } m_uniformLocations;
     
    122126class TextureMapperShaderProgramSimple : public TextureMapperShaderProgram {
    123127public:
    124     static PassRefPtr<TextureMapperShaderProgramSimple> create()
    125     {
    126         return adoptRef(new TextureMapperShaderProgramSimple());
    127     }
    128 
    129 protected:
     128    static PassRefPtr<TextureMapperShaderProgramSimple> create(GraphicsContext3D* context)
     129    {
     130        return adoptRef(new TextureMapperShaderProgramSimple(context));
     131    }
     132
     133protected:
     134    TextureMapperShaderProgramSimple(GraphicsContext3D*);
     135private:
    130136    TextureMapperShaderProgramSimple();
    131137};
     
    133139class TextureMapperShaderProgramRectSimple : public TextureMapperShaderProgram {
    134140public:
    135     static PassRefPtr<TextureMapperShaderProgramRectSimple> create()
    136     {
    137         return adoptRef(new TextureMapperShaderProgramRectSimple());
    138     }
    139 
     141    static PassRefPtr<TextureMapperShaderProgramRectSimple> create(GraphicsContext3D* context)
     142    {
     143        return adoptRef(new TextureMapperShaderProgramRectSimple(context));
     144    }
     145
     146protected:
     147    TextureMapperShaderProgramRectSimple(GraphicsContext3D*);
    140148private:
    141149    TextureMapperShaderProgramRectSimple();
     
    144152class TextureMapperShaderProgramOpacityAndMask : public TextureMapperShaderProgram {
    145153public:
    146     static PassRefPtr<TextureMapperShaderProgramOpacityAndMask> create()
    147     {
    148         return adoptRef(new TextureMapperShaderProgramOpacityAndMask());
    149     }
    150 
     154    static PassRefPtr<TextureMapperShaderProgramOpacityAndMask> create(GraphicsContext3D* context)
     155    {
     156        return adoptRef(new TextureMapperShaderProgramOpacityAndMask(context));
     157    }
     158
     159protected:
     160    TextureMapperShaderProgramOpacityAndMask(GraphicsContext3D*);
    151161private:
    152162    TextureMapperShaderProgramOpacityAndMask();
     
    155165class TextureMapperShaderProgramRectOpacityAndMask : public TextureMapperShaderProgram {
    156166public:
    157     static PassRefPtr<TextureMapperShaderProgramRectOpacityAndMask> create()
    158     {
    159         return adoptRef(new TextureMapperShaderProgramRectOpacityAndMask());
    160     }
    161 
     167    static PassRefPtr<TextureMapperShaderProgramRectOpacityAndMask> create(GraphicsContext3D* context)
     168    {
     169        return adoptRef(new TextureMapperShaderProgramRectOpacityAndMask(context));
     170    }
     171
     172protected:
     173    TextureMapperShaderProgramRectOpacityAndMask(GraphicsContext3D*);
    162174private:
    163175    TextureMapperShaderProgramRectOpacityAndMask();
     
    166178class TextureMapperShaderProgramSolidColor : public TextureMapperShaderProgram {
    167179public:
    168     static PassRefPtr<TextureMapperShaderProgramSolidColor> create()
    169     {
    170         return adoptRef(new TextureMapperShaderProgramSolidColor());
    171     }
    172 
    173     GLint colorLocation() const { return m_colorLocation; }
    174 
     180    static PassRefPtr<TextureMapperShaderProgramSolidColor> create(GraphicsContext3D* context)
     181    {
     182        return adoptRef(new TextureMapperShaderProgramSolidColor(context));
     183    }
     184
     185    GC3Dint colorLocation() const { return m_colorLocation; }
     186
     187protected:
     188    TextureMapperShaderProgramSolidColor(GraphicsContext3D*);
    175189private:
    176190    TextureMapperShaderProgramSolidColor();
    177     GLint m_colorLocation;
     191    GC3Dint m_colorLocation;
    178192};
    179193
    180194class TextureMapperShaderProgramAntialiasingNoMask : public TextureMapperShaderProgram {
    181195public:
    182     static PassRefPtr<TextureMapperShaderProgramAntialiasingNoMask> create()
    183     {
    184         return adoptRef(new TextureMapperShaderProgramAntialiasingNoMask());
    185     }
    186 
    187     GLint expandedQuadVerticesInTextureCoordinatesLocation() { return m_expandedQuadVerticesInTextureCordinatesLocation; }
    188     GLint expandedQuadEdgesInScreenSpaceLocation() { return m_expandedQuadEdgesInScreenSpaceLocation; }
    189 
     196    static PassRefPtr<TextureMapperShaderProgramAntialiasingNoMask> create(GraphicsContext3D* context)
     197    {
     198        return adoptRef(new TextureMapperShaderProgramAntialiasingNoMask(context));
     199    }
     200
     201    GC3Dint expandedQuadVerticesInTextureCoordinatesLocation() { return m_expandedQuadVerticesInTextureCordinatesLocation; }
     202    GC3Dint expandedQuadEdgesInScreenSpaceLocation() { return m_expandedQuadEdgesInScreenSpaceLocation; }
     203
     204protected:
     205    TextureMapperShaderProgramAntialiasingNoMask(GraphicsContext3D*);
    190206private:
    191207    TextureMapperShaderProgramAntialiasingNoMask();
    192208
    193     GLint m_expandedQuadVerticesInTextureCordinatesLocation;
    194     GLint m_expandedQuadEdgesInScreenSpaceLocation;
     209    GC3Dint m_expandedQuadVerticesInTextureCordinatesLocation;
     210    GC3Dint m_expandedQuadEdgesInScreenSpaceLocation;
    195211};
    196212
     
    207223    };
    208224
    209     TextureMapperShaderManager();
     225    TextureMapperShaderManager() { }
     226    TextureMapperShaderManager(GraphicsContext3D*);
    210227    virtual ~TextureMapperShaderManager();
    211228
     
    222239    typedef HashMap<ShaderType, RefPtr<TextureMapperShaderProgram>, DefaultHash<int>::Hash, HashTraits<int> > TextureMapperShaderProgramMap;
    223240    TextureMapperShaderProgramMap m_textureMapperShaderProgramMap;
     241    GraphicsContext3D* m_context;
    224242
    225243#if ENABLE(CSS_FILTERS)
     
    227245    FilterMap m_filterMap;
    228246#endif
    229 
    230247};
    231248
Note: See TracChangeset for help on using the changeset viewer.