Changeset 105314 in webkit


Ignore:
Timestamp:
Jan 18, 2012 1:41:51 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Enable tracking opaque region in Skia graphics context, return it from LayerTextureUpdater
https://bugs.webkit.org/show_bug.cgi?id=76211

Patch by Dana Jansens <danakj@chromium.org> on 2012-01-18
Reviewed by James Robinson.

Source/WebCore:

New unit tests in LayerTextureUpdaterTest.cpp

  • platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp:

(WebCore::BitmapCanvasLayerTextureUpdater::prepareToUpdate):

  • platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h:
  • platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp:

(WebCore::BitmapSkPictureCanvasLayerTextureUpdater::prepareToUpdate):

  • platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h:
  • platform/graphics/chromium/ContentLayerChromium.cpp:

(WebCore::ContentLayerChromium::createTextureUpdater):

  • platform/graphics/chromium/LayerTextureUpdater.h:

(WebCore::LayerTextureUpdater::prepareToUpdate):

  • platform/graphics/chromium/PlatformCanvas.h:

(WebCore::PlatformCanvas::Painter::skiaContext):

  • platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp:

(WebCore::SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater):
(WebCore::SkPictureCanvasLayerTextureUpdater::prepareToUpdate):
(WebCore::SkPictureCanvasLayerTextureUpdater::setOpaque):

  • platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h:
  • platform/graphics/chromium/TiledLayerChromium.cpp:

(WebCore::TiledLayerChromium::prepareToUpdateTiles):

Source/WebKit/chromium:

  • WebKit.gypi:
  • tests/LayerTextureUpdaterTest.cpp: Added.

(WebCore::TestLayerPainterChromium::TestLayerPainterChromium):
(WebCore::TestLayerPainterChromium::paint):
(WebCore::PaintFillOpaque::operator()):
(WebCore::PaintFillAlpha::operator()):
(WebCore::TEST):

  • tests/TiledLayerChromiumTest.cpp:

(WTF::FakeLayerTextureUpdater::prepareToUpdate):

Location:
trunk/Source
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r105311 r105314  
     12012-01-18  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Enable tracking opaque region in Skia graphics context, return it from LayerTextureUpdater
     4        https://bugs.webkit.org/show_bug.cgi?id=76211
     5
     6        Reviewed by James Robinson.
     7
     8        New unit tests in LayerTextureUpdaterTest.cpp
     9
     10        * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp:
     11        (WebCore::BitmapCanvasLayerTextureUpdater::prepareToUpdate):
     12        * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h:
     13        * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp:
     14        (WebCore::BitmapSkPictureCanvasLayerTextureUpdater::prepareToUpdate):
     15        * platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h:
     16        * platform/graphics/chromium/ContentLayerChromium.cpp:
     17        (WebCore::ContentLayerChromium::createTextureUpdater):
     18        * platform/graphics/chromium/LayerTextureUpdater.h:
     19        (WebCore::LayerTextureUpdater::prepareToUpdate):
     20        * platform/graphics/chromium/PlatformCanvas.h:
     21        (WebCore::PlatformCanvas::Painter::skiaContext):
     22        * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp:
     23        (WebCore::SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater):
     24        (WebCore::SkPictureCanvasLayerTextureUpdater::prepareToUpdate):
     25        (WebCore::SkPictureCanvasLayerTextureUpdater::setOpaque):
     26        * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h:
     27        * platform/graphics/chromium/TiledLayerChromium.cpp:
     28        (WebCore::TiledLayerChromium::prepareToUpdateTiles):
     29
    1302012-01-18  Tim Dresser  <tdresser@chromium.org>
    231
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp

    r104742 r105314  
    3333#include "LayerPainterChromium.h"
    3434#include "PlatformColor.h"
     35#include "PlatformContextSkia.h"
    3536
    3637namespace WebCore {
     
    7879}
    7980
    80 void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale)
     81void BitmapCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect)
    8182{
    8283    m_texSubImage.setSubImageSize(tileSize);
     84
     85    bool layerIsOpaque = m_canvas.opaque();
    8386
    8487    m_canvas.resize(contentRect.size());
     
    8992        borderTexels ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText;
    9093    PlatformCanvas::Painter canvasPainter(&m_canvas, textOption);
     94    canvasPainter.skiaContext()->setTrackOpaqueRegion(!layerIsOpaque);
    9195    paintContents(*canvasPainter.context(), contentRect, contentsScale);
     96
     97    if (!layerIsOpaque)
     98        *resultingOpaqueRect = canvasPainter.skiaContext()->opaqueRegion().asRect();
    9299}
    93100
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h

    r104742 r105314  
    6161    virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*);
    6262    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
    63     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale);
     63    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect);
    6464    void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
    6565
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.cpp

    r102181 r105314  
    8787}
    8888
    89 void BitmapSkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale)
     89void BitmapSkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect)
    9090{
    9191    m_texSubImage.setSubImageSize(tileSize);
    92     SkPictureCanvasLayerTextureUpdater::prepareToUpdate(contentRect, tileSize, borderTexels, contentsScale);
     92    SkPictureCanvasLayerTextureUpdater::prepareToUpdate(contentRect, tileSize, borderTexels, contentsScale, resultingOpaqueRect);
    9393}
    9494
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapSkPictureCanvasLayerTextureUpdater.h

    r104522 r105314  
    6060    virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*);
    6161    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
    62     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale);
     62    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect);
    6363    void paintContentsRect(SkCanvas*, const IntRect& sourceRect);
    6464    void updateTextureRect(GraphicsContext3D*, GC3Denum format, const IntRect& destRect, const uint8_t* pixels);
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r104742 r105314  
    120120{
    121121#if USE(SKIA)
    122     if (host->settings().acceleratePainting) {
     122    if (host->settings().acceleratePainting)
    123123        m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate));
    124         return;
    125     }
    126 
    127     if (host->settings().perTilePainting) {
     124    else if (host->settings().perTilePainting)
    128125        m_textureUpdater = BitmapSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub);
    129         return;
    130     }
     126    else
    131127#endif // USE(SKIA)
    132 
    133     m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub);
     128        m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub);
    134129    m_textureUpdater->setOpaque(opaque());
    135130}
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h

    r104742 r105314  
    7272    // If the format is TexelFormatBGRA, vec4.x is blue and vec4.z is red.
    7373    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0;
    74     virtual void prepareToUpdate(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */, float /* contentsScale */) { }
     74    // The |resultingOpaqueRect| gives back a region of the layer that was painted opaque. If the layer is marked opaque in the updater,
     75    // then this region should be ignored in preference for the entire layer's area.
     76    virtual void prepareToUpdate(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */, float /* contentsScale */,
     77                                 IntRect* /* resultingOpaqueRect */) { }
    7578
     79    // Set true by the layer when it is known that the entire output is going to be opaque.
    7680    virtual void setOpaque(bool) { }
    7781};
  • trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.h

    r104742 r105314  
    8686
    8787        GraphicsContext* context() const { return m_context.get(); }
     88        PlatformContextSkia* skiaContext() const { return m_skiaContext.get(); }
    8889    private:
    8990        OwnPtr<GraphicsContext> m_context;
  • trunk/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp

    r101600 r105314  
    4242SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
    4343    : CanvasLayerTextureUpdater(painter)
     44    , m_layerIsOpaque(false)
    4445{
    4546}
     
    4950}
    5051
    51 void SkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& /* tileSize */, int /* borderTexels */, float contentsScale)
     52void SkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& /* tileSize */, int /* borderTexels */, float contentsScale, IntRect* resultingOpaqueRect)
    5253{
    5354    SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height());
    5455    PlatformContextSkia platformContext(canvas);
    5556    platformContext.setDeferred(true);
     57    platformContext.setTrackOpaqueRegion(!m_layerIsOpaque);
    5658    GraphicsContext graphicsContext(&platformContext);
    5759    paintContents(graphicsContext, contentRect, contentsScale);
    5860    m_picture.endRecording();
     61
     62    if (!m_layerIsOpaque)
     63        *resultingOpaqueRect = platformContext.opaqueRegion().asRect();
    5964}
    6065
     
    6570}
    6671
     72void SkPictureCanvasLayerTextureUpdater::setOpaque(bool opaque)
     73{
     74    m_layerIsOpaque = opaque;
     75}
     76
    6777} // namespace WebCore
    6878#endif // USE(SKIA)
  • trunk/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h

    r104522 r105314  
    5252    explicit SkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);
    5353
    54     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale);
     54    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels, float contentsScale, IntRect* resultingOpaqueRect);
    5555    void drawPicture(SkCanvas*);
    5656
     57    virtual void setOpaque(bool);
     58
    5759private:
    58     SkPicture m_picture; // Recording canvas.
     60    // Recording canvas.
     61    SkPicture m_picture;
     62    // True when it is known that all output pixels will be opaque.
     63    bool m_layerIsOpaque;
    5964};
    6065
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r104780 r105314  
    413413    // so we grab a local reference here to hold the updater alive until the paint completes.
    414414    RefPtr<LayerTextureUpdater> protector(textureUpdater());
    415     textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels(), contentsScale());
     415    IntRect opaqueRect; // FIXME: unused. remove this and store in the layer to pass to impl for draw culling
     416    textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels(), contentsScale(), &opaqueRect);
    416417    for (int j = top; j <= bottom; ++j) {
    417418        for (int i = left; i <= right; ++i) {
  • trunk/Source/WebKit/chromium/ChangeLog

    r105311 r105314  
     12012-01-18  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Enable tracking opaque region in Skia graphics context, return it from LayerTextureUpdater
     4        https://bugs.webkit.org/show_bug.cgi?id=76211
     5
     6        Reviewed by James Robinson.
     7
     8        * WebKit.gypi:
     9        * tests/LayerTextureUpdaterTest.cpp: Added.
     10        (WebCore::TestLayerPainterChromium::TestLayerPainterChromium):
     11        (WebCore::TestLayerPainterChromium::paint):
     12        (WebCore::PaintFillOpaque::operator()):
     13        (WebCore::PaintFillAlpha::operator()):
     14        (WebCore::TEST):
     15        * tests/TiledLayerChromiumTest.cpp:
     16        (WTF::FakeLayerTextureUpdater::prepareToUpdate):
     17
    1182012-01-18  Tim Dresser  <tdresser@chromium.org>
    219
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r105051 r105314  
    9494            'tests/KURLTest.cpp',
    9595            'tests/LayerChromiumTest.cpp',
     96            'tests/LayerTextureUpdaterTest.cpp',
    9697            'tests/PODArenaTest.cpp',
    9798            'tests/PODIntervalTreeTest.cpp',
  • trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

    r104780 r105314  
    7373    virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture(ManagedTexture::create(manager))); }
    7474    virtual SampledTexelFormat sampledTexelFormat(GC3Denum) { return SampledTexelFormatRGBA; }
    75     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float);
     75    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect*);
    7676
    7777private:
     
    150150}
    151151
    152 void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float)
     152void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect)
    153153{
    154154    m_prepareCount++;
     
    159159        m_layer = 0;
    160160    }
     161    *resultingOpaqueRect = IntRect();
    161162}
    162163
Note: See TracChangeset for help on using the changeset viewer.