Changeset 65836 in webkit


Ignore:
Timestamp:
Aug 23, 2010 3:23:42 PM (14 years ago)
Author:
senorblanco@chromium.org
Message:

2010-08-20 Stephen White <senorblanco@chromium.org>

Reviewed by Kenneth Russell.

[CHROMIUM] Fix some failing layout tests w/ACCELERATED_2D_CANVAS
https://bugs.webkit.org/show_bug.cgi?id=44346

LayoutTests/fast/canvas/canvas-incremental-repaint.html (top middle
pane).
Failing because we were not applying the CTM in clearRect(). Now using
the fast path when the CTM is identity, and a fillRect() for the rest.
LayoutTests/fast/canvas/canvas-strokeRect.html
LayoutTests/fast/canvas/shadow-offset-[1-7].html
Failing because we weren't switching to the software path when a
shadow is present.
Also refactor the two versions of fillRect(), and use TRIANGLE_STRIP
strip instead of TRIANGLES, which lets us get rid of the element array
and use drawArrays() instead of drawElements().

Covered by the above layout tests.

  • platform/graphics/chromium/GLES2Canvas.cpp: (WebCore::GLES2Canvas::GLES2Canvas): (WebCore::GLES2Canvas::~GLES2Canvas): Remove m_quadIndices (now unused). (WebCore::GLES2Canvas::clearRect): Use a glClear() fast path for the identity-CTM clear, and fillRect() for the rest. (WebCore::GLES2Canvas::fillRect): Refactor the two versions of fillRect(). (WebCore::GLES2Canvas::drawTexturedRect): (WebCore::GLES2Canvas::drawTexturedRectTile): Get rid of the ELEMENT_ARRAY_BUFFER bind. Use drawArrays() instead of drawElements(). (WebCore::GLES2Canvas::getQuadVertices): Re-order the vertices so they form a triangle strip.
  • platform/graphics/chromium/GLES2Canvas.h: Remove m_quadIndices (now unused).
  • platform/graphics/skia/GraphicsContextSkia.cpp: (WebCore::GraphicsContext::fillRect): Check for a draw looper (shadow), and drop to the software path.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65835 r65836  
     12010-08-20  Stephen White  <senorblanco@chromium.org>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        [CHROMIUM] Fix some failing layout tests w/ACCELERATED_2D_CANVAS
     6        https://bugs.webkit.org/show_bug.cgi?id=44346
     7
     8        LayoutTests/fast/canvas/canvas-incremental-repaint.html (top middle
     9        pane).
     10        Failing because we were not applying the CTM in clearRect().  Now using
     11        the fast path when the CTM is identity, and a fillRect() for the rest.
     12        LayoutTests/fast/canvas/canvas-strokeRect.html
     13        LayoutTests/fast/canvas/shadow-offset-[1-7].html
     14        Failing because we weren't switching to the software path when a
     15        shadow is present.
     16        Also refactor the two versions of fillRect(), and use TRIANGLE_STRIP
     17        strip instead of TRIANGLES, which lets us get rid of the element array
     18        and use drawArrays() instead of drawElements().
     19
     20        Covered by the above layout tests.
     21
     22        * platform/graphics/chromium/GLES2Canvas.cpp:
     23        (WebCore::GLES2Canvas::GLES2Canvas):
     24        (WebCore::GLES2Canvas::~GLES2Canvas):
     25        Remove m_quadIndices (now unused).
     26        (WebCore::GLES2Canvas::clearRect):
     27        Use a glClear() fast path for the identity-CTM clear, and fillRect()
     28        for the rest.
     29        (WebCore::GLES2Canvas::fillRect):
     30        Refactor the two versions of fillRect().
     31        (WebCore::GLES2Canvas::drawTexturedRect):
     32        (WebCore::GLES2Canvas::drawTexturedRectTile):
     33        Get rid of the ELEMENT_ARRAY_BUFFER bind.  Use drawArrays() instead of
     34        drawElements().
     35        (WebCore::GLES2Canvas::getQuadVertices):
     36        Re-order the vertices so they form a triangle strip.
     37        * platform/graphics/chromium/GLES2Canvas.h:
     38        Remove m_quadIndices (now unused).
     39        * platform/graphics/skia/GraphicsContextSkia.cpp:
     40        (WebCore::GraphicsContext::fillRect):
     41        Check for a draw looper (shadow), and drop to the software path.
     42
    1432010-08-23  Patrick Gansterer  <paroga@paroga.com>
    244
  • trunk/WebCore/platform/graphics/chromium/GLES2Canvas.cpp

    r65455 r65836  
    8080    : m_context(context)
    8181    , m_quadVertices(0)
    82     , m_quadIndices(0)
    8382    , m_simpleProgram(0)
    8483    , m_texProgram(0)
     
    112111    m_context->deleteProgram(m_texProgram);
    113112    m_context->deleteBuffer(m_quadVertices);
    114     m_context->deleteBuffer(m_quadIndices);
    115113}
    116114
    117115void GLES2Canvas::clearRect(const FloatRect& rect)
    118116{
    119     m_context->scissor(rect.x(), rect.y(), rect.width(), rect.height());
    120     m_context->enable(GraphicsContext3D::SCISSOR_TEST);
    121     m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
    122     m_context->disable(GraphicsContext3D::SCISSOR_TEST);
     117    if (m_state->m_ctm.isIdentity()) {
     118        m_context->scissor(rect.x(), rect.y(), rect.width(), rect.height());
     119        m_context->enable(GraphicsContext3D::SCISSOR_TEST);
     120        m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
     121        m_context->disable(GraphicsContext3D::SCISSOR_TEST);
     122    } else {
     123        save();
     124        setCompositeOperation(CompositeClear);
     125        fillRect(rect, Color(RGBA32(0)), DeviceColorSpace);
     126        restore();
     127    }
    123128}
    124129
    125130void GLES2Canvas::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
    126131{
     132    applyCompositeOperator(m_state->m_compositeOp);
     133
    127134    m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, getQuadVertices());
    128     m_context->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, getQuadIndices());
     135
     136    m_context->useProgram(getSimpleProgram());
    129137
    130138    float rgba[4];
    131139    color.getRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
    132     m_context->uniform4f(m_simpleColorLocation, rgba[0] * rgba[3], rgba[1] * rgba[3], rgba[2] * rgba[3], rgba[3]);
    133 
    134     m_context->drawElements(GraphicsContext3D::TRIANGLES, 6, GraphicsContext3D::UNSIGNED_SHORT, 0);
    135 }
    136 
    137 void GLES2Canvas::fillRect(const FloatRect& rect)
    138 {
    139     applyCompositeOperator(m_state->m_compositeOp);
    140 
    141     m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, getQuadVertices());
    142     m_context->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, getQuadIndices());
    143 
    144     m_context->useProgram(getSimpleProgram());
    145 
    146     float rgba[4];
    147     m_state->m_fillColor.getRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
    148140    m_context->uniform4f(m_simpleColorLocation, rgba[0] * rgba[3], rgba[1] * rgba[3], rgba[2] * rgba[3], rgba[3]);
    149141
     
    160152    m_context->enableVertexAttribArray(m_simplePositionLocation);
    161153
    162     m_context->drawElements(GraphicsContext3D::TRIANGLES, 6, GraphicsContext3D::UNSIGNED_SHORT, 0);
     154    m_context->drawArrays(GraphicsContext3D::TRIANGLE_STRIP, 0, 4);
     155}
     156
     157void GLES2Canvas::fillRect(const FloatRect& rect)
     158{
     159    fillRect(rect, m_state->m_fillColor, DeviceColorSpace);
    163160}
    164161
     
    216213
    217214    m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, getQuadVertices());
    218     m_context->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, getQuadIndices());
    219215    checkGLError("glBindBuffer");
    220216
     
    276272    checkGLError("glUniformMatrix3fv");
    277273
    278     m_context->drawElements(GraphicsContext3D::TRIANGLES, 6, GraphicsContext3D::UNSIGNED_SHORT, 0);
    279     checkGLError("glDrawElements");
     274    m_context->drawArrays(GraphicsContext3D::TRIANGLE_STRIP, 0, 4);
     275    checkGLError("glDrawArrays");
    280276}
    281277
     
    352348        float vertices[] = { 0.0f, 0.0f, 1.0f,
    353349                             1.0f, 0.0f, 1.0f,
    354                              1.0f, 1.0f, 1.0f,
    355                              0.0f, 1.0f, 1.0f };
     350                             0.0f, 1.0f, 1.0f,
     351                             1.0f, 1.0f, 1.0f };
    356352        m_quadVertices = m_context->createBuffer();
    357353        RefPtr<Float32Array> vertexArray = Float32Array::create(vertices, sizeof(vertices) / sizeof(float));
     
    362358}
    363359
    364 
    365 unsigned GLES2Canvas::getQuadIndices()
    366 {
    367     if (!m_quadIndices) {
    368         unsigned short indices[] = { 0, 1, 2, 0, 2, 3};
    369 
    370         m_quadIndices = m_context->createBuffer();
    371         RefPtr<Uint16Array> indexArray = Uint16Array::create(indices, sizeof(indices) / sizeof(unsigned short));
    372         m_context->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, m_quadIndices);
    373         m_context->bufferData(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, indexArray.get(), GraphicsContext3D::STATIC_DRAW);
    374     }
    375     return m_quadIndices;
    376 }
    377360
    378361static unsigned loadShader(GraphicsContext3D* context, unsigned type, const char* shaderSource)
  • trunk/WebCore/platform/graphics/chromium/GLES2Canvas.h

    r65455 r65836  
    8686    void checkGLError(const char* header);
    8787    unsigned getQuadVertices();
    88     unsigned getQuadIndices();
    8988    unsigned getSimpleProgram();
    9089    unsigned getTexProgram();
     
    9594    State* m_state;
    9695    unsigned m_quadVertices;
    97     unsigned m_quadIndices;
    9896    unsigned m_simpleProgram;
    9997    unsigned m_texProgram;
  • trunk/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

    r65700 r65836  
    782782
    783783#if USE(GLES2_RENDERING)
    784     if (platformContext()->useGPU() && !m_common->state.fillPattern && !m_common->state.fillGradient) {
     784    if (platformContext()->useGPU() && !m_common->state.fillPattern && !m_common->state.fillGradient && !platformContext()->getDrawLooper()) {
    785785        platformContext()->prepareForHardwareDraw();
    786786        platformContext()->gpuCanvas()->fillRect(rect);
Note: See TracChangeset for help on using the changeset viewer.