Changeset 69747 in webkit


Ignore:
Timestamp:
Oct 14, 2010 12:18:18 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-10-14 Adrienne Walker <enne@google.com>

Reviewed by James Robinson.

Add a test for very large image layers. Skip this test for mac-wk2
because of the use of layerTreeAsText().
https://bugs.webkit.org/show_bug.cgi?id=47016

  • compositing/tiling/huge-layer-img.html: Added.
  • platform/chromium-gpu/compositing/tiling/huge-layer-img-expected.txt: Added.
  • platform/mac-wk2/Skipped:
  • platform/mac/compositing/tiling/huge-layer-img-expected.txt: Added.

2010-10-14 Adrienne Walker <enne@google.com>

Reviewed by James Robinson.

Add a short-term solution for large layers. Layers that are too
large to be contained in a single texture just upload the portion of
the layer that is within the content rect. A longer-term solution
is still tiling with proper memory management. Layers that have full
3D transforms (more than just translations) are still not drawn.
https://bugs.webkit.org/show_bug.cgi?id=47016

Test: compositing/tiling

  • platform/graphics/chromium/ContentLayerChromium.cpp: (WebCore::ContentLayerChromium::ContentLayerChromium): (WebCore::ContentLayerChromium::requiresClippedUpdateRect): (WebCore::ContentLayerChromium::calculateClippedUpdateRect): (WebCore::ContentLayerChromium::updateContents): (WebCore::ContentLayerChromium::updateTextureRect): (WebCore::ContentLayerChromium::draw):
  • platform/graphics/chromium/ContentLayerChromium.h:
  • platform/graphics/chromium/ImageLayerChromium.cpp: (WebCore::ImageLayerChromium::updateContents):
  • platform/graphics/chromium/LayerRendererChromium.cpp: (WebCore::LayerRendererChromium::drawLayers):
  • platform/graphics/chromium/LayerRendererChromium.h: (WebCore::LayerRendererChromium::rootLayerContentRect):
Location:
trunk
Files:
6 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69745 r69747  
     12010-10-14  Adrienne Walker  <enne@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        Add a test for very large image layers.  Skip this test for mac-wk2
     6        because of the use of layerTreeAsText().
     7        https://bugs.webkit.org/show_bug.cgi?id=47016
     8
     9        * compositing/tiling/huge-layer-img.html: Added.
     10        * platform/chromium-gpu/compositing/tiling/huge-layer-img-expected.txt: Added.
     11        * platform/mac-wk2/Skipped:
     12        * platform/mac/compositing/tiling/huge-layer-img-expected.txt: Added.
     13
    1142010-10-13  James Simonsen  <simonjam@chromium.org>
    215
  • trunk/LayoutTests/platform/mac-wk2/Skipped

    r69364 r69747  
    7979compositing/tiling/huge-layer-with-layer-children.html
    8080compositing/tiling/huge-layer.html
     81compositing/tiling/huge-layer-img.html
    8182compositing/video/video-poster.html
    8283
  • trunk/WebCore/ChangeLog

    r69746 r69747  
     12010-10-14  Adrienne Walker  <enne@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        Add a short-term solution for large layers.  Layers that are too
     6        large to be contained in a single texture just upload the portion of
     7        the layer that is within the content rect.  A longer-term solution
     8        is still tiling with proper memory management.  Layers that have full
     9        3D transforms (more than just translations) are still not drawn.
     10        https://bugs.webkit.org/show_bug.cgi?id=47016
     11
     12        Test: compositing/tiling
     13
     14        * platform/graphics/chromium/ContentLayerChromium.cpp:
     15        (WebCore::ContentLayerChromium::ContentLayerChromium):
     16        (WebCore::ContentLayerChromium::requiresClippedUpdateRect):
     17        (WebCore::ContentLayerChromium::calculateClippedUpdateRect):
     18        (WebCore::ContentLayerChromium::updateContents):
     19        (WebCore::ContentLayerChromium::updateTextureRect):
     20        (WebCore::ContentLayerChromium::draw):
     21        * platform/graphics/chromium/ContentLayerChromium.h:
     22        * platform/graphics/chromium/ImageLayerChromium.cpp:
     23        (WebCore::ImageLayerChromium::updateContents):
     24        * platform/graphics/chromium/LayerRendererChromium.cpp:
     25        (WebCore::LayerRendererChromium::drawLayers):
     26        * platform/graphics/chromium/LayerRendererChromium.h:
     27        (WebCore::LayerRendererChromium::rootLayerContentRect):
     28
    1292010-10-14  Chris Rogers  <crogers@google.com>
    230
  • trunk/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r69369 r69747  
    123123    : LayerChromium(owner)
    124124    , m_contentsTexture(0)
     125    , m_skipsDraw(false)
    125126{
    126127}
     
    141142}
    142143
     144bool ContentLayerChromium::requiresClippedUpdateRect() const
     145{
     146    return !layerRenderer()->checkTextureSize(m_bounds);
     147}
     148
     149void ContentLayerChromium::calculateClippedUpdateRect(IntRect& dirtyRect, IntRect& drawRect) const
     150{
     151    // For the given layer size and content rect, calculate:
     152    // 1) The minimal texture space rectangle to be uploaded, returned in dirtyRect.
     153    // 2) The content rect-relative rectangle to draw this texture in, returned in drawRect.
     154
     155    const IntRect contentRect = layerRenderer()->rootLayerContentRect();
     156    const TransformationMatrix& transform = drawTransform();
     157    // The layer's draw transform points to the center of the layer, relative to
     158    // the content rect.  layerPos is the distance from the top left of the
     159    // layer to the top left of the content rect.
     160    const IntPoint layerPos(m_bounds.width() / 2 - transform.m41(),
     161                            m_bounds.height() / 2 - transform.m42());
     162    // Transform the contentRect into the space of the layer.
     163    IntRect contentRectInLayerSpace(layerPos, contentRect.size());
     164
     165    // Clip the entire layer against the visible region in the content rect
     166    // and use that as the drawable texture, instead of the entire layer.
     167    dirtyRect = IntRect(IntPoint(0, 0), m_bounds);
     168    dirtyRect.intersect(contentRectInLayerSpace);
     169
     170    // The draw position is relative to the content rect.
     171    drawRect = IntRect(toPoint(dirtyRect.location() - layerPos), dirtyRect.size());
     172}
     173
    143174void ContentLayerChromium::updateContents()
    144175{
     
    151182    ASSERT(layerRenderer());
    152183
    153     // FIXME: Remove this test when tiled layers are implemented.
    154     m_skipsDraw = false;
    155     if (!layerRenderer()->checkTextureSize(m_bounds)) {
    156         m_skipsDraw = true;
    157         return;
    158     }
    159 
    160184    void* pixels = 0;
    161     IntRect dirtyRect(m_dirtyRect);
     185    IntRect dirtyRect;
     186    IntRect updateRect;
    162187    IntSize requiredTextureSize;
    163188    IntSize bitmapSize;
    164189
    165     requiredTextureSize = m_bounds;
    166     IntRect boundsRect(IntPoint(0, 0), m_bounds);
    167 
    168     // If the texture needs to be reallocated then we must redraw the entire
    169     // contents of the layer.
    170     if (requiredTextureSize != m_allocatedTextureSize)
    171         dirtyRect = boundsRect;
    172     else {
    173         // Clip the dirtyRect to the size of the layer to avoid drawing outside
    174         // the bounds of the backing texture.
    175         dirtyRect.intersect(boundsRect);
     190    // FIXME: Remove this test when tiled layers are implemented.
     191    if (requiresClippedUpdateRect()) {
     192        // A layer with 3D transforms could require an arbitrarily large number
     193        // of texels to be repainted, so ignore these layers until tiling is
     194        // implemented.
     195        if (!drawTransform().isIdentityOrTranslation()) {
     196            m_skipsDraw = true;
     197            return;
     198        }
     199
     200        calculateClippedUpdateRect(dirtyRect, m_largeLayerDrawRect);
     201        if (!layerRenderer()->checkTextureSize(m_largeLayerDrawRect.size())) {
     202            m_skipsDraw = true;
     203            return;
     204        }
     205        if (m_largeLayerDirtyRect == dirtyRect)
     206            return;
     207
     208        m_largeLayerDirtyRect = dirtyRect;
     209        requiredTextureSize = dirtyRect.size();
     210        updateRect = IntRect(IntPoint(0, 0), dirtyRect.size());
     211    } else {
     212        dirtyRect = IntRect(m_dirtyRect);
     213        IntRect boundsRect(IntPoint(0, 0), m_bounds);
     214        requiredTextureSize = m_bounds;
     215        // If the texture needs to be reallocated then we must redraw the entire
     216        // contents of the layer.
     217        if (requiredTextureSize != m_allocatedTextureSize)
     218            dirtyRect = boundsRect;
     219        else {
     220            // Clip the dirtyRect to the size of the layer to avoid drawing
     221            // outside the bounds of the backing texture.
     222            dirtyRect.intersect(boundsRect);
     223        }
     224        updateRect = dirtyRect;
    176225    }
    177226
     
    237286
    238287    if (pixels)
    239         updateTextureRect(pixels, bitmapSize, requiredTextureSize,  dirtyRect, textureId);
     288        updateTextureRect(pixels, bitmapSize, requiredTextureSize, updateRect, textureId);
    240289}
    241290
     
    288337
    289338    m_dirtyRect.setSize(FloatSize());
    290     m_contentsDirty = false;
     339    // Large layers always stay dirty, because they need to update when the content rect changes.
     340    m_contentsDirty = requiresClippedUpdateRect();
    291341}
    292342
     
    304354    layerRenderer()->useShader(sv->contentShaderProgram());
    305355    GLC(context, context->uniform1i(sv->shaderSamplerLocation(), 0));
    306     drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
    307                      bounds().width(), bounds().height(), drawOpacity(),
    308                      sv->shaderMatrixLocation(), sv->shaderAlphaLocation());
     356
     357    if (requiresClippedUpdateRect()) {
     358        float m43 = drawTransform().m43();
     359        TransformationMatrix transform;
     360        transform.translate3d(m_largeLayerDrawRect.center().x(), m_largeLayerDrawRect.center().y(), m43);
     361        drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
     362                         transform, m_largeLayerDrawRect.width(),
     363                         m_largeLayerDrawRect.height(), drawOpacity(),
     364                         sv->shaderMatrixLocation(), sv->shaderAlphaLocation());
     365    } else {
     366        drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
     367                         drawTransform(), m_bounds.width(), m_bounds.height(),
     368                         drawOpacity(), sv->shaderMatrixLocation(),
     369                         sv->shaderAlphaLocation());
     370    }
    309371}
    310372
  • trunk/WebCore/platform/graphics/chromium/ContentLayerChromium.h

    r69172 r69747  
    8585
    8686    virtual void cleanupResources();
     87    bool requiresClippedUpdateRect() const;
    8788
    8889    unsigned m_contentsTexture;
     
    9091    bool m_skipsDraw;
    9192
     93private:
     94    void calculateClippedUpdateRect(IntRect& dirtyRect, IntRect& drawRect) const;
     95    IntRect m_largeLayerDrawRect;
     96    IntRect m_largeLayerDirtyRect;
    9297};
    9398
  • trunk/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

    r69172 r69747  
    7676    ASSERT(layerRenderer());
    7777
     78    // FIXME: Remove this test when tiled layers are implemented.
     79    if (requiresClippedUpdateRect()) {
     80        // Use the base version of updateContents which draws a subset of the
     81        // image to a bitmap, as the pixel contents can't be uploaded directly.
     82        ContentLayerChromium::updateContents();
     83        return;
     84    }
     85
    7886    void* pixels = 0;
    7987    IntSize requiredTextureSize;
     
    137145#error "Need to implement for your platform."
    138146#endif
    139     // FIXME: Remove this test when tiled layers are implemented.
    140     m_skipsDraw = false;
    141     if (!layerRenderer()->checkTextureSize(requiredTextureSize)) {
    142         m_skipsDraw = true;
    143         return;
    144     }
    145147
    146148    unsigned textureId = m_contentsTexture;
  • trunk/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r69624 r69747  
    308308    GLC(m_context, m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
    309309
    310     // Set the rootVisibleRect --- used by subsequent drawLayers calls
     310    // Set the root visible/content rects --- used by subsequent drawLayers calls.
    311311    m_rootVisibleRect = visibleRect;
     312    m_rootContentRect = contentRect;
    312313
    313314    // Traverse the layer tree and update the layer transforms.
  • trunk/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r69624 r69747  
    109109
    110110    IntSize rootLayerTextureSize() const { return IntSize(m_rootLayerTextureWidth, m_rootLayerTextureHeight); }
     111    IntRect rootLayerContentRect() const { return m_rootContentRect; }
    111112    void getFramebufferPixels(void *pixels, const IntRect& rect);
    112113
     
    162163
    163164    IntRect m_rootVisibleRect;
     165    IntRect m_rootContentRect;
    164166
    165167    int m_maxTextureSize;
Note: See TracChangeset for help on using the changeset viewer.