Changeset 95341 in webkit


Ignore:
Timestamp:
Sep 16, 2011 5:33:09 PM (13 years ago)
Author:
enne@google.com
Message:

[chromium] Move quad drawing code from LayerChromium to LayerRendererChromium
https://bugs.webkit.org/show_bug.cgi?id=68272

Reviewed by James Robinson.

All the OpenGL code is in LayerRendererChromium and the CCLayerImpl
tree, so move the static drawTexturedQuad/toGLMatrix functions to
LayerRendererChromium, where they really belong.

Just moving code around. Tested by existing compositor tests.

  • platform/graphics/chromium/LayerChromium.cpp:
  • platform/graphics/chromium/LayerChromium.h:
  • platform/graphics/chromium/LayerRendererChromium.cpp:

(WebCore::LayerRendererChromium::toGLMatrix):
(WebCore::LayerRendererChromium::drawTexturedQuad):

  • platform/graphics/chromium/LayerRendererChromium.h:
  • platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp:

(WebCore::CCCanvasLayerImpl::draw):

  • platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:

(WebCore::CCHeadsUpDisplay::draw):

  • platform/graphics/chromium/cc/CCLayerImpl.cpp:

(WebCore::CCLayerImpl::drawDebugBorder):

  • platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:

(WebCore::CCPluginLayerImpl::draw):

  • platform/graphics/chromium/cc/CCRenderSurface.cpp:

(WebCore::CCRenderSurface::drawSurface):

  • platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:

(WebCore::CCTiledLayerImpl::drawTiles):

  • platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:

(WebCore::CCVideoLayerImpl::drawYUV):
(WebCore::CCVideoLayerImpl::drawRGBA):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r95336 r95341  
     12011-09-16  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Move quad drawing code from LayerChromium to LayerRendererChromium
     4        https://bugs.webkit.org/show_bug.cgi?id=68272
     5
     6        Reviewed by James Robinson.
     7
     8        All the OpenGL code is in LayerRendererChromium and the CCLayerImpl
     9        tree, so move the static drawTexturedQuad/toGLMatrix functions to
     10        LayerRendererChromium, where they really belong.
     11
     12        Just moving code around. Tested by existing compositor tests.
     13
     14        * platform/graphics/chromium/LayerChromium.cpp:
     15        * platform/graphics/chromium/LayerChromium.h:
     16        * platform/graphics/chromium/LayerRendererChromium.cpp:
     17        (WebCore::LayerRendererChromium::toGLMatrix):
     18        (WebCore::LayerRendererChromium::drawTexturedQuad):
     19        * platform/graphics/chromium/LayerRendererChromium.h:
     20        * platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp:
     21        (WebCore::CCCanvasLayerImpl::draw):
     22        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
     23        (WebCore::CCHeadsUpDisplay::draw):
     24        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
     25        (WebCore::CCLayerImpl::drawDebugBorder):
     26        * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
     27        (WebCore::CCPluginLayerImpl::draw):
     28        * platform/graphics/chromium/cc/CCRenderSurface.cpp:
     29        (WebCore::CCRenderSurface::drawSurface):
     30        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
     31        (WebCore::CCTiledLayerImpl::drawTiles):
     32        * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
     33        (WebCore::CCVideoLayerImpl::drawYUV):
     34        (WebCore::CCVideoLayerImpl::drawRGBA):
     35
    1362011-09-16  Shawn Singh  <shawnsingh@chromium.org>
    237
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp

    r95148 r95341  
    3636
    3737#include "cc/CCLayerImpl.h"
     38#include "cc/CCLayerTreeHost.h"
    3839#include "GraphicsContext3D.h"
    39 #include "LayerRendererChromium.h"
    4040#if USE(SKIA)
    4141#include "NativeImageSkia.h"
     
    295295}
    296296
    297 void LayerChromium::toGLMatrix(float* flattened, const TransformationMatrix& m)
    298 {
    299     flattened[0] = m.m11();
    300     flattened[1] = m.m12();
    301     flattened[2] = m.m13();
    302     flattened[3] = m.m14();
    303     flattened[4] = m.m21();
    304     flattened[5] = m.m22();
    305     flattened[6] = m.m23();
    306     flattened[7] = m.m24();
    307     flattened[8] = m.m31();
    308     flattened[9] = m.m32();
    309     flattened[10] = m.m33();
    310     flattened[11] = m.m34();
    311     flattened[12] = m.m41();
    312     flattened[13] = m.m42();
    313     flattened[14] = m.m43();
    314     flattened[15] = m.m44();
    315 }
    316 
    317297void LayerChromium::pushPropertiesTo(CCLayerImpl* layer)
    318298{
     
    342322}
    343323
    344 void LayerChromium::drawTexturedQuad(GraphicsContext3D* context, const TransformationMatrix& projectionMatrix, const TransformationMatrix& drawMatrix,
    345                                      float width, float height, float opacity, const FloatQuad& quad,
    346                                      int matrixLocation, int alphaLocation, int quadLocation)
    347 {
    348     static float glMatrix[16];
    349 
    350     TransformationMatrix renderMatrix = drawMatrix;
    351 
    352     // Apply a scaling factor to size the quad from 1x1 to its intended size.
    353     renderMatrix.scale3d(width, height, 1);
    354 
    355     // Apply the projection matrix before sending the transform over to the shader.
    356     toGLMatrix(&glMatrix[0], projectionMatrix * renderMatrix);
    357 
    358     GLC(context, context->uniformMatrix4fv(matrixLocation, false, &glMatrix[0], 1));
    359 
    360     if (quadLocation != -1) {
    361         float point[8];
    362         point[0] = quad.p1().x();
    363         point[1] = quad.p1().y();
    364         point[2] = quad.p2().x();
    365         point[3] = quad.p2().y();
    366         point[4] = quad.p3().x();
    367         point[5] = quad.p3().y();
    368         point[6] = quad.p4().x();
    369         point[7] = quad.p4().y();
    370         GLC(context, context->uniform2fv(quadLocation, point, 4));
    371     }
    372 
    373     if (alphaLocation != -1)
    374         GLC(context, context->uniform1f(alphaLocation, opacity));
    375 
    376     GLC(context, context->drawElements(GraphicsContext3D::TRIANGLES, 6, GraphicsContext3D::UNSIGNED_SHORT, 0));
    377 }
    378 
    379324PassRefPtr<CCLayerImpl> LayerChromium::createCCLayerImpl()
    380325{
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r95336 r95341  
    184184    void setBorderWidth(float);
    185185
    186     static void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& layerMatrix,
    187                                  float width, float height, float opacity, const FloatQuad&,
    188                                  int matrixLocation, int alphaLocation, int quadLocation);
    189 
    190186    virtual void pushPropertiesTo(CCLayerImpl*);
    191187
     
    225221    // hold context-dependent resources such as textures.
    226222    virtual void cleanupResources();
    227 
    228     static void toGLMatrix(float*, const TransformationMatrix&);
    229223
    230224    FloatRect m_dirtyRect;
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r95320 r95341  
    347347}
    348348
     349void LayerRendererChromium::toGLMatrix(float* flattened, const TransformationMatrix& m)
     350{
     351    flattened[0] = m.m11();
     352    flattened[1] = m.m12();
     353    flattened[2] = m.m13();
     354    flattened[3] = m.m14();
     355    flattened[4] = m.m21();
     356    flattened[5] = m.m22();
     357    flattened[6] = m.m23();
     358    flattened[7] = m.m24();
     359    flattened[8] = m.m31();
     360    flattened[9] = m.m32();
     361    flattened[10] = m.m33();
     362    flattened[11] = m.m34();
     363    flattened[12] = m.m41();
     364    flattened[13] = m.m42();
     365    flattened[14] = m.m43();
     366    flattened[15] = m.m44();
     367}
     368
     369void LayerRendererChromium::drawTexturedQuad(const TransformationMatrix& drawMatrix,
     370                                             float width, float height, float opacity, const FloatQuad& quad,
     371                                             int matrixLocation, int alphaLocation, int quadLocation)
     372{
     373    static float glMatrix[16];
     374
     375    TransformationMatrix renderMatrix = drawMatrix;
     376
     377    // Apply a scaling factor to size the quad from 1x1 to its intended size.
     378    renderMatrix.scale3d(width, height, 1);
     379
     380    // Apply the projection matrix before sending the transform over to the shader.
     381    toGLMatrix(&glMatrix[0], m_projectionMatrix * renderMatrix);
     382
     383    GLC(m_context, m_context->uniformMatrix4fv(matrixLocation, false, &glMatrix[0], 1));
     384
     385    if (quadLocation != -1) {
     386        float point[8];
     387        point[0] = quad.p1().x();
     388        point[1] = quad.p1().y();
     389        point[2] = quad.p2().x();
     390        point[3] = quad.p2().y();
     391        point[4] = quad.p3().x();
     392        point[5] = quad.p3().y();
     393        point[6] = quad.p4().x();
     394        point[7] = quad.p4().y();
     395        GLC(m_context, m_context->uniform2fv(quadLocation, point, 4));
     396    }
     397
     398    if (alphaLocation != -1)
     399        GLC(m_context, m_context->uniform1f(alphaLocation, opacity));
     400
     401    GLC(m_context, m_context->drawElements(GraphicsContext3D::TRIANGLES, 6, GraphicsContext3D::UNSIGNED_SHORT, 0));
     402}
     403
    349404void LayerRendererChromium::finish()
    350405{
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r95135 r95341  
    151151    void setContentsTextureMemoryUseBytes(size_t contentsTextureMemoryUseBytes) { m_contentsTextureMemoryUseBytes = contentsTextureMemoryUseBytes; }
    152152
     153    static void toGLMatrix(float*, const TransformationMatrix&);
     154    void drawTexturedQuad(const TransformationMatrix& layerMatrix,
     155                          float width, float height, float opacity, const FloatQuad&,
     156                          int matrixLocation, int alphaLocation, int quadLocation);
     157
    153158private:
    154159    LayerRendererChromium(CCLayerTreeHostImpl*, PassRefPtr<GraphicsContext3D>);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp

    r95135 r95341  
    6767    GLC(context, context->useProgram(program->program()));
    6868    GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
    69     LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), drawTransform(),
    70                                     bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
     69    layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
    7170                                    program->vertexShader().matrixLocation(),
    7271                                    program->fragmentShader().alphaLocation(),
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp

    r94703 r95341  
    152152    TransformationMatrix matrix;
    153153    matrix.translate3d(hudSize.width() * 0.5, hudSize.height() * 0.5, 0);
    154     LayerChromium::drawTexturedQuad(context, m_layerRenderer->projectionMatrix(),
    155                                     matrix, hudSize.width(), hudSize.height(),
    156                                     1.0f, m_layerRenderer->sharedGeometryQuad(), program->vertexShader().matrixLocation(),
    157                                     program->fragmentShader().alphaLocation(),
    158                                     -1);
     154    m_layerRenderer->drawTexturedQuad(matrix, hudSize.width(), hudSize.height(),
     155                                      1.0f, m_layerRenderer->sharedGeometryQuad(), program->vertexShader().matrixLocation(),
     156                                      program->fragmentShader().alphaLocation(),
     157                                      -1);
    159158    m_hudTexture->unreserve();
    160159}
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp

    r95135 r95341  
    3636#include <wtf/text/WTFString.h>
    3737
    38 namespace {
    39 void toGLMatrix(float* flattened, const WebCore::TransformationMatrix& m)
    40 {
    41     flattened[0] = m.m11();
    42     flattened[1] = m.m12();
    43     flattened[2] = m.m13();
    44     flattened[3] = m.m14();
    45     flattened[4] = m.m21();
    46     flattened[5] = m.m22();
    47     flattened[6] = m.m23();
    48     flattened[7] = m.m24();
    49     flattened[8] = m.m31();
    50     flattened[9] = m.m32();
    51     flattened[10] = m.m33();
    52     flattened[11] = m.m34();
    53     flattened[12] = m.m41();
    54     flattened[13] = m.m42();
    55     flattened[14] = m.m43();
    56     flattened[15] = m.m44();
    57 }
    58 }
    59 
    60 
    6138namespace WebCore {
    6239
     
    168145    TransformationMatrix renderMatrix = drawTransform();
    169146    renderMatrix.scale3d(bounds().width(), bounds().height(), 1);
    170     toGLMatrix(&glMatrix[0], layerRenderer->projectionMatrix() * renderMatrix);
     147    LayerRendererChromium::toGLMatrix(&glMatrix[0], layerRenderer->projectionMatrix() * renderMatrix);
    171148    GLC(context, context->uniformMatrix4fv(program->vertexShader().matrixLocation(), false, &glMatrix[0], 1));
    172149
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp

    r95135 r95341  
    6565    GLC(context, context->useProgram(program->program()));
    6666    GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
    67     LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), drawTransform(),
    68                                     bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
     67    layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
    6968                                    program->vertexShader().matrixLocation(),
    7069                                    program->fragmentShader().alphaLocation(),
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp

    r95135 r95341  
    203203    FloatQuad quad = deviceTransform.inverse().mapQuad(layerQuad.floatQuad());
    204204
    205     LayerChromium::drawTexturedQuad(layerRenderer->context(), layerRenderer->projectionMatrix(), drawTransform,
    206                                     m_contentRect.width(), m_contentRect.height(), m_drawOpacity, quad,
     205    layerRenderer->drawTexturedQuad(drawTransform, m_contentRect.width(), m_contentRect.height(), m_drawOpacity, quad,
    207206                                    program->vertexShader().matrixLocation(), program->fragmentShader().alphaLocation(), shaderQuadLocation);
    208207}
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp

    r95135 r95341  
    320320            GLC(context, context->uniform4f(program->vertexShader().vertexTexTransformLocation(), vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY));
    321321
    322             LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), globalTransform,
     322            layerRenderer->drawTexturedQuad(globalTransform,
    323323                                            tileRect.width(), tileRect.height(), opacity, quad,
    324324                                            program->vertexShader().matrixLocation(),
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp

    r95135 r95341  
    132132    GLC(context, context->uniform3fv(program->fragmentShader().yuvAdjLocation(), const_cast<float*>(yuvAdjust), 1));
    133133
    134     LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), drawTransform(),
    135                                     bounds().width(), bounds().height(), drawOpacity(), FloatQuad(),
     134    layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), FloatQuad(),
    136135                                    program->vertexShader().matrixLocation(),
    137136                                    program->fragmentShader().alphaLocation(),
     
    159158    GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
    160159
    161     LayerChromium::drawTexturedQuad(context, layerRenderer->projectionMatrix(), drawTransform(),
    162                                     bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
     160    layerRenderer->drawTexturedQuad(drawTransform(), bounds().width(), bounds().height(), drawOpacity(), layerRenderer->sharedGeometryQuad(),
    163161                                    program->vertexShader().matrixLocation(),
    164162                                    program->fragmentShader().alphaLocation(),
Note: See TracChangeset for help on using the changeset viewer.