Changeset 83915 in webkit


Ignore:
Timestamp:
Apr 14, 2011 5:16:51 PM (13 years ago)
Author:
enne@google.com
Message:

2011-04-14 Adrienne Walker <enne@google.com>

Reviewed by James Robinson.

[chromium] Tile content and image layers
https://bugs.webkit.org/show_bug.cgi?id=57113

Rebaseline a number of image tests where slight filtering differences
from using tiles caused test failures with exact pixel matching.
None of these results are perceptually different.

  • platform/chromium-gpu-linux/compositing/color-matching/image-color-matching-expected.checksum:
  • platform/chromium-gpu-linux/compositing/color-matching/image-color-matching-expected.png:
  • platform/chromium-gpu-linux/compositing/text-on-large-layer-expected.checksum:
  • platform/chromium-gpu-linux/compositing/text-on-large-layer-expected.png:
  • platform/chromium-gpu-linux/fast/canvas/canvas-text-alignment-expected.checksum:
  • platform/chromium-gpu-linux/fast/canvas/canvas-text-alignment-expected.png:
  • platform/chromium-gpu-linux/fast/canvas/canvas-text-baseline-expected.checksum:
  • platform/chromium-gpu-linux/fast/canvas/canvas-text-baseline-expected.png:
  • platform/chromium-gpu-mac/compositing/color-matching/image-color-matching-expected.checksum:
  • platform/chromium-gpu-mac/compositing/color-matching/image-color-matching-expected.png:
  • platform/chromium-gpu-mac/compositing/text-on-large-layer-expected.checksum:
  • platform/chromium-gpu-mac/compositing/text-on-large-layer-expected.png:
  • platform/chromium-gpu-win/compositing/color-matching/image-color-matching-expected.checksum:
  • platform/chromium-gpu-win/compositing/color-matching/image-color-matching-expected.png:
  • platform/chromium-gpu-win/compositing/text-on-large-layer-expected.checksum:
  • platform/chromium-gpu-win/compositing/text-on-large-layer-expected.png:
  • platform/chromium-gpu-win/fast/canvas/canvas-text-alignment-expected.checksum:
  • platform/chromium-gpu-win/fast/canvas/canvas-text-alignment-expected.png:
  • platform/chromium-gpu-win/fast/canvas/canvas-text-baseline-expected.checksum:
  • platform/chromium-gpu-win/fast/canvas/canvas-text-baseline-expected.png:
  • platform/chromium/test_expectations.txt:

2011-04-14 Adrienne Walker <enne@google.com>

Reviewed by James Robinson.

[chromium] Tile content and image layers
https://bugs.webkit.org/show_bug.cgi?id=57113

Layers tile by default if any dimension is larger than 512. Smaller
layers are contained within a single texture but still use the tiler
infrastructure so that there's only one code path.

Remove large layer support from content layers. Content layers no
longer own a platform canvas--they own a tiler. Refactor tiler to
allow for better separation of update/upload/paint. Add rect
parameter to update and draw functions on layers for the layer-space
rect of interest. This is necessary to know which tiles need to be
drawn.

  • platform/graphics/chromium/ContentLayerChromium.cpp: (WebCore::ContentLayerChromium::ContentLayerChromium): (WebCore::ContentLayerChromium::~ContentLayerChromium): (WebCore::ContentLayerPainter::ContentLayerPainter): (WebCore::ContentLayerPainter::paint): (WebCore::ContentLayerChromium::paintContentsIfDirty): (WebCore::ContentLayerChromium::setLayerRenderer): (WebCore::ContentLayerChromium::tilingTransform): (WebCore::ContentLayerChromium::visibleLayerRect): (WebCore::ContentLayerChromium::layerBounds): (WebCore::ContentLayerChromium::updateLayerSize): (WebCore::ContentLayerChromium::draw): (WebCore::ContentLayerChromium::createTilerIfNeeded): (WebCore::ContentLayerChromium::updateCompositorResources): (WebCore::ContentLayerChromium::setTilingOption): (WebCore::ContentLayerChromium::bindContentsTexture): (WebCore::ContentLayerChromium::unreserveContentsTexture): (WebCore::ContentLayerChromium::setIsMask): (WebCore::ContentLayerChromium::dumpLayerProperties):
  • platform/graphics/chromium/ContentLayerChromium.h: (WebCore::ContentLayerChromium::drawsContent):
  • platform/graphics/chromium/GraphicsLayerChromium.cpp: (WebCore::GraphicsLayerChromium::setMaskLayer):
  • platform/graphics/chromium/ImageLayerChromium.cpp: (WebCore::ImageLayerChromium::paintContentsIfDirty): (WebCore::ImageLayerChromium::updateCompositorResources): (WebCore::ImageLayerChromium::layerBounds): (WebCore::ImageLayerChromium::tilingTransform):
  • platform/graphics/chromium/ImageLayerChromium.h:
  • platform/graphics/chromium/LayerChromium.h: (WebCore::LayerChromium::invalidateRect): (WebCore::LayerChromium::paintContentsIfDirty): (WebCore::LayerChromium::setIsMask): (WebCore::LayerChromium::draw):
  • platform/graphics/chromium/LayerRendererChromium.cpp: (WebCore::LayerRendererChromium::drawRootLayer): (WebCore::LayerRendererChromium::drawLayers): (WebCore::LayerRendererChromium::paintContentsRecursive): (WebCore::LayerRendererChromium::copyOffscreenTextureToDisplay): (WebCore::LayerRendererChromium::drawLayer): (WebCore::LayerRendererChromium::initializeSharedObjects): (WebCore::LayerRendererChromium::cleanupSharedObjects):
  • platform/graphics/chromium/LayerRendererChromium.h:
  • platform/graphics/chromium/LayerTilerChromium.cpp: (WebCore::LayerTilerChromium::setTileSize): (WebCore::LayerTilerChromium::getSingleTexture): (WebCore::LayerTilerChromium::invalidateRect): (WebCore::LayerTilerChromium::update): (WebCore::LayerTilerChromium::uploadCanvas): (WebCore::LayerTilerChromium::updateFromPixels): (WebCore::LayerTilerChromium::draw): (WebCore::LayerTilerChromium::unreserveTextures):
  • platform/graphics/chromium/LayerTilerChromium.h: (WebCore::LayerTilerChromium::setLayerRenderer): (WebCore::LayerTilerChromium::skipsDraw):
  • platform/graphics/chromium/PlatformCanvas.cpp: (WebCore::PlatformCanvas::AutoLocker::AutoLocker): (WebCore::PlatformCanvas::Painter::Painter):
  • platform/graphics/chromium/PlatformCanvas.h:
  • platform/graphics/chromium/RenderSurfaceChromium.cpp: (WebCore::RenderSurfaceChromium::draw):
  • platform/graphics/chromium/RenderSurfaceChromium.h:
  • platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp: (WebCore::CCCanvasLayerImpl::draw):
  • platform/graphics/chromium/cc/CCCanvasLayerImpl.h:
  • platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: (WebCore::CCHeadsUpDisplay::draw):
  • platform/graphics/chromium/cc/CCLayerImpl.cpp: (WebCore::CCLayerImpl::draw):
  • platform/graphics/chromium/cc/CCLayerImpl.h:
  • platform/graphics/chromium/cc/CCPluginLayerImpl.cpp: (WebCore::CCPluginLayerImpl::draw):
  • platform/graphics/chromium/cc/CCPluginLayerImpl.h:
  • platform/graphics/chromium/cc/CCVideoLayerImpl.cpp: (WebCore::CCVideoLayerImpl::draw):
  • platform/graphics/chromium/cc/CCVideoLayerImpl.h:
Location:
trunk
Files:
46 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r83914 r83915  
     12011-04-14  Adrienne Walker  <enne@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        [chromium] Tile content and image layers
     6        https://bugs.webkit.org/show_bug.cgi?id=57113
     7
     8        Rebaseline a number of image tests where slight filtering differences
     9        from using tiles caused test failures with exact pixel matching.
     10        None of these results are perceptually different.
     11
     12        * platform/chromium-gpu-linux/compositing/color-matching/image-color-matching-expected.checksum:
     13        * platform/chromium-gpu-linux/compositing/color-matching/image-color-matching-expected.png:
     14        * platform/chromium-gpu-linux/compositing/text-on-large-layer-expected.checksum:
     15        * platform/chromium-gpu-linux/compositing/text-on-large-layer-expected.png:
     16        * platform/chromium-gpu-linux/fast/canvas/canvas-text-alignment-expected.checksum:
     17        * platform/chromium-gpu-linux/fast/canvas/canvas-text-alignment-expected.png:
     18        * platform/chromium-gpu-linux/fast/canvas/canvas-text-baseline-expected.checksum:
     19        * platform/chromium-gpu-linux/fast/canvas/canvas-text-baseline-expected.png:
     20        * platform/chromium-gpu-mac/compositing/color-matching/image-color-matching-expected.checksum:
     21        * platform/chromium-gpu-mac/compositing/color-matching/image-color-matching-expected.png:
     22        * platform/chromium-gpu-mac/compositing/text-on-large-layer-expected.checksum:
     23        * platform/chromium-gpu-mac/compositing/text-on-large-layer-expected.png:
     24        * platform/chromium-gpu-win/compositing/color-matching/image-color-matching-expected.checksum:
     25        * platform/chromium-gpu-win/compositing/color-matching/image-color-matching-expected.png:
     26        * platform/chromium-gpu-win/compositing/text-on-large-layer-expected.checksum:
     27        * platform/chromium-gpu-win/compositing/text-on-large-layer-expected.png:
     28        * platform/chromium-gpu-win/fast/canvas/canvas-text-alignment-expected.checksum:
     29        * platform/chromium-gpu-win/fast/canvas/canvas-text-alignment-expected.png:
     30        * platform/chromium-gpu-win/fast/canvas/canvas-text-baseline-expected.checksum:
     31        * platform/chromium-gpu-win/fast/canvas/canvas-text-baseline-expected.png:
     32        * platform/chromium/test_expectations.txt:
     33
    1342011-04-14  James Robinson  <jamesr@chromium.org>
    235
  • trunk/LayoutTests/platform/chromium-gpu-linux/compositing/color-matching/image-color-matching-expected.checksum

    r83511 r83915  
    1 23fa4ef4d069718cee8dd5120b6271df
     19af568c8084f3cf8d2a614f2324804cc
  • trunk/LayoutTests/platform/chromium-gpu-linux/compositing/text-on-large-layer-expected.checksum

    r83511 r83915  
    1 fe58e58bc0287ef9549722f0417b0ccb
     1c85d12f4ff9c8e9791b9a111cc3a137e
  • trunk/LayoutTests/platform/chromium-gpu-linux/fast/canvas/canvas-text-alignment-expected.checksum

    r79381 r83915  
    1 d7da5c3c67c61c23c2b24aef3572cd52
     1f10ff733898353c29ed21bd6928fe08b
  • trunk/LayoutTests/platform/chromium-gpu-linux/fast/canvas/canvas-text-baseline-expected.checksum

    r70582 r83915  
    1 f330ab78aeb1f176c8bec4bbd1ce86b3
     18ead55d188ea374c96a4437b9786cce2
  • trunk/LayoutTests/platform/chromium-gpu-mac/compositing/color-matching/image-color-matching-expected.checksum

    r83511 r83915  
    1 8acef2a5710b4f87f2594b4a2ac8af75
     1a563248737d41f703e528054e0155279
  • trunk/LayoutTests/platform/chromium-gpu-mac/compositing/text-on-large-layer-expected.checksum

    r83511 r83915  
    1 24766181b479126107feb69ad08af8e8
     10f39e5e414500af54dad1f8f99e168a3
  • trunk/LayoutTests/platform/chromium-gpu-win/compositing/color-matching/image-color-matching-expected.checksum

    r83511 r83915  
    1 e8c3f969c3ebff9dfc70ee48dbb40d0f
     1143d90ea374a99cc25c0dff7899bf0f1
  • trunk/LayoutTests/platform/chromium-gpu-win/compositing/text-on-large-layer-expected.checksum

    r83511 r83915  
    1 3f83e7406a50d10563080040019f7fe0
     100ec487b9eec64bd3957def11c93f46d
  • trunk/LayoutTests/platform/chromium-gpu-win/fast/canvas/canvas-text-alignment-expected.checksum

    r79381 r83915  
    1 c5f11c49a9d8d97e566c520a06d1a5f5
     1fee76e0b4356bb41329d9964150322e8
  • trunk/LayoutTests/platform/chromium-gpu-win/fast/canvas/canvas-text-baseline-expected.checksum

    r70582 r83915  
    1 d4f4655eef150d04c51f34a91ee034a5
     13cac80d01fdebff0e8d6351d392f5476
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r83914 r83915  
    30903090
    30913091// Seems to blend scrollbars very slightly differently in debug vs. release.
    3092 BUGWK58587 DEBUG GPU LINUX : compositing/geometry/horizontal-scroll-composited.html = IMAGE
     3092// Commented out because BUGWK57113 supersedes it below.
     3093//BUGWK58587 DEBUG GPU LINUX : compositing/geometry/horizontal-scroll-composited.html = IMAGE
    30933094BUGWK58587 DEBUG GPU LINUX : fast/canvas/image-object-in-canvas.html = IMAGE
    30943095BUGWK58587 DEBUG GPU LINUX : media/video-zoom.html = IMAGE
     
    34863487
    34873488BUGCROGERS WIN LINUX : fast/text/zero-font-size.html = IMAGE+TEXT
     3489
     3490// Temporarily marked failing for rebaselining.
     3491BUGWK57113 GPU : compositing/geometry/fixed-position.html = FAIL
     3492BUGWK57113 GPU : compositing/geometry/horizontal-scroll-composited.html = FAIL
     3493BUGWK57113 GPU : compositing/geometry/vertical-scroll-composited.html = FAIL
     3494BUGWK57113 GPU : compositing/tiling/huge-layer-img.html = FAIL
     3495BUGWK57113 GPU : compositing/overflow/fixed-position-ancestor-clip.html = FAIL
     3496BUGWK57113 GPU : compositing/overflow/overflow-scroll.html = FAIL
     3497BUGWK57113 GPU : platform/chromium/compositing/huge-layer-rotated.html = FAIL
  • trunk/Source/WebCore/ChangeLog

    r83914 r83915  
     12011-04-14  Adrienne Walker  <enne@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        [chromium] Tile content and image layers
     6        https://bugs.webkit.org/show_bug.cgi?id=57113
     7
     8        Layers tile by default if any dimension is larger than 512.  Smaller
     9        layers are contained within a single texture but still use the tiler
     10        infrastructure so that there's only one code path.
     11
     12        Remove large layer support from content layers.  Content layers no
     13        longer own a platform canvas--they own a tiler.  Refactor tiler to
     14        allow for better separation of update/upload/paint.  Add rect
     15        parameter to update and draw functions on layers for the layer-space
     16        rect of interest.  This is necessary to know which tiles need to be
     17        drawn.
     18
     19        * platform/graphics/chromium/ContentLayerChromium.cpp:
     20        (WebCore::ContentLayerChromium::ContentLayerChromium):
     21        (WebCore::ContentLayerChromium::~ContentLayerChromium):
     22        (WebCore::ContentLayerPainter::ContentLayerPainter):
     23        (WebCore::ContentLayerPainter::paint):
     24        (WebCore::ContentLayerChromium::paintContentsIfDirty):
     25        (WebCore::ContentLayerChromium::setLayerRenderer):
     26        (WebCore::ContentLayerChromium::tilingTransform):
     27        (WebCore::ContentLayerChromium::visibleLayerRect):
     28        (WebCore::ContentLayerChromium::layerBounds):
     29        (WebCore::ContentLayerChromium::updateLayerSize):
     30        (WebCore::ContentLayerChromium::draw):
     31        (WebCore::ContentLayerChromium::createTilerIfNeeded):
     32        (WebCore::ContentLayerChromium::updateCompositorResources):
     33        (WebCore::ContentLayerChromium::setTilingOption):
     34        (WebCore::ContentLayerChromium::bindContentsTexture):
     35        (WebCore::ContentLayerChromium::unreserveContentsTexture):
     36        (WebCore::ContentLayerChromium::setIsMask):
     37        (WebCore::ContentLayerChromium::dumpLayerProperties):
     38        * platform/graphics/chromium/ContentLayerChromium.h:
     39        (WebCore::ContentLayerChromium::drawsContent):
     40        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
     41        (WebCore::GraphicsLayerChromium::setMaskLayer):
     42        * platform/graphics/chromium/ImageLayerChromium.cpp:
     43        (WebCore::ImageLayerChromium::paintContentsIfDirty):
     44        (WebCore::ImageLayerChromium::updateCompositorResources):
     45        (WebCore::ImageLayerChromium::layerBounds):
     46        (WebCore::ImageLayerChromium::tilingTransform):
     47        * platform/graphics/chromium/ImageLayerChromium.h:
     48        * platform/graphics/chromium/LayerChromium.h:
     49        (WebCore::LayerChromium::invalidateRect):
     50        (WebCore::LayerChromium::paintContentsIfDirty):
     51        (WebCore::LayerChromium::setIsMask):
     52        (WebCore::LayerChromium::draw):
     53        * platform/graphics/chromium/LayerRendererChromium.cpp:
     54        (WebCore::LayerRendererChromium::drawRootLayer):
     55        (WebCore::LayerRendererChromium::drawLayers):
     56        (WebCore::LayerRendererChromium::paintContentsRecursive):
     57        (WebCore::LayerRendererChromium::copyOffscreenTextureToDisplay):
     58        (WebCore::LayerRendererChromium::drawLayer):
     59        (WebCore::LayerRendererChromium::initializeSharedObjects):
     60        (WebCore::LayerRendererChromium::cleanupSharedObjects):
     61        * platform/graphics/chromium/LayerRendererChromium.h:
     62        * platform/graphics/chromium/LayerTilerChromium.cpp:
     63        (WebCore::LayerTilerChromium::setTileSize):
     64        (WebCore::LayerTilerChromium::getSingleTexture):
     65        (WebCore::LayerTilerChromium::invalidateRect):
     66        (WebCore::LayerTilerChromium::update):
     67        (WebCore::LayerTilerChromium::uploadCanvas):
     68        (WebCore::LayerTilerChromium::updateFromPixels):
     69        (WebCore::LayerTilerChromium::draw):
     70        (WebCore::LayerTilerChromium::unreserveTextures):
     71        * platform/graphics/chromium/LayerTilerChromium.h:
     72        (WebCore::LayerTilerChromium::setLayerRenderer):
     73        (WebCore::LayerTilerChromium::skipsDraw):
     74        * platform/graphics/chromium/PlatformCanvas.cpp:
     75        (WebCore::PlatformCanvas::AutoLocker::AutoLocker):
     76        (WebCore::PlatformCanvas::Painter::Painter):
     77        * platform/graphics/chromium/PlatformCanvas.h:
     78        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
     79        (WebCore::RenderSurfaceChromium::draw):
     80        * platform/graphics/chromium/RenderSurfaceChromium.h:
     81        * platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp:
     82        (WebCore::CCCanvasLayerImpl::draw):
     83        * platform/graphics/chromium/cc/CCCanvasLayerImpl.h:
     84        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
     85        (WebCore::CCHeadsUpDisplay::draw):
     86        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
     87        (WebCore::CCLayerImpl::draw):
     88        * platform/graphics/chromium/cc/CCLayerImpl.h:
     89        * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
     90        (WebCore::CCPluginLayerImpl::draw):
     91        * platform/graphics/chromium/cc/CCPluginLayerImpl.h:
     92        * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
     93        (WebCore::CCVideoLayerImpl::draw):
     94        * platform/graphics/chromium/cc/CCVideoLayerImpl.h:
     95
    1962011-04-14  James Robinson  <jamesr@chromium.org>
    297
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r83820 r83915  
    4242#include "TextStream.h"
    4343
     44// Maximum size the width or height of this layer can be before enabling tiling
     45// when m_tilingOption == AutoTile.
     46static int maxUntiledSize = 512;
     47// When tiling is enabled, use tiles of this dimension squared.
     48static int defaultTileSize = 256;
     49
     50using namespace std;
     51
    4452namespace WebCore {
    4553
     
    5159ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner)
    5260    : LayerChromium(owner)
    53     , m_contentsTexture(0)
    54     , m_skipsDraw(false)
     61    , m_tilingOption(ContentLayerChromium::AutoTile)
    5562{
    5663}
     
    5865ContentLayerChromium::~ContentLayerChromium()
    5966{
    60     cleanupResources();
    61 }
    62 
    63 void ContentLayerChromium::cleanupResources()
    64 {
     67    m_tiler.clear();
    6568    LayerChromium::cleanupResources();
    66     m_contentsTexture.clear();
    67 }
    68 
    69 bool ContentLayerChromium::requiresClippedUpdateRect()
    70 {
    71     // To avoid allocating excessively large textures, switch into "large layer mode" if
    72     // one of the layer's dimensions is larger than 2000 pixels or the size of
    73     // surface it's rendering into. This is a temporary measure until layer tiling is implemented.
    74     static const int maxLayerSize = 2000;
    75     return (bounds().width() > max(maxLayerSize, ccLayerImpl()->targetRenderSurface()->contentRect().width())
    76             || bounds().height() > max(maxLayerSize, ccLayerImpl()->targetRenderSurface()->contentRect().height())
    77             || !layerRenderer()->checkTextureSize(bounds()));
    78 }
    79 
    80 void ContentLayerChromium::paintContentsIfDirty()
     69}
     70
     71class ContentLayerPainter : public TilePaintInterface {
     72public:
     73    explicit ContentLayerPainter(GraphicsLayerChromium* owner)
     74        : m_owner(owner)
     75    {
     76    }
     77
     78    virtual void paint(GraphicsContext& context, const IntRect& contentRect)
     79    {
     80        context.save();
     81        context.clearRect(contentRect);
     82        context.clip(contentRect);
     83        m_owner->paintGraphicsLayerContents(context, contentRect);
     84        context.restore();
     85    }
     86private:
     87    GraphicsLayerChromium* m_owner;
     88};
     89
     90void ContentLayerChromium::paintContentsIfDirty(const IntRect& targetSurfaceRect)
    8191{
    8292    ASSERT(drawsContent());
    83 
    8493    ASSERT(layerRenderer());
    8594
    86     IntRect dirtyRect;
    87     IntRect boundsRect(IntPoint(0, 0), bounds());
    88     IntPoint paintingOffset;
    89 
    90     // FIXME: Remove this test when tiled layers are implemented.
    91     if (requiresClippedUpdateRect()) {
    92         // Calculate the region of this layer that is currently visible.
    93         const IntRect clipRect = ccLayerImpl()->targetRenderSurface()->contentRect();
    94 
    95         TransformationMatrix layerOriginTransform = ccLayerImpl()->drawTransform();
    96         layerOriginTransform.translate3d(-0.5 * bounds().width(), -0.5 * bounds().height(), 0);
    97 
    98         // We compute the visible portion of the layer by back-mapping the current RenderSurface
    99         // content area to the layer. To do that, we invert the drawing matrix of the layer
    100         // and project the content area rectangle to it. If the layer transform is not invertible
    101         // then we skip rendering the layer.
    102         if (!layerOriginTransform.isInvertible()) {
    103             m_skipsDraw = true;
    104             return;
    105         }
    106         TransformationMatrix targetToLayerMatrix = layerOriginTransform.inverse();
    107         FloatQuad mappedClipToLayer = targetToLayerMatrix.projectQuad(FloatRect(clipRect));
    108         IntRect visibleRectInLayerCoords = mappedClipToLayer.enclosingBoundingBox();
    109         visibleRectInLayerCoords.intersect(IntRect(0, 0, bounds().width(), bounds().height()));
    110 
    111         // If this is still too large to render, then skip the layer completely.
    112         if (!layerRenderer()->checkTextureSize(visibleRectInLayerCoords.size())) {
    113             m_skipsDraw = true;
    114             return;
    115         }
    116 
    117         // If we need to resize the upload buffer we have to repaint everything.
    118         if (m_canvas.size() != visibleRectInLayerCoords.size()) {
    119             resizeUploadBuffer(visibleRectInLayerCoords.size());
    120             m_dirtyRect = boundsRect;
    121         }
    122         // If the visible portion of the layer is different from the last upload.
    123         if (visibleRectInLayerCoords != m_visibleRectInLayerCoords)
    124             m_dirtyRect = boundsRect;
    125         m_visibleRectInLayerCoords = visibleRectInLayerCoords;
    126 
    127         // Calculate the portion of the dirty rectangle that is visible.  m_dirtyRect is in layer space.
    128         IntRect visibleDirtyRectInLayerSpace = enclosingIntRect(m_dirtyRect);
    129         visibleDirtyRectInLayerSpace.intersect(visibleRectInLayerCoords);
    130 
    131         // What the rectangles mean:
    132         //   dirtyRect: The region of this layer that will be updated.
    133         //   m_uploadUpdateRect: The region of the layer's texture that will be uploaded into.
    134         dirtyRect = visibleDirtyRectInLayerSpace;
    135         m_uploadUpdateRect = dirtyRect;
    136         IntSize visibleRectOffsetInLayerCoords(visibleRectInLayerCoords.x(), visibleRectInLayerCoords.y());
    137         paintingOffset = IntPoint(visibleRectOffsetInLayerCoords);
    138         m_uploadUpdateRect.move(-visibleRectOffsetInLayerCoords);
    139     } else {
    140         dirtyRect = IntRect(m_dirtyRect);
    141         // If the texture needs to be reallocated then we must redraw the entire
    142         // contents of the layer.
    143         if (m_canvas.size() != bounds()) {
    144             resizeUploadBuffer(bounds());
    145             dirtyRect = boundsRect;
    146         } else {
    147             // Clip the dirtyRect to the size of the layer to avoid drawing
    148             // outside the bounds of the backing texture.
    149             dirtyRect.intersect(boundsRect);
    150         }
    151         m_uploadUpdateRect = dirtyRect;
    152     }
    153 
    154     if (dirtyRect.isEmpty())
     95    createTilerIfNeeded();
     96
     97    ContentLayerPainter painter(m_owner);
     98    updateLayerSize(layerBounds().size());
     99
     100    IntRect layerRect = visibleLayerRect(targetSurfaceRect);
     101    if (layerRect.isEmpty())
    155102        return;
    156 
    157     PlatformCanvas::Painter painter(&m_canvas);
    158     painter.context()->save();
    159     painter.context()->translate(-paintingOffset.x(), -paintingOffset.y());
    160     painter.context()->clearRect(dirtyRect);
    161     painter.context()->clip(dirtyRect);
    162 
    163     m_owner->paintGraphicsLayerContents(*painter.context(), dirtyRect);
    164     painter.context()->restore();
    165 }
    166 
    167 void ContentLayerChromium::resizeUploadBuffer(const IntSize& size)
    168 {
    169     m_canvas.resize(size);
    170 }
    171 
    172 void ContentLayerChromium::updateTextureIfNeeded()
    173 {
    174     PlatformCanvas::AutoLocker locker(&m_canvas);
    175     updateTexture(locker.pixels(), m_canvas.size());
    176 }
    177 
    178 void ContentLayerChromium::updateTexture(const uint8_t* pixels, const IntSize& size)
    179 {
    180     if (!pixels)
     103    m_tiler->invalidateRect(enclosingIntRect(m_dirtyRect));
     104    m_tiler->update(painter, layerRect);
     105    m_dirtyRect = FloatRect();
     106}
     107
     108void ContentLayerChromium::setLayerRenderer(LayerRendererChromium* layerRenderer)
     109{
     110    LayerChromium::setLayerRenderer(layerRenderer);
     111    createTilerIfNeeded();
     112    m_tiler->setLayerRenderer(layerRenderer);
     113}
     114
     115TransformationMatrix ContentLayerChromium::tilingTransform()
     116{
     117    TransformationMatrix transform = ccLayerImpl()->drawTransform();
     118    // Tiler draws from the upper left corner. The draw transform
     119    // specifies the middle of the layer.
     120    IntSize size = bounds();
     121    transform.translate(-size.width() / 2.0, -size.height() / 2.0);
     122
     123    return transform;
     124}
     125
     126IntRect ContentLayerChromium::visibleLayerRect(const IntRect& targetSurfaceRect)
     127{
     128    if (targetSurfaceRect.isEmpty())
     129        return targetSurfaceRect;
     130
     131    const IntRect layerBoundRect = layerBounds();
     132    const TransformationMatrix transform = tilingTransform();
     133
     134    // Is this layer fully contained within the target surface?
     135    IntRect layerInSurfaceSpace = transform.mapRect(layerBoundRect);
     136    if (targetSurfaceRect.contains(layerInSurfaceSpace))
     137        return layerBoundRect;
     138
     139    // If the layer doesn't fill up the entire surface, then find the part of
     140    // the surface rect where the layer could be visible. This avoids trying to
     141    // project surface rect points that are behind the projection point.
     142    IntRect minimalSurfaceRect = targetSurfaceRect;
     143    minimalSurfaceRect.intersect(layerInSurfaceSpace);
     144
     145    // Project the corners of the target surface rect into the layer space.
     146    // This bounding rectangle may be larger than it needs to be (being
     147    // axis-aligned), but is a reasonable filter on the space to consider.
     148    // Non-invertible transforms will create an empty rect here.
     149    const TransformationMatrix surfaceToLayer = transform.inverse();
     150    IntRect layerRect = surfaceToLayer.projectQuad(FloatQuad(FloatRect(minimalSurfaceRect))).enclosingBoundingBox();
     151    layerRect.intersect(layerBoundRect);
     152    return layerRect;
     153}
     154
     155IntRect ContentLayerChromium::layerBounds() const
     156{
     157    return IntRect(IntPoint(0, 0), bounds());
     158}
     159
     160void ContentLayerChromium::updateLayerSize(const IntSize& layerSize)
     161{
     162    if (!m_tiler)
    181163        return;
    182164
    183     GraphicsContext3D* context = layerRendererContext();
    184     if (!m_contentsTexture)
    185         m_contentsTexture = LayerTexture::create(context, layerRenderer()->textureManager());
    186 
    187     // If we have to allocate a new texture we have to upload the full contents.
    188     if (!m_contentsTexture->isValid(size, GraphicsContext3D::RGBA))
    189         m_uploadUpdateRect = IntRect(IntPoint(0, 0), size);
    190 
    191     if (m_uploadUpdateRect.isEmpty())
     165    const IntSize tileSize(min(defaultTileSize, layerSize.width()), min(defaultTileSize, layerSize.height()));
     166    const bool autoTiled = layerSize.width() > maxUntiledSize || layerSize.height() > maxUntiledSize;
     167
     168    bool isTiled;
     169    if (m_tilingOption == AlwaysTile)
     170        isTiled = true;
     171    else if (m_tilingOption == NeverTile)
     172        isTiled = false;
     173    else
     174        isTiled = autoTiled;
     175
     176    m_tiler->setTileSize(isTiled ? tileSize : layerSize);
     177}
     178
     179void ContentLayerChromium::draw(const IntRect& targetSurfaceRect)
     180{
     181    const TransformationMatrix transform = tilingTransform();
     182    IntRect layerRect = visibleLayerRect(targetSurfaceRect);
     183    if (!layerRect.isEmpty())
     184        m_tiler->draw(layerRect, transform, ccLayerImpl()->drawOpacity());
     185    m_tiler->unreserveTextures();
     186}
     187
     188void ContentLayerChromium::createTilerIfNeeded()
     189{
     190    if (m_tiler)
    192191        return;
    193 
    194     if (!m_contentsTexture->reserve(size, GraphicsContext3D::RGBA)) {
    195         m_skipsDraw = true;
    196         return;
    197     }
    198 
    199     IntRect srcRect = IntRect(IntPoint(0, 0), size);
    200     if (requiresClippedUpdateRect())
    201         srcRect = m_visibleRectInLayerCoords;
    202 
    203     const size_t destStride = m_uploadUpdateRect.width() * 4;
    204     const size_t srcStride = srcRect.width() * 4;
    205 
    206     const uint8_t* uploadPixels = pixels + srcStride * m_uploadUpdateRect.y();
    207     Vector<uint8_t> uploadBuffer;
    208     if (srcStride != destStride || m_uploadUpdateRect.x()) {
    209         uploadBuffer.resize(m_uploadUpdateRect.height() * destStride);
    210         for (int row = 0; row < m_uploadUpdateRect.height(); ++row) {
    211             size_t srcOffset = (m_uploadUpdateRect.y() + row) * srcStride + m_uploadUpdateRect.x() * 4;
    212             ASSERT(srcOffset + destStride <= static_cast<size_t>(size.width() * size.height() * 4));
    213             size_t destOffset = row * destStride;
    214             ASSERT(destOffset  + destStride <= uploadBuffer.size());
    215             memcpy(uploadBuffer.data() + destOffset, pixels + srcOffset, destStride);
    216         }
    217         uploadPixels = uploadBuffer.data();
    218     }
    219 
    220     m_contentsTexture->bindTexture();
    221     GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0,
    222                                         m_uploadUpdateRect.x(), m_uploadUpdateRect.y(), m_uploadUpdateRect.width(), m_uploadUpdateRect.height(),
    223                                         GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE,
    224                                         uploadPixels));
    225 
    226     m_uploadUpdateRect = IntRect();
    227     m_dirtyRect.setSize(FloatSize());
    228     // Large layers always stay dirty, because they need to update when the content rect changes.
    229     m_contentsDirty = requiresClippedUpdateRect();
    230 }
    231 
    232 void ContentLayerChromium::draw()
    233 {
    234     if (m_skipsDraw)
    235         return;
    236 
    237     ASSERT(layerRenderer());
    238 
    239     const ContentLayerChromium::Program* program = layerRenderer()->contentLayerProgram();
    240     ASSERT(program && program->initialized());
    241     GraphicsContext3D* context = layerRendererContext();
    242     GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
    243     bindContentsTexture();
    244     layerRenderer()->useShader(program->program());
    245     GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
    246     GLC(context, context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
    247 
    248     if (requiresClippedUpdateRect()) {
    249         // Compute the offset between the layer's center point and the center of the visible portion
    250         // of the layer.
    251         FloatPoint visibleRectCenterOffset = FloatRect(m_visibleRectInLayerCoords).center();
    252         visibleRectCenterOffset.move(-0.5 * bounds().width(), -0.5 * bounds().height());
    253 
    254         TransformationMatrix transform = ccLayerImpl()->drawTransform();
    255         transform.translate(visibleRectCenterOffset.x(), visibleRectCenterOffset.y());
    256 
    257         drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
    258                          transform, m_visibleRectInLayerCoords.width(),
    259                          m_visibleRectInLayerCoords.height(), ccLayerImpl()->drawOpacity(),
    260                          program->vertexShader().matrixLocation(),
    261                          program->fragmentShader().alphaLocation());
    262     } else {
    263         drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
    264                          ccLayerImpl()->drawTransform(), bounds().width(), bounds().height(),
    265                          ccLayerImpl()->drawOpacity(), program->vertexShader().matrixLocation(),
    266                          program->fragmentShader().alphaLocation());
    267     }
    268     unreserveContentsTexture();
     192    m_tiler = LayerTilerChromium::create(layerRenderer(), IntSize(defaultTileSize, defaultTileSize), LayerTilerChromium::HasBorderTexels);
    269193}
    270194
    271195void ContentLayerChromium::updateCompositorResources()
    272196{
    273     updateTextureIfNeeded();
     197    m_tiler->uploadCanvas();
     198}
     199
     200void ContentLayerChromium::setTilingOption(TilingOption option)
     201{
     202    m_tilingOption = option;
     203    updateLayerSize(bounds());
     204}
     205
     206void ContentLayerChromium::bindContentsTexture()
     207{
     208    // This function is only valid for single texture layers, e.g. masks.
     209    ASSERT(m_tilingOption == NeverTile);
     210    ASSERT(m_tiler);
     211
     212    LayerTexture* texture = m_tiler->getSingleTexture();
     213    ASSERT(texture);
     214
     215    texture->bindTexture();
    274216}
    275217
    276218void ContentLayerChromium::unreserveContentsTexture()
    277219{
    278     if (!m_skipsDraw && m_contentsTexture)
    279         m_contentsTexture->unreserve();
    280 }
    281 
    282 void ContentLayerChromium::bindContentsTexture()
    283 {
    284     if (!m_skipsDraw && m_contentsTexture)
    285         m_contentsTexture->bindTexture();
     220    m_tiler->unreserveTextures();
     221}
     222
     223void ContentLayerChromium::setIsMask(bool isMask)
     224{
     225    setTilingOption(isMask ? NeverTile : AutoTile);
    286226}
    287227
     
    296236    LayerChromium::dumpLayerProperties(ts, indent);
    297237    writeIndent(ts, indent);
    298     ts << "skipsDraw: " << m_skipsDraw << "\n";
     238    ts << "skipsDraw: " << m_tiler->skipsDraw() << "\n";
    299239}
    300240
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h

    r83511 r83915  
    3636
    3737#include "LayerChromium.h"
    38 #include "PlatformCanvas.h"
     38#include "LayerTilerChromium.h"
    3939#include "TextureManager.h"
    4040
     
    4747    friend class LayerRendererChromium;
    4848public:
     49    enum TilingOption { AlwaysTile, NeverTile, AutoTile };
     50
    4951    static PassRefPtr<ContentLayerChromium> create(GraphicsLayerChromium* owner = 0);
    5052
    5153    virtual ~ContentLayerChromium();
    5254
    53     virtual void paintContentsIfDirty();
     55    virtual void paintContentsIfDirty(const IntRect& targetSurfaceRect);
    5456    virtual void updateCompositorResources();
     57    virtual void setIsMask(bool);
    5558    virtual void unreserveContentsTexture();
    5659    virtual void bindContentsTexture();
    5760
    58     virtual void draw();
    59     virtual bool drawsContent() const { return m_owner && m_owner->drawsContent(); }
    60 
    61     typedef ProgramBinding<VertexShaderPosTex, FragmentShaderTexAlpha> Program;
     61    virtual void draw(const IntRect& targetSurfaceRect);
     62    virtual bool drawsContent() const { return m_owner && m_owner->drawsContent() && (!m_tiler || !m_tiler->skipsDraw()); }
    6263
    6364protected:
    6465    explicit ContentLayerChromium(GraphicsLayerChromium* owner);
    6566
    66     virtual void cleanupResources();
    67     bool requiresClippedUpdateRect();
    68     void resizeUploadBuffer(const IntSize&);
    69 
    7067    virtual const char* layerTypeAsString() const { return "ContentLayer"; }
    7168    virtual void dumpLayerProperties(TextStream&, int indent) const;
    7269
    73     OwnPtr<LayerTexture> m_contentsTexture;
    74     bool m_skipsDraw;
     70    virtual void setLayerRenderer(LayerRendererChromium*);
    7571
    76     // The portion of the upload buffer that has a pending update, in the coordinates of the texture.
    77     IntRect m_uploadUpdateRect;
     72    virtual IntRect layerBounds() const;
    7873
    79     virtual void updateTextureIfNeeded();
    80     void updateTexture(const uint8_t* pixels, const IntSize&);
     74    virtual TransformationMatrix tilingTransform();
    8175
    82 private:
    83     PlatformCanvas m_canvas;
     76    // For a given render surface rect that this layer will be transformed and
     77    // drawn into, return the layer space rect that is visible in that surface.
     78    IntRect visibleLayerRect(const IntRect&);
    8479
    85     IntRect m_visibleRectInLayerCoords;
     80    void updateLayerSize(const IntSize&);
     81    void createTilerIfNeeded();
     82    void setTilingOption(TilingOption);
     83
     84    OwnPtr<LayerTilerChromium> m_tiler;
     85    TilingOption m_tilingOption;
    8686};
    8787
  • trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp

    r83511 r83915  
    284284
    285285    LayerChromium* maskLayerChromium = m_maskLayer ? m_maskLayer->platformLayer() : 0;
     286    if (maskLayerChromium)
     287        maskLayerChromium->setIsMask(true);
    286288    m_layer->setMaskLayer(maskLayerChromium);
    287289}
  • trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

    r83558 r83915  
    3535#include "ImageLayerChromium.h"
    3636
     37#include "cc/CCLayerImpl.h"
    3738#include "Image.h"
    3839#include "LayerRendererChromium.h"
     
    6869}
    6970
    70 void ImageLayerChromium::paintContentsIfDirty()
     71void ImageLayerChromium::paintContentsIfDirty(const IntRect&)
    7172{
    7273    ASSERT(layerRenderer());
    7374
    74     // FIXME: Remove this test when tiled layers are implemented.
    75     if (requiresClippedUpdateRect()) {
    76         // Use the base version of updateContents which draws a subset of the
    77         // image to a bitmap, as the pixel contents can't be uploaded directly.
    78         ContentLayerChromium::paintContentsIfDirty();
    79         return;
    80     }
    81 
    8275    if (!m_dirtyRect.isEmpty()) {
    8376        m_decodedImage.updateFromImage(m_contents->nativeImageForCurrentFrame());
    84         m_uploadUpdateRect = IntRect(IntPoint(0, 0), m_decodedImage.size());
    8577    }
    8678}
    8779
    88 void ImageLayerChromium::updateTextureIfNeeded()
     80void ImageLayerChromium::updateCompositorResources()
    8981{
    90     // FIXME: Remove this test when tiled layers are implemented.
    91     if (requiresClippedUpdateRect()) {
    92         ContentLayerChromium::updateTextureIfNeeded();
    93         return;
     82    updateLayerSize(m_decodedImage.size());
     83
     84    IntRect paintRect(IntPoint(0, 0), m_decodedImage.size());
     85    if (!m_dirtyRect.isEmpty()) {
     86        m_tiler->invalidateRect(paintRect);
     87        m_dirtyRect = IntRect();
    9488    }
    95     updateTexture(m_decodedImage.pixels(), m_decodedImage.size());
     89    m_tiler->updateFromPixels(paintRect, m_decodedImage.pixels());
     90}
     91
     92IntRect ImageLayerChromium::layerBounds() const
     93{
     94    return IntRect(IntPoint(0, 0), m_decodedImage.size());
     95}
     96
     97TransformationMatrix ImageLayerChromium::tilingTransform()
     98{
     99    // Tiler draws from the upper left corner. The draw transform
     100    // specifies the middle of the layer.
     101    TransformationMatrix transform = ccLayerImpl()->drawTransform();
     102    const IntRect sourceRect = layerBounds();
     103    const IntSize destSize = bounds();
     104
     105    transform.translate(-destSize.width() / 2.0, -destSize.height() / 2.0);
     106
     107    // Tiler also draws at the original content size, so rescale the original
     108    // image dimensions to the bounds that it is meant to be drawn at.
     109    float scaleX = destSize.width() / static_cast<float>(sourceRect.size().width());
     110    float scaleY = destSize.height() / static_cast<float>(sourceRect.size().height());
     111    transform.scale3d(scaleX, scaleY, 1.0f);
     112
     113    return transform;
    96114}
    97115
  • trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h

    r83558 r83915  
    5151    static PassRefPtr<ImageLayerChromium> create(GraphicsLayerChromium* owner = 0);
    5252
    53     virtual void paintContentsIfDirty();
     53    virtual void paintContentsIfDirty(const IntRect& targetSurfaceRect);
     54    virtual void updateCompositorResources();
    5455    virtual bool drawsContent() const { return m_contents; }
    5556
     
    5960    virtual const char* layerTypeAsString() const { return "ImageLayer"; }
    6061
     62    virtual TransformationMatrix tilingTransform();
     63    virtual IntRect layerBounds() const;
     64
    6165private:
    62     virtual void updateTextureIfNeeded();
    63 
    6466    ImageLayerChromium(GraphicsLayerChromium* owner);
    6567
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r83666 r83915  
    114114    void setNeedsDisplay(const FloatRect& dirtyRect);
    115115    void setNeedsDisplay();
     116    virtual void invalidateRect(const FloatRect& dirtyRect) {}
    116117    const FloatRect& dirtyRect() const { return m_dirtyRect; }
    117118    void resetNeedsDisplay();
     
    157158    // These methods typically need to be overwritten by derived classes.
    158159    virtual bool drawsContent() const { return false; }
     160    virtual void paintContentsIfDirty(const IntRect&) { }
    159161    virtual void paintContentsIfDirty() { }
    160162    virtual void updateCompositorResources() { }
     163    virtual void setIsMask(bool) {}
    161164    virtual void unreserveContentsTexture() { }
    162165    virtual void bindContentsTexture() { }
    163     virtual void draw() { }
     166    virtual void draw(const IntRect&) { }
    164167
    165168    // These exists just for debugging (via drawDebugBorder()).
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r83828 r83915  
    167167void LayerRendererChromium::drawRootLayer()
    168168{
    169     m_rootLayerContentTiler->draw(m_viewportVisibleRect);
     169    TransformationMatrix scroll;
     170    scroll.translate(-m_viewportVisibleRect.x(), -m_viewportVisibleRect.y());
     171
     172    m_rootLayerContentTiler->uploadCanvas();
     173    m_rootLayerContentTiler->draw(m_viewportVisibleRect, scroll, 1.0f);
     174    m_rootLayerContentTiler->unreserveTextures();
    170175}
    171176
     
    359364
    360365    GLC(m_context.get(), m_context->enable(GraphicsContext3D::BLEND));
     366    GLC(m_context.get(), m_context->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
    361367    GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST));
    362368
     
    765771        return;
    766772
     773    const IntRect targetSurfaceRect = layer->ccLayerImpl()->scissorRect();
     774
    767775    if (layer->drawsContent())
    768         layer->paintContentsIfDirty();
     776        layer->paintContentsIfDirty(targetSurfaceRect);
    769777    if (layer->maskLayer() && layer->maskLayer()->drawsContent())
    770         layer->maskLayer()->paintContentsIfDirty();
     778        layer->maskLayer()->paintContentsIfDirty(targetSurfaceRect);
    771779    if (layer->replicaLayer() && layer->replicaLayer()->drawsContent())
    772         layer->replicaLayer()->paintContentsIfDirty();
     780        layer->replicaLayer()->paintContentsIfDirty(targetSurfaceRect);
    773781    if (layer->replicaLayer() && layer->replicaLayer()->maskLayer() && layer->replicaLayer()->maskLayer()->drawsContent())
    774         layer->replicaLayer()->maskLayer()->paintContentsIfDirty();
     782        layer->replicaLayer()->maskLayer()->paintContentsIfDirty(targetSurfaceRect);
    775783}
    776784
     
    824832                                                            0.5 * m_defaultRenderSurface->m_contentRect.height(), 0);
    825833        m_defaultRenderSurface->m_drawOpacity = 1;
    826         m_defaultRenderSurface->draw();
     834        m_defaultRenderSurface->draw(m_defaultRenderSurface->m_contentRect);
    827835    }
    828836}
     
    865873{
    866874    if (layer->renderSurface() && layer->renderSurface() != targetSurface) {
    867         layer->renderSurface()->draw();
     875        layer->renderSurface()->draw(layer->getDrawRect());
    868876        return;
    869877    }
     
    905913    }
    906914
    907     layer->draw();
     915    layer->draw(layer->scissorRect());
    908916
    909917    // Draw the debug border if there is one.
     
    978986    m_sharedGeometry = adoptPtr(new GeometryBinding(m_context.get()));
    979987    m_borderProgram = adoptPtr(new LayerChromium::BorderProgram(m_context.get()));
    980     m_contentLayerProgram = adoptPtr(new ContentLayerChromium::Program(m_context.get()));
    981988    m_canvasLayerProgram = adoptPtr(new CCCanvasLayerImpl::Program(m_context.get()));
    982989    m_videoLayerRGBAProgram = adoptPtr(new CCVideoLayerImpl::RGBAProgram(m_context.get()));
     
    988995
    989996    if (!m_sharedGeometry->initialized() || !m_borderProgram->initialized()
    990         || !m_contentLayerProgram->initialized() || !m_canvasLayerProgram->initialized()
     997        || !m_canvasLayerProgram->initialized()
    991998        || !m_videoLayerRGBAProgram->initialized() || !m_videoLayerYUVProgram->initialized()
    992999        || !m_pluginLayerProgram->initialized() || !m_renderSurfaceProgram->initialized()
     
    10071014    m_sharedGeometry.clear();
    10081015    m_borderProgram.clear();
    1009     m_contentLayerProgram.clear();
    10101016    m_canvasLayerProgram.clear();
    10111017    m_videoLayerRGBAProgram.clear();
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r83828 r83915  
    111111    const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); }
    112112    const LayerChromium::BorderProgram* borderProgram() const { return m_borderProgram.get(); }
    113     const ContentLayerChromium::Program* contentLayerProgram() const { return m_contentLayerProgram.get(); }
    114113    const RenderSurfaceChromium::Program* renderSurfaceProgram() const { return m_renderSurfaceProgram.get(); }
    115114    const RenderSurfaceChromium::MaskProgram* renderSurfaceMaskProgram() const { return m_renderSurfaceMaskProgram.get(); }
     
    207206    OwnPtr<GeometryBinding> m_sharedGeometry;
    208207    OwnPtr<LayerChromium::BorderProgram> m_borderProgram;
    209     OwnPtr<ContentLayerChromium::Program> m_contentLayerProgram;
    210208    OwnPtr<RenderSurfaceChromium::Program> m_renderSurfaceProgram;
    211209    OwnPtr<RenderSurfaceChromium::MaskProgram> m_renderSurfaceMaskProgram;
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp

    r83511 r83915  
    4141using namespace std;
    4242
     43static int minTextureSize = 16;
     44
    4345namespace WebCore {
    4446
     
    7072}
    7173
    72 void LayerTilerChromium::setTileSize(const IntSize& size)
    73 {
     74void LayerTilerChromium::setTileSize(const IntSize& requestedSize)
     75{
     76    IntSize size(max(minTextureSize, requestedSize.width()), max(minTextureSize, requestedSize.height()));
     77
    7478    if (m_tileSize == size)
    7579        return;
     
    8084    m_tilePixels = adoptArrayPtr(new uint8_t[m_tileSize.width() * m_tileSize.height() * 4]);
    8185    m_tilingData.setMaxTextureSize(max(size.width(), size.height()));
     86}
     87
     88LayerTexture* LayerTilerChromium::getSingleTexture()
     89{
     90    Tile* tile = tileAt(0, 0);
     91    return tile ? tile->texture() : 0;
    8292}
    8393
     
    181191void LayerTilerChromium::invalidateRect(const IntRect& contentRect)
    182192{
    183     if (contentRect.isEmpty())
     193    if (contentRect.isEmpty() || m_skipsDraw)
    184194        return;
    185195
     
    237247            if (!tile->texture()->isValid(m_tileSize, GraphicsContext3D::RGBA))
    238248                tile->m_dirtyLayerRect = tileLayerRect(tile);
     249            else
     250                tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA);
    239251            dirtyLayerRect.unite(tile->m_dirtyLayerRect);
    240252        }
     
    244256        return;
    245257
    246     const IntRect paintRect = layerRectToContentRect(dirtyLayerRect);
    247 
    248     m_canvas.resize(paintRect.size());
    249     PlatformCanvas::Painter canvasPainter(&m_canvas);
    250     canvasPainter.context()->translate(-paintRect.x(), -paintRect.y());
     258    m_paintRect = layerRectToContentRect(dirtyLayerRect);
     259
     260    m_canvas.resize(m_paintRect.size());
     261
     262    // Assumption: if a tiler is using border texels, then it is because the
     263    // layer is likely to be filtered or transformed. Because of it might be
     264    // transformed, draw the text in grayscale instead of subpixel antialiasing.
     265    PlatformCanvas::Painter::TextOption textOption = m_tilingData.borderTexels() ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText;
     266    PlatformCanvas::Painter canvasPainter(&m_canvas, textOption);
     267    canvasPainter.context()->translate(-m_paintRect.x(), -m_paintRect.y());
    251268    {
    252269        TRACE_EVENT("LayerTilerChromium::update::paint", this, 0);
    253         painter.paint(*canvasPainter.context(), paintRect);
    254     }
    255 
     270        painter.paint(*canvasPainter.context(), m_paintRect);
     271    }
     272}
     273
     274void LayerTilerChromium::uploadCanvas()
     275{
    256276    PlatformCanvas::AutoLocker locker(&m_canvas);
    257277    {
    258278        TRACE_EVENT("LayerTilerChromium::updateFromPixels", this, 0);
    259         updateFromPixels(paintRect, locker.pixels());
     279        updateFromPixels(m_paintRect, locker.pixels());
    260280    }
    261281}
     
    264284{
    265285    // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update.
    266     if (!m_tiles.size())
     286    if (!m_tilingData.totalSizeX() || !m_tilingData.totalSizeY())
    267287        return;
    268288
     
    275295            Tile* tile = tileAt(i, j);
    276296            if (!tile)
    277                 CRASH();
    278             if (!tile->dirty())
     297                tile = createTile(i, j);
     298            else if (!tile->dirty())
    279299                continue;
    280300
     
    283303            const IntPoint anchor = sourceRect.location();
    284304            sourceRect.intersect(layerRectToContentRect(tile->m_dirtyLayerRect));
     305            // Paint rect not guaranteed to line up on tile boundaries, so
     306            // make sure that sourceRect doesn't extend outside of it.
     307            sourceRect.intersect(paintRect);
    285308            if (sourceRect.isEmpty())
    286309                continue;
    287310
    288             if (!tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA)) {
    289                 m_skipsDraw = true;
    290                 reset();
    291                 return;
     311            if (!tile->texture()->isReserved()) {
     312                if (!tile->texture()->reserve(m_tileSize, GraphicsContext3D::RGBA)) {
     313                    m_skipsDraw = true;
     314                    reset();
     315                    return;
     316                }
    292317            }
    293318
     
    325350
    326351            tile->texture()->bindTexture();
    327             GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST));
    328             GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::NEAREST));
     352
     353            const GC3Dint filter = m_tilingData.borderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
     354            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
     355            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
    329356
    330357            GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource));
     
    340367}
    341368
    342 void LayerTilerChromium::draw(const IntRect& contentRect)
     369void LayerTilerChromium::draw(const IntRect& contentRect, const TransformationMatrix& globalTransform, float opacity)
    343370{
    344371    if (m_skipsDraw || !m_tiles.size())
     
    355382        for (int i = left; i <= right; ++i) {
    356383            Tile* tile = tileAt(i, j);
    357             ASSERT(tile);
     384            if (!tile)
     385                continue;
    358386
    359387            tile->texture()->bindTexture();
    360388
    361             TransformationMatrix tileMatrix;
     389            TransformationMatrix tileMatrix(globalTransform);
    362390
    363391            // Don't use tileContentRect here, as that contains the full
     
    365393            IntRect tileRect = m_tilingData.tileBounds(m_tilingData.tileIndex(tile->i(), tile->j()));
    366394            tileRect.move(m_layerPosition.x(), m_layerPosition.y());
    367             tileMatrix.translate3d(tileRect.x() - contentRect.x() + tileRect.width() / 2.0, tileRect.y() - contentRect.y() + tileRect.height() / 2.0, 0);
     395            tileMatrix.translate3d(tileRect.x() + tileRect.width() / 2.0, tileRect.y() + tileRect.height() / 2.0, 0);
    368396
    369397            IntPoint texOffset = m_tilingData.textureOffset(tile->i(), tile->j());
     
    375403            float texScaleY = tileRect.height() / tileHeight;
    376404
    377             drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, tileRect.width(), tileRect.height(), 1, texTranslateX, texTranslateY, texScaleX, texScaleY, program);
    378 
    379             tile->texture()->unreserve();
     405            drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, tileRect.width(), tileRect.height(), opacity, texTranslateX, texTranslateY, texScaleX, texScaleY, program);
    380406        }
     407    }
     408}
     409
     410void LayerTilerChromium::unreserveTextures()
     411{
     412    for (TileMap::iterator iter = m_tiles.begin(); iter != m_tiles.end(); ++iter) {
     413        Tile* tile = iter->second.get();
     414        if (!tile)
     415            continue;
     416        tile->texture()->unreserve();
    381417    }
    382418}
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h

    r83511 r83915  
    5757    ~LayerTilerChromium();
    5858
     59    // Set invalidations to be potentially repainted during update().
    5960    void invalidateRect(const IntRect& contentRect);
    6061    void invalidateEntireLayer();
     62
     63    // Paint all invalidations and missing tiles needed to draw the contentRect
     64    // into the internal canvas.
    6165    void update(TilePaintInterface& painter, const IntRect& contentRect);
     66
     67    // Reserve and upload tile textures from the internal canvas.
     68    void uploadCanvas();
     69
     70    // Reserve and upload tile textures from an externally painted buffer.
    6271    void updateFromPixels(const IntRect& paintRect, const uint8_t* pixels);
    63     void draw(const IntRect& contentRect);
     72
     73    // Draw all tiles that intersect with the content rect.
     74    void draw(const IntRect& contentRect, const TransformationMatrix&, float opacity);
     75
     76    // If uploadCanvas/updateFromPixels is called, this must be called after
     77    // draw() to unreserve any textures that were reserved prior to uploading.
     78    void unreserveTextures();
    6479
    6580    // Set position of this tiled layer in content space.
     
    6782    // Change the tile size.  This may invalidate all the existing tiles.
    6883    void setTileSize(const IntSize& size);
     84    void setLayerRenderer(LayerRendererChromium* layerRenderer) { m_layerRenderer = layerRenderer; }
     85
     86    bool skipsDraw() const { return m_skipsDraw; }
    6987
    7088    typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderTexAlpha> Program;
     89
     90    // If this tiler has exactly one tile, return its texture. Otherwise, null.
     91    LayerTexture* getSingleTexture();
    7192
    7293private:
     
    141162    Vector<RefPtr<Tile> > m_unusedTiles;
    142163
     164    IntRect m_paintRect;
    143165    PlatformCanvas m_canvas;
    144166
  • trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.cpp

    r83666 r83915  
    7575        m_bitmap = 0;
    7676#elif PLATFORM(CG)
    77     m_pixels = &canvas->m_pixelData[0];
     77    if (canvas->m_pixelData)
     78        m_pixels = &canvas->m_pixelData[0];
    7879#endif
    7980}
     
    8788}
    8889
    89 PlatformCanvas::Painter::Painter(PlatformCanvas* canvas)
     90PlatformCanvas::Painter::Painter(PlatformCanvas* canvas, PlatformCanvas::Painter::TextOption option)
    9091{
    9192#if USE(SKIA)
    9293    m_skiaContext = adoptPtr(new PlatformContextSkia(canvas->m_skiaCanvas.get()));
    9394
    94     // This is needed to get text to show up correctly.
    95     m_skiaContext->setDrawingToImageBuffer(true);
     95    m_skiaContext->setDrawingToImageBuffer(option == GrayscaleText);
    9696
    9797    m_context = adoptPtr(new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(m_skiaContext.get())));
  • trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.h

    r83666 r83915  
    7979        WTF_MAKE_NONCOPYABLE(Painter);
    8080    public:
    81         explicit Painter(PlatformCanvas*);
     81        enum TextOption { GrayscaleText, SubpixelText };
     82
     83        Painter(PlatformCanvas*, TextOption);
    8284        ~Painter();
    8385
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp

    r83511 r83915  
    144144}
    145145
    146 void RenderSurfaceChromium::draw()
     146void RenderSurfaceChromium::draw(const IntRect&)
    147147{
    148148    if (m_skipsDraw || !m_contentsTexture)
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h

    r83511 r83915  
    5353    bool prepareContentsTexture();
    5454    void cleanupResources();
    55     void draw();
     55    void draw(const IntRect& targetSurfaceRect);
    5656
    5757    String name() const;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp

    r83511 r83915  
    4848}
    4949
    50 void CCCanvasLayerImpl::draw()
     50void CCCanvasLayerImpl::draw(const IntRect&)
    5151{
    5252    ASSERT(layerRenderer());
     
    7878
    7979#endif // USE(ACCELERATED_COMPOSITING)
    80 
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h

    r83511 r83915  
    4343    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexFlipAlpha> Program;
    4444
    45     virtual void draw();
     45    virtual void draw(const IntRect&);
    4646
    4747    virtual void dumpLayerProperties(TextStream&, int indent) const;
     
    5959
    6060#endif // CCCanvasLayerImpl_h
    61 
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp

    r83511 r83915  
    8080    canvas.resize(hudSize);
    8181    {
    82         PlatformCanvas::Painter painter(&canvas);
     82        PlatformCanvas::Painter painter(&canvas, PlatformCanvas::Painter::GrayscaleText);
    8383        drawHudContents(painter.context(), hudSize);
    8484    }
     
    9393
    9494    // Draw the HUD onto the default render surface.
    95     const ContentLayerChromium::Program* program = m_layerRenderer->contentLayerProgram();
     95    const LayerTilerChromium::Program* program = m_layerRenderer->tilerProgram();
    9696    ASSERT(program && program->initialized());
    9797    GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp

    r83551 r83915  
    130130}
    131131
    132 void CCLayerImpl::draw()
    133 {
    134     return m_owner->draw();
     132void CCLayerImpl::draw(const IntRect& targetSurfaceRect)
     133{
     134    return m_owner->draw(targetSurfaceRect);
    135135}
    136136
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h

    r83551 r83915  
    6161    CCLayerImpl* replicaLayer() const;
    6262
    63     virtual void draw();
     63    virtual void draw(const IntRect& contentRect);
    6464    virtual void updateCompositorResources();
    6565    void unreserveContentsTexture();
     
    207207
    208208#endif // CCLayerImpl_h
    209 
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp

    r83511 r83915  
    4747}
    4848
    49 void CCPluginLayerImpl::draw()
     49void CCPluginLayerImpl::draw(const IntRect&)
    5050{
    5151    ASSERT(layerRenderer());
     
    8282
    8383#endif // USE(ACCELERATED_COMPOSITING)
    84 
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h

    r83511 r83915  
    4343    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexFlipAlpha> Program;
    4444
    45     virtual void draw();
     45    virtual void draw(const IntRect&);
    4646
    4747    virtual void dumpLayerProperties(TextStream&, int indent) const;
     
    5858
    5959#endif // CCPluginLayerImpl_h
    60 
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp

    r83511 r83915  
    7676}
    7777
    78 void CCVideoLayerImpl::draw()
     78void CCVideoLayerImpl::draw(const IntRect&)
    7979{
    8080    if (m_skipsDraw)
     
    171171
    172172#endif // USE(ACCELERATED_COMPOSITING)
    173 
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h

    r83511 r83915  
    4848    typedef ProgramBinding<VertexShaderPosTexYUVStretch, FragmentShaderYUVVideo> YUVProgram;
    4949
    50     virtual void draw();
     50    virtual void draw(const IntRect&);
    5151
    5252    virtual void dumpLayerProperties(TextStream&, int indent) const;
     
    7373
    7474#endif // CCVideoLayerImpl_h
    75 
Note: See TracChangeset for help on using the changeset viewer.