Changeset 71213 in webkit


Ignore:
Timestamp:
Nov 2, 2010 9:41:32 PM (13 years ago)
Author:
crogers@google.com
Message:

2010-11-02 Chris Rogers <crogers@google.com>

Reviewed by James Robinson.

Add AudioProcessingEvent files
https://bugs.webkit.org/show_bug.cgi?id=48884

No new tests since audio API is not yet implemented.

  • webaudio/AudioProcessingEvent.cpp: Added. (WebCore::AudioProcessingEvent::create): (WebCore::AudioProcessingEvent::AudioProcessingEvent): (WebCore::AudioProcessingEvent::~AudioProcessingEvent): (WebCore::AudioProcessingEvent::isAudioProcessingEvent):
  • webaudio/AudioProcessingEvent.h: Added. (WebCore::AudioProcessingEvent::inputBuffer): (WebCore::AudioProcessingEvent::outputBuffer):
  • webaudio/AudioProcessingEvent.idl: Added.

2010-11-02 Noam Rosenthal <noam.rosenthal@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Some refactor for texmap to enable WebKit2: remove globals, and allow TextureMapper to exist without a GraphicsContext.
This will allow rendering the TextureMapperNode tree without an active QPainter, into the current GL context.
Most of the changes simply move the globas in TextureMapperGL into members of that class.

[Texmap] [Qt] Texture mapper initial implementation
https://bugs.webkit.org/show_bug.cgi?id=47070

  • Api/qwebframe.cpp: (QWebFramePrivate::renderFromTiledBackingStore): (QWebFramePrivate::renderCompositedLayers): (QWebFramePrivate::renderRelativeCoords):
  • Api/qwebframe_p.h:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71212 r71213  
    783783        (WebInspector.ImageView.prototype.contentTabSelected.onImageLoad):
    784784
    785 2010-11-02  Adele Peterson  <adele@apple.com>
     785 2010-10-31  Noam Rosenthal  <noam.rosenthal@nokia.com>
     786
     787        Reviewed by Kenneth Rohde Christiansen.
     788
     789        [Texmap] [Qt] Texture mapper initial implementation
     790        https://bugs.webkit.org/show_bug.cgi?id=47070
     791
     792        Some refactor for texmap to enable WebKit2: remove globals, and allow TextureMapper to exist without a GraphicsContext.
     793        This will allow rendering the TextureMapperNode tree without an active QPainter, into the current GL context.
     794        Most of the changes simply move the globas in TextureMapperGL into members of that class.
     795
     796        No new tests. Old tests in LayoutTests/compositing cover this.
     797
     798        * platform/graphics/opengl/TextureMapperGL.cpp:
     799        (WebCore::TextureMapperGLData::ShaderInfo::getUniformLocation):
     800        (WebCore::TextureMapperGLData::ShaderInfo::createShaderProgram):
     801        (WebCore::TextureMapperGLData::DirectlyCompositedImageRepository::findOrCreate):
     802        (WebCore::TextureMapperGLData::DirectlyCompositedImageRepository::deref):
     803        (WebCore::TextureMapperGLData::DirectlyCompositedImageRepository::DirectlyCompositedImageRepository):
     804        (WebCore::TextureMapperGLData::DirectlyCompositedImageRepository::~DirectlyCompositedImageRepository):
     805        (WebCore::TextureMapperGLData::TextureMapperGLData):
     806        (WebCore::TextureMapperGL::TextureMapperGL):
     807        (WebCore::TextureMapperGL::drawTexture):
     808        (WebCore::BitmapTextureGL::setContentsToImage):
     809        (WebCore::BitmapTextureGL::destroy):
     810        (WebCore::TextureMapperGL::~TextureMapperGL):
     811        (WebCore::TextureMapperGL::makeContextCurrent):
     812        (WebCore::TextureMapperGL::obtainCurrentContext):
     813        (WebCore::TextureMapperGL::bindSurface):
     814        (WebCore::TextureMapperGL::paintToTarget):
     815        (WebCore::TextureMapperGL::createTexture):
     816        * platform/graphics/opengl/TextureMapperGL.h:
     817        (WebCore::TextureMapperGL::data):
     818        * platform/graphics/qt/TextureMapperQt.cpp:
     819        (WebCore::TextureMapperQt::TextureMapperQt):
     820        (WebCore::TextureMapperQt::setGraphicsContext):
     821        (WebCore::TextureMapper::create):
     822        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
     823        (WebCore::TextureMapperNode::paint):
     824        (WebCore::TextureMapperNode::uploadTextureFromContent):
     825        * platform/graphics/texmap/TextureMapper.h:
     826        (WebCore::TextureMapper::setGraphicsContext):
     827        (WebCore::TextureMapper::setImageInterpolationQuality):
     828        (WebCore::TextureMapper::setTextDrawingMode):
     829        (WebCore::TextureMapper::imageInterpolationQuality):
     830        (WebCore::TextureMapper::textDrawingMode):
     831        (WebCore::TextureMapper::TextureMapper):
     832        * platform/graphics/texmap/TextureMapperPlatformLayer.h:
     833        (WebCore::TextureMapperContentLayer::paint):
     834
     835 2010-11-02  Adele Peterson  <adele@apple.com>
    786836
    787837        Reviewed by Kent Tamura.
     
    8308483134        Reviewed by Gustavo Noronha Silva.
    8308583135
    83086         Bug 41340 - [GStreamer] Subtle race condition during seeks
     83136        Bug 41340 - [GStreamer] Subtle race condition during seeks
    8308783137        https://bugs.webkit.org/show_bug.cgi?id=41340
    8308883138
  • trunk/WebCore/platform/graphics/opengl/TextureMapperGL.cpp

    r70933 r71213  
    3131#include <GLES2/gl2.h>
    3232#elif OS(MAC_OS_X)
     33#include <AGL/agl.h>
    3334#include <gl.h>
    3435#else
     36#if OS(UNIX)
     37#include <GL/glx.h>
     38#endif
    3539#include <GL/gl.h>
    3640#endif
     
    9195#endif
    9296
     97static const GLuint gInVertexAttributeIndex = 0;
     98
     99struct TextureMapperGLData {
     100    static struct ShaderInfo {
     101        enum ShaderProgramIndex {
     102            SimpleProgram,
     103            OpacityAndMaskProgram,
     104            TargetProgram,
     105
     106            ProgramCount
     107        };
     108
     109        enum ShaderVariableIndex {
     110            InMatrixVariable,
     111            InSourceMatrixVariable,
     112            InMaskMatrixVariable,
     113            OpacityVariable,
     114            SourceTextureVariable,
     115            MaskTextureVariable,
     116
     117            VariableCount
     118        };
     119
     120        struct ProgramInfo {
     121            GLuint id;
     122            GLint vars[VariableCount];
     123        };
     124
     125        GLint getUniformLocation(ShaderProgramIndex prog, ShaderVariableIndex var, const char* name)
     126        {
     127            return programs[prog].vars[var] = glGetUniformLocation(programs[prog].id, name);
     128        }
     129
     130        void createShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource, ShaderProgramIndex index)
     131        {
     132            GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
     133            GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
     134            GL_CMD(glShaderSource(vertexShader, 1, &vertexShaderSource, 0))
     135            GL_CMD(glShaderSource(fragmentShader, 1, &fragmentShaderSource, 0))
     136            GLuint programID = glCreateProgram();
     137            GL_CMD(glCompileShader(vertexShader))
     138            GL_CMD(glCompileShader(fragmentShader))
     139            GL_CMD(glAttachShader(programID, vertexShader))
     140            GL_CMD(glAttachShader(programID, fragmentShader))
     141            GL_CMD(glBindAttribLocation(programID, gInVertexAttributeIndex, "InVertex"))
     142            GL_CMD(glLinkProgram(programID))
     143            programs[index].id = programID;
     144#ifdef PRINT_PROGRAM_INFO_LOG
     145            char infoLog[1024];
     146            int len;
     147            GL_CMD(glGetProgramInfoLog(programID, 1024, &len, infoLog));
     148            LOG(Graphics, "Compiled program for texture mapper. Log: %s\n", infoLog);
     149#endif
     150        }
     151
     152        ProgramInfo programs[ProgramCount];
     153
     154    } shaderInfo;
     155
     156    struct DirectlyCompositedImageRepository {
     157        struct Entry {
     158            GLuint texture;
     159            int refCount;
     160        };
     161        HashMap<NativeImagePtr, Entry> imageToTexture;
     162
     163        GLuint findOrCreate(NativeImagePtr image, bool& found)
     164        {
     165            HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.find(image);
     166            found = false;
     167            if (it != imageToTexture.end()) {
     168                it->second.refCount++;
     169                found = true;
     170                return it->second.texture;
     171            }
     172            Entry entry;
     173            GL_CMD(glGenTextures(1, &entry.texture));
     174            entry.refCount = 1;
     175            imageToTexture.add(image, entry);
     176            return entry.texture;
     177        }
     178
     179        bool deref(NativeImagePtr image)
     180        {
     181            HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.find(image);
     182            if (it != imageToTexture.end()) {
     183                if (it->second.refCount < 2) {
     184                    imageToTexture.remove(it);
     185                    return false;
     186                }
     187            }
     188            return true;
     189        }
     190
     191        DirectlyCompositedImageRepository()
     192        {
     193        }
     194
     195        ~DirectlyCompositedImageRepository()
     196        {
     197            for (HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.begin(); it != imageToTexture.end(); ++it) {
     198                GLuint texture = it->second.texture;
     199                if (texture)
     200                    GL_CMD(glDeleteTextures(1, &texture));
     201            }
     202
     203        }
     204    } directlyCompositedImages;
     205
     206    TextureMapperGLData()
     207        : currentProgram(TextureMapperGLData::ShaderInfo::TargetProgram)
     208    { }
     209
     210    TransformationMatrix projectionMatrix;
     211    int currentProgram;
     212
     213#if OS(MAC_OS_X)
     214    AGLContext aglContext;
     215#elif OS(UNIX)
     216    Drawable glxDrawable;
     217    GLXContext glxContext;
     218#endif
     219};
     220
     221TextureMapperGLData::ShaderInfo TextureMapperGLData::shaderInfo;
     222
    93223class BitmapTextureGL : public BitmapTexture {
    94224public:
     
    112242    IntSize m_actualSize;
    113243    bool m_surfaceNeedsReset;
     244    RefPtr<TextureMapperGL> m_textureMapper;
    114245    BitmapTextureGL()
    115246        : m_id(0)
     
    124255};
    125256
    126 static struct TexmapShaderInfo {
    127     enum ShaderProgramIndex {
    128         SimpleProgram,
    129         OpacityAndMaskProgram,
    130         TargetProgram,
    131         NumPrograms
    132     };
    133 
    134     enum ShaderVariableIndex {
    135         InMatrixVariable,
    136         InSourceMatrixVariable,
    137         InMaskMatrixVariable,
    138         InVertexVariable,
    139 
    140         OpacityVariable,
    141         SourceTextureVariable,
    142         MaskTextureVariable,
    143         NumVariables
    144     };
    145 
    146     struct ProgramInfo {
    147         GLuint id;
    148         GLint vars[NumVariables];
    149     };
    150 
    151     GLint getUniformLocation(ShaderProgramIndex prog, ShaderVariableIndex var, const char* name)
    152     {
    153         return programs[prog].vars[var] = glGetUniformLocation(programs[prog].id, name);
    154     }
    155 
    156     void createShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource, ShaderProgramIndex index)
    157     {
    158         GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
    159         GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    160         GL_CMD(glShaderSource(vertexShader, 1, &vertexShaderSource, 0))
    161         GL_CMD(glShaderSource(fragmentShader, 1, &fragmentShaderSource, 0))
    162         GLuint programID = glCreateProgram();
    163         GL_CMD(glCompileShader(vertexShader))
    164         GL_CMD(glCompileShader(fragmentShader))
    165         GL_CMD(glAttachShader(programID, vertexShader))
    166         GL_CMD(glAttachShader(programID, fragmentShader))
    167         GL_CMD(glBindAttribLocation(programID, 0, "InVertex"))
    168         GL_CMD(glLinkProgram(programID))
    169         programs[index].id = programID;
    170     }
    171 
    172     ProgramInfo programs[NumPrograms];
    173 
    174 } gShaderInfo;
    175 
    176257#define TEXMAP_GET_SHADER_VAR_LOCATION(prog, var) \
    177             if (gShaderInfo.getUniformLocation(TexmapShaderInfo::prog##Program, TexmapShaderInfo::var##Variable, #var) < 0) \
    178                     LOG_ERROR("Couldn't find variable "#var" in program "#prog"\n");
    179 #define TEXMAP_BUILD_SHADER(program) gShaderInfo.createShaderProgram(vertexShaderSource##program, fragmentShaderSource##program, TexmapShaderInfo::program##Program);
    180 
    181 TextureMapperGL::TextureMapperGL(GraphicsContext* context)
    182     : TextureMapper(context)
    183     , m_currentProgram(TexmapShaderInfo::TargetProgram)
     258    if (TextureMapperGLData::shaderInfo.getUniformLocation(TextureMapperGLData::shaderInfo.prog##Program, TextureMapperGLData::shaderInfo.var##Variable, #var) < 0) \
     259            LOG_ERROR("Couldn't find variable "#var" in program "#prog"\n");
     260
     261#define TEXMAP_BUILD_SHADER(program) \
     262    TextureMapperGLData::shaderInfo.createShaderProgram(vertexShaderSource##program, fragmentShaderSource##program, TextureMapperGLData::shaderInfo.program##Program);
     263
     264TextureMapperGL::TextureMapperGL()
     265    : m_data(new TextureMapperGLData)
    184266{
    185267    static bool shadersCompiled = false;
     
    283365    const BitmapTextureGL& textureGL = static_cast<const BitmapTextureGL&>(texture);
    284366
    285     TexmapShaderInfo::ShaderProgramIndex program;
     367    TextureMapperGLData::ShaderInfo::ShaderProgramIndex program;
    286368    if (maskTexture)
    287         program = TexmapShaderInfo::OpacityAndMaskProgram;
     369        program = TextureMapperGLData::ShaderInfo::OpacityAndMaskProgram;
    288370    else
    289         program = TexmapShaderInfo::SimpleProgram;
    290 
    291     const TexmapShaderInfo::ProgramInfo& programInfo = gShaderInfo.programs[program];
    292     if (m_currentProgram != program) {
     371        program = TextureMapperGLData::ShaderInfo::SimpleProgram;
     372
     373    const TextureMapperGLData::ShaderInfo::ProgramInfo& programInfo = data().shaderInfo.programs[program];
     374    if (data().currentProgram != program) {
    293375        GL_CMD(glUseProgram(programInfo.id))
    294         GL_CMD(glDisableVertexAttribArray(gShaderInfo.programs[m_currentProgram].vars[TexmapShaderInfo::InVertexVariable]))
    295         m_currentProgram = program;
    296         GL_CMD(glEnableVertexAttribArray(programInfo.vars[TexmapShaderInfo::InVertexVariable]))
     376        GL_CMD(glDisableVertexAttribArray(gInVertexAttributeIndex))
     377        data().currentProgram = program;
     378        GL_CMD(glEnableVertexAttribArray(gInVertexAttributeIndex))
    297379    }
    298380
     
    306388    GL_CMD(glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, unitRect))
    307389
    308     TransformationMatrix matrix = TransformationMatrix(m_projectionMatrix).multLeft(modelViewMatrix).multLeft(TransformationMatrix(
     390    TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix).multLeft(modelViewMatrix).multLeft(TransformationMatrix(
    309391            targetRect.width(), 0, 0, 0,
    310392            0, targetRect.height(), 0, 0,
     
    322404                                     0, 0, 1, 0,
    323405                                     0, 0, 0, 1};
    324     GL_CMD(glUniformMatrix4fv(programInfo.vars[TexmapShaderInfo::InMatrixVariable], 1, GL_FALSE, m4))
    325     GL_CMD(glUniformMatrix4fv(programInfo.vars[TexmapShaderInfo::InSourceMatrixVariable], 1, GL_FALSE, m4src))
    326     GL_CMD(glUniform1i(programInfo.vars[TexmapShaderInfo::SourceTextureVariable], 0))
    327     GL_CMD(glUniform1f(programInfo.vars[TexmapShaderInfo::OpacityVariable], opacity))
     406    GL_CMD(glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InMatrixVariable], 1, GL_FALSE, m4))
     407    GL_CMD(glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InSourceMatrixVariable], 1, GL_FALSE, m4src))
     408    GL_CMD(glUniform1i(programInfo.vars[TextureMapperGLData::ShaderInfo::SourceTextureVariable], 0))
     409    GL_CMD(glUniform1f(programInfo.vars[TextureMapperGLData::ShaderInfo::OpacityVariable], opacity))
    328410
    329411    if (maskTexture && maskTexture->isValid()) {
     
    335417                                         0, 0, 1, 0,
    336418                                         0, 0, 0, 1};
    337         glUniformMatrix4fv(programInfo.vars[TexmapShaderInfo::InMaskMatrixVariable], 1, GL_FALSE, m4mask);
    338         GL_CMD(glUniform1i(programInfo.vars[TexmapShaderInfo::MaskTextureVariable], 1))
     419        glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InMaskMatrixVariable], 1, GL_FALSE, m4mask);
     420        GL_CMD(glUniform1i(programInfo.vars[TextureMapperGLData::ShaderInfo::MaskTextureVariable], 1))
    339421        GL_CMD(glActiveTexture(GL_TEXTURE0))
    340422    }
     
    400482}
    401483
    402 struct TexmapGLShaderTextures {
    403     struct Entry {
    404         GLuint texture;
    405         int refCount;
    406     };
    407     HashMap<NativeImagePtr, Entry> imageToTexture;
    408     GLuint findOrCreate(NativeImagePtr image, bool& found)
    409     {
    410         HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.find(image);
    411         found = false;
    412         if (it != imageToTexture.end()) {
    413             it->second.refCount++;
    414             found = true;
    415             return it->second.texture;
    416         }
    417         Entry entry;
    418         GL_CMD(glGenTextures(1, &entry.texture));
    419         entry.refCount = 1;
    420         imageToTexture.add(image, entry);
    421         return entry.texture;
    422     }
    423 
    424     bool deref(NativeImagePtr image)
    425     {
    426         HashMap<NativeImagePtr, Entry>::iterator it = imageToTexture.find(image);
    427         if (it != imageToTexture.end()) {
    428             if (it->second.refCount < 2) {
    429                 imageToTexture.remove(it);
    430                 return false;
    431             }
    432         }
    433         return true;
    434     }
    435 };
    436 
    437 static TexmapGLShaderTextures gTextureRepository;
    438 
    439484void BitmapTextureGL::setContentsToImage(Image* image)
    440485{
     
    449494        return;
    450495    bool found = false;
    451     GLuint newTextureID = gTextureRepository.findOrCreate(nativeImage, found);
     496    GLuint newTextureID = m_textureMapper->data().directlyCompositedImages.findOrCreate(nativeImage, found);
    452497    if (newTextureID != m_id) {
    453498        destroy();
     
    465510void BitmapTextureGL::destroy()
    466511{
    467     if (m_id && (!m_image || !gTextureRepository.deref(m_image)))
     512    if (m_id && (!m_image || !m_textureMapper->data().directlyCompositedImages.deref(m_image)))
    468513        GL_CMD(glDeleteTextures(1, &m_id))
    469514    if (m_fbo)
     
    494539}
    495540
    496 void TextureMapperGL::cleanup()
    497 {
     541TextureMapperGL::~TextureMapperGL()
     542{
     543    makeContextCurrent();
     544    delete m_data;
     545}
     546
     547bool TextureMapperGL::makeContextCurrent()
     548{
     549#if OS(MAC_OS_X)
     550    return aglSetCurrentContext(data().aglContext);
     551#elif OS(UNIX)
     552    Display* display = XOpenDisplay(0);
     553    if (!display)
     554        return false;
     555    return glXMakeCurrent(display, data().glxDrawable, data().glxContext);
     556#endif
     557}
     558
     559void TextureMapperGL::obtainCurrentContext()
     560{
     561#if OS(MAC_OS_X)
     562    data().aglContext = aglGetCurrentContext();
     563#elif OS(UNIX)
     564    data().glxDrawable = glXGetCurrentDrawable();
     565    data().glxContext = glXGetCurrentContext();
     566#endif
    498567}
    499568
     
    504573    if (!surface)
    505574        return;
     575
    506576    TransformationMatrix matrix = createProjectionMatrix(surface->size(), false);
    507577    matrix.translate(-surface->offset().x(), -surface->offset().y());
     
    521591
    522592    GL_CMD(glViewport(0, 0, surface->size().width(), surface->size().height()))
    523     m_projectionMatrix = matrix;
     593    data().projectionMatrix = matrix;
    524594}
    525595
     
    541611                        0, surface.m_actualSize.height(), 0, 0,
    542612                        0, 0, 1, 0,
    543                         surface.offset().x(), surface.offset().y(), 0, 1
    544                 )
     613                        surface.offset().x(), surface.offset().y(), 0, 1)
    545614            );
    546615
     
    558627
    559628    // We already blended the alpha in; the result is premultiplied.
    560     GL_CMD(glUseProgram(gShaderInfo.programs[TexmapShaderInfo::TargetProgram].id))
     629    GL_CMD(glUseProgram(data().shaderInfo.programs[TextureMapperGLData::ShaderInfo::TargetProgram].id))
    561630    GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, 0))
    562631    GL_CMD(glViewport(0, 0, surfaceSize.width(), surfaceSize.height()))
    563632    GL_CMD(glDisable(GL_STENCIL_TEST))
    564     const TexmapShaderInfo::ProgramInfo& programInfo = gShaderInfo.programs[TexmapShaderInfo::TargetProgram];
    565     GL_CMD(glUniform1f(programInfo.vars[TexmapShaderInfo::OpacityVariable], opacity))
     633    const TextureMapperGLData::ShaderInfo::ProgramInfo& programInfo = data().shaderInfo.programs[TextureMapperGLData::ShaderInfo::TargetProgram];
     634    GL_CMD(glUniform1f(programInfo.vars[TextureMapperGLData::ShaderInfo::OpacityVariable], opacity))
    566635    GL_CMD(glActiveTexture(GL_TEXTURE0))
    567636    GL_CMD(glBindTexture(GL_TEXTURE_2D, surface.m_id))
    568     GL_CMD(glUniform1i(programInfo.vars[TexmapShaderInfo::SourceTextureVariable], 0))
    569     GL_CMD(glEnableVertexAttribArray(programInfo.vars[TexmapShaderInfo::InVertexVariable]))
    570     GL_CMD(glUniformMatrix4fv(programInfo.vars[TexmapShaderInfo::InMatrixVariable], 1, GL_FALSE, m4))
    571     GL_CMD(glUniformMatrix4fv(programInfo.vars[TexmapShaderInfo::InSourceMatrixVariable], 1, GL_FALSE, m4src))
     637    GL_CMD(glUniform1i(programInfo.vars[TextureMapperGLData::ShaderInfo::SourceTextureVariable], 0))
     638    GL_CMD(glEnableVertexAttribArray(gInVertexAttributeIndex))
     639    GL_CMD(glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InMatrixVariable], 1, GL_FALSE, m4))
     640    GL_CMD(glUniformMatrix4fv(programInfo.vars[TextureMapperGLData::ShaderInfo::InSourceMatrixVariable], 1, GL_FALSE, m4src))
    572641    GL_CMD(glBindBuffer(GL_ARRAY_BUFFER, 0))
    573642    const GLfloat unitRect[] = {0, 0, 1, 0, 1, 1, 0, 1};
     
    578647
    579648    GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4))
    580     GL_CMD(glDisableVertexAttribArray(programInfo.vars[TexmapShaderInfo::InVertexVariable]))
     649    GL_CMD(glDisableVertexAttribArray(0))
    581650    GL_CMD(glUseProgram(0))
    582651    GL_CMD(glBindBuffer(GL_ARRAY_BUFFER, 0))
    583     m_currentProgram = TexmapShaderInfo::TargetProgram;
     652    data().currentProgram = TextureMapperGLData::ShaderInfo::TargetProgram;
    584653}
    585654
    586655PassRefPtr<BitmapTexture> TextureMapperGL::createTexture()
    587656{
    588     return adoptRef(new BitmapTextureGL());
     657    BitmapTextureGL* texture = new BitmapTextureGL();
     658    texture->m_textureMapper = this;
     659    return adoptRef(texture);
    589660}
    590661
  • trunk/WebCore/platform/graphics/opengl/TextureMapperGL.h

    r70452 r71213  
    3030namespace WebCore {
    3131
     32class TextureMapperGLData;
     33
    3234// An OpenGL-ES2 implementation of TextureMapper.
    3335class TextureMapperGL : public TextureMapper {
    3436public:
    35     TextureMapperGL(GraphicsContext* gc);
    36     virtual ~TextureMapperGL() {}
     37    TextureMapperGL();
     38    virtual ~TextureMapperGL();
    3739
    3840    // reimps from TextureMapper
     
    4446    virtual PassRefPtr<BitmapTexture> createTexture();
    4547    virtual const char* type() const;
    46     virtual void cleanup();
     48    void obtainCurrentContext();
     49    bool makeContextCurrent();
    4750
    4851private:
    49     TransformationMatrix m_projectionMatrix;
    50     int m_currentProgram;
     52    inline TextureMapperGLData& data() { return *m_data; }
     53    TextureMapperGLData* m_data;
     54    friend class BitmapTextureGL;
    5155};
    5256
  • trunk/WebCore/platform/graphics/qt/TextureMapperQt.cpp

    r69374 r71213  
    5555    virtual void bindSurface(BitmapTexture* surface);
    5656    virtual void setClip(const IntRect&);
     57    virtual void setGraphicsContext(GraphicsContext*);
    5758    virtual bool allowSurfaceForRoot() const { return false; }
    58     TextureMapperQt(GraphicsContext* context);
     59    TextureMapperQt();
    5960    virtual const char* type() const { return "TextureMapperQt"; }
    6061    virtual PassRefPtr<BitmapTexture> createTexture();
     
    124125}
    125126
    126 TextureMapperQt::TextureMapperQt(GraphicsContext* context)
    127     : TextureMapper(context)
    128     , m_painter(context->platformContext())
    129     , m_currentSurface(0)
    130 {
    131     TextureMapperQt::initialize(m_painter);
     127TextureMapperQt::TextureMapperQt()
     128    : m_currentSurface(0)
     129{
     130}
     131
     132void TextureMapperQt::setGraphicsContext(GraphicsContext* context)
     133{
     134    m_painter = context->platformContext();
     135    initialize(m_painter);
    132136}
    133137
     
    182186{
    183187#ifdef QT_OPENGL_LIB
    184     if (context->platformContext()->paintEngine()->type() == QPaintEngine::OpenGL2)
    185         return adoptRef(new TextureMapperGL(context));
     188    if (context->platformContext()->paintEngine()->type() == QPaintEngine::OpenGL2) {
     189        TextureMapperGL* texmapGL = new TextureMapperGL;
     190        return adoptRef(texmapGL);
     191    }
    186192#endif
    187     return adoptRef(new TextureMapperQt(context));
     193    return adoptRef(new TextureMapperQt);
    188194}
    189195
  • trunk/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp

    r70819 r71213  
    4141    BitmapTexture* surface;
    4242    TextureMapper* textureMapper;
    43     GraphicsContext* context;
    4443    TextureMapperNode* rootLayer;
    4544    float opacity;
     
    215214
    216215    virtual void setPlatformLayerClient(TextureMapperLayerClient*);
    217     virtual void paint(GraphicsContext*, const IntSize&, const IntRect& targetRect, const IntRect& exposedRect, const TransformationMatrix& transform, float opacity);
     216    virtual void paint(TextureMapper*, const TextureMapperContentLayer::PaintOptions&);
    218217
    219218    static TextureMapperNode* toTextureMapperNode(GraphicsLayer*);
     
    399398}
    400399
    401 void TextureMapperNode::paint(GraphicsContext* context, const IntSize& size, const IntRect& targetRect, const IntRect& exposedRect, const TransformationMatrix& transform, float opacity)
     400void TextureMapperNode::paint(TextureMapper* textureMapper, const TextureMapperContentLayer::PaintOptions& options)
    402401{
    403402    ASSERT(m_layerType == RootLayer);
     
    410409#endif
    411410
    412     RefPtr<TextureMapper> textureMapper = TextureMapper::create(context);
    413 
    414411    if (textureMapper->type() != m_lastTextureMapperType)
    415412        gTextureMapperCache.m_data.clear();
     
    419416    opt.opacity = 1;
    420417    opt.rootLayer = this;
    421     opt.scissorRect = targetRect;
    422     opt.visibleRect = exposedRect;
    423     opt.textureMapper = textureMapper.get();
    424     opt.context = textureMapper->graphicsContext();
     418    opt.scissorRect = options.targetRect;
     419    opt.visibleRect = options.visibleRect;
     420    opt.textureMapper = textureMapper;
    425421    opt.surface = 0;
    426422    paintRecursive(opt);
     
    428424    if (textureMapper->allowSurfaceForRoot() || m_state.hasSurfaceDescendants) {
    429425        textureMapper->bindSurface(0);
    430         textureMapper->paintToTarget(*m_surface.get(), size, transform, opacity * m_state.opacity, targetRect);
     426        textureMapper->paintToTarget(*m_surface.get(), options.viewportSize, options.transform, options.opacity * m_state.opacity, options.targetRect);
    431427    }
    432428    gTextureMapperCache.purge();
     
    693689    {
    694690        GraphicsContext context(m_texture->beginPaint(dirtyRect));
    695         if (textureMapper && textureMapper->graphicsContext()) {
    696             GraphicsContext* originalContext = textureMapper->graphicsContext();
    697             context.setImageInterpolationQuality(originalContext->imageInterpolationQuality());
    698             context.setTextDrawingMode(originalContext->textDrawingMode());
     691        if (textureMapper) {
     692            context.setImageInterpolationQuality(textureMapper->imageInterpolationQuality());
     693            context.setTextDrawingMode(textureMapper->textDrawingMode());
    699694        }
    700695        m_layer->paintGraphicsLayerContents(context, dirtyRect);
  • trunk/WebCore/platform/graphics/texmap/TextureMapper.h

    r69374 r71213  
    9898    }
    9999
     100    virtual void setGraphicsContext(GraphicsContext*) { }
    100101    virtual void setClip(const IntRect&) = 0;
    101102    virtual bool allowSurfaceForRoot() const = 0;
     
    104105    virtual void cleanup() {}
    105106
    106     GraphicsContext* graphicsContext() const
    107     {
    108         return m_gc;
    109     }
     107    void setImageInterpolationQuality(InterpolationQuality quality) { m_interpolationQuality = quality; }
     108    void setTextDrawingMode(int mode) { m_textDrawingMode = mode; }
     109
     110    InterpolationQuality imageInterpolationQuality() const { return m_interpolationQuality; }
     111    int textDrawingMode() const { return m_textDrawingMode; }
     112
     113    void setViewportSize(const IntSize&);
    110114
    111115protected:
    112     TextureMapper(GraphicsContext* gc) : m_gc(gc) {}
    113     GraphicsContext* m_gc;
     116    TextureMapper()
     117        : m_interpolationQuality(InterpolationDefault)
     118        , m_textDrawingMode(cTextFill)
     119    {}
     120
     121private:
     122    InterpolationQuality m_interpolationQuality;
     123    int m_textDrawingMode;
    114124};
    115125
  • trunk/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h

    r69374 r71213  
    2626class IntRect;
    2727class IntSize;
     28class TextureMapper;
    2829class TransformationMatrix;
    2930
     
    5152class TextureMapperContentLayer : public TextureMapperPlatformLayer {
    5253public:
     54    struct PaintOptions {
     55        IntRect visibleRect;
     56        IntRect targetRect;
     57        IntSize viewportSize;
     58        TransformationMatrix transform;
     59        float opacity;
     60    };
     61
    5362    virtual void setPlatformLayerClient(TextureMapperLayerClient*) = 0;
    54     virtual void paint(GraphicsContext*, const IntSize&, const IntRect& targetRect, const IntRect& exposedRect, const TransformationMatrix& transform, float opacity) {}
     63    virtual void paint(TextureMapper*, const PaintOptions&) {}
    5564    virtual IntSize size() const = 0;
    56     virtual void cleanupTextureMapper() {}
    5765    virtual Type layerType() const { return ContentLayer; }
    5866};
  • trunk/WebKit/qt/Api/qwebframe.cpp

    r70976 r71213  
    9898#endif
    9999#if USE(TEXTURE_MAPPER)
     100#include "texmap/TextureMapper.h"
    100101#include "texmap/TextureMapperPlatformLayer.h"
    101102#endif
     
    295296        painter->restore();
    296297    }
     298
    297299#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
    298     // TextureMapper might use raw OpenGL or some other backend that requires native painting. On raster this doesn't have any effect.
    299     if (rootGraphicsLayer) {
    300         painter->beginNativePainting();
    301         rootGraphicsLayer->paint(context, view->size(), view->frameRect(), IntRect(clip.boundingRect()), TransformationMatrix(), painter->opacity());
    302         painter->endNativePainting();
    303     }
    304 
     300    renderCompositedLayers(context, IntRect(clip.boundingRect()));
    305301    renderRelativeCoords(context, (QWebFrame::RenderLayer)(QWebFrame::ScrollBarLayer | QWebFrame::PanIconLayer), clip);
    306302#endif
     303}
     304#endif
     305
     306#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
     307void QWebFramePrivate::renderCompositedLayers(GraphicsContext* context, const IntRect& clip)
     308{
     309    if (!rootGraphicsLayer)
     310        return;
     311
     312    if (!textureMapper)
     313        textureMapper = TextureMapper::create(context);
     314
     315    textureMapper->setGraphicsContext(context);
     316    textureMapper->setImageInterpolationQuality(context->imageInterpolationQuality());
     317    textureMapper->setTextDrawingMode(context->textDrawingMode());
     318    QPainter* painter = context->platformContext();
     319    FrameView* view = frame->view();
     320    painter->save();
     321    painter->beginNativePainting();
     322    TextureMapperContentLayer::PaintOptions options;
     323    options.visibleRect = clip;
     324    options.targetRect = view->frameRect();
     325    options.viewportSize = view->size();
     326    options.opacity = painter->opacity();
     327    rootGraphicsLayer->paint(textureMapper.get(), options);
     328    painter->endNativePainting();
     329    painter->restore();
    307330}
    308331#endif
     
    350373        }
    351374        painter->restore();
    352 
    353375#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
    354         if (rootGraphicsLayer) {
    355             painter->save();
    356             painter->beginNativePainting();
    357             rootGraphicsLayer->paint(context, view->size(), view->frameRect(), IntRect(clip.boundingRect()),
    358                                      TransformationMatrix(), context->platformContext()->opacity());
    359             painter->endNativePainting();
    360             painter->restore();
    361         }
     376        renderCompositedLayers(context, IntRect(clip.boundingRect()));
    362377#endif
    363378    }
  • trunk/WebKit/qt/Api/qwebframe_p.h

    r70487 r71213  
    3333#include "Frame.h"
    3434#include "ViewportArguments.h"
     35
     36#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
     37#include "texmap/TextureMapper.h"
     38#endif
    3539
    3640namespace WebCore {
     
    9599#endif
    96100
     101#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
     102    void renderCompositedLayers(WebCore::GraphicsContext* context, const WebCore::IntRect& clip);
     103#endif
    97104    QWebFrame *q;
    98105    Qt::ScrollBarPolicy horizontalScrollBarPolicy;
     
    107114#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
    108115    WebCore::TextureMapperContentLayer* rootGraphicsLayer;
     116    RefPtr<WebCore::TextureMapper> textureMapper;
    109117#endif
    110118    bool zoomTextOnly;
  • trunk/WebKit/qt/ChangeLog

    r71041 r71213  
     12010-11-02  Noam Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Some refactor for texmap to enable WebKit2: remove globals, and allow TextureMapper to exist without a GraphicsContext.
     6        This will allow rendering the TextureMapperNode tree without an active QPainter, into the current GL context.
     7        Most of the changes simply move the globas in TextureMapperGL into members of that class.
     8
     9        [Texmap] [Qt] Texture mapper initial implementation
     10        https://bugs.webkit.org/show_bug.cgi?id=47070
     11
     12        * Api/qwebframe.cpp:
     13        (QWebFramePrivate::renderFromTiledBackingStore):
     14        (QWebFramePrivate::renderCompositedLayers):
     15        (QWebFramePrivate::renderRelativeCoords):
     16        * Api/qwebframe_p.h:
     17
    1182010-11-01  Brady Eidson  <beidson@apple.com>
    219
Note: See TracChangeset for help on using the changeset viewer.