Changeset 86805 in webkit


Ignore:
Timestamp:
May 18, 2011 4:53:12 PM (13 years ago)
Author:
enne@google.com
Message:

2011-05-18 Alok Priyadarshi <alokp@chromium.org> and Adrienne Walker <enne@google.com>

Reviewed by James Robinson.

[chromium] Split canvas from LayerTilerChromium
https://bugs.webkit.org/show_bug.cgi?id=60719

LayerTilerChromium now just does tiling. It delegates the task of painting and updating textures to LayerTextureUpdater.
Also abstracted LayerTextureSubImage to upload texture pixels.

  • WebCore.gypi:
  • platform/chromium/TraceEvent.h:
  • platform/graphics/chromium/ContentLayerChromium.cpp: (WebCore::ContentLayerChromium::create): (WebCore::ContentLayerChromium::ContentLayerChromium): (WebCore::ContentLayerChromium::~ContentLayerChromium): (WebCore::ContentLayerChromium::paintContentsIfDirty): (WebCore::ContentLayerChromium::cleanupResources): (WebCore::ContentLayerChromium::setLayerRenderer): (WebCore::ContentLayerChromium::createTextureUpdater): (WebCore::ContentLayerChromium::drawsContent): (WebCore::ContentLayerChromium::createTilerIfNeeded): (WebCore::ContentLayerChromium::updateCompositorResources):
  • platform/graphics/chromium/ContentLayerChromium.h:
  • platform/graphics/chromium/ImageLayerChromium.cpp: (WebCore::ImageLayerTextureUpdater::ImageLayerTextureUpdater): (WebCore::ImageLayerTextureUpdater::~ImageLayerTextureUpdater): (WebCore::ImageLayerTextureUpdater::orientation): (WebCore::ImageLayerTextureUpdater::prepareToUpdate): (WebCore::ImageLayerTextureUpdater::updateTextureRect): (WebCore::ImageLayerTextureUpdater::imageRect): (WebCore::ImageLayerChromium::paintContentsIfDirty): (WebCore::ImageLayerChromium::updateCompositorResources): (WebCore::ImageLayerChromium::createTextureUpdater):
  • platform/graphics/chromium/ImageLayerChromium.h:
  • platform/graphics/chromium/LayerPainterChromium.h: Added.
  • platform/graphics/chromium/LayerRendererChromium.cpp: (WebCore::LayerRendererChromium::create): (WebCore::LayerRendererChromium::LayerRendererChromium): (WebCore::LayerRendererChromium::updateRootLayerContents): (WebCore::LayerRendererChromium::drawRootLayer): (WebCore::LayerRendererChromium::updateAndDrawLayers): (WebCore::LayerRendererChromium::updateLayers):
  • platform/graphics/chromium/LayerRendererChromium.h:
  • platform/graphics/chromium/LayerTextureSubImage.cpp: Added. (WebCore::LayerTextureSubImage::LayerTextureSubImage): (WebCore::LayerTextureSubImage::~LayerTextureSubImage): (WebCore::LayerTextureSubImage::setSubImageSize): (WebCore::LayerTextureSubImage::upload): (WebCore::LayerTextureSubImage::uploadWithTexSubImage): (WebCore::LayerTextureSubImage::uploadWithMapTexSubImage):
  • platform/graphics/chromium/LayerTextureSubImage.h: Copied from Source/WebCore/platform/chromium/TraceEvent.h.
  • platform/graphics/chromium/LayerTextureUpdater.h: Copied from Source/WebCore/platform/chromium/TraceEvent.h. (WebCore::LayerTextureUpdater::LayerTextureUpdater): (WebCore::LayerTextureUpdater::~LayerTextureUpdater): (WebCore::LayerTextureUpdater::context):
  • platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp: Added. (WebCore::LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas): (WebCore::LayerTextureUpdaterCanvas::paintContents): (WebCore::LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap): (WebCore::LayerTextureUpdaterBitmap::prepareToUpdate): (WebCore::LayerTextureUpdaterBitmap::updateTextureRect):
  • platform/graphics/chromium/LayerTextureUpdaterCanvas.h: Added. (WebCore::LayerTextureUpdaterCanvas::~LayerTextureUpdaterCanvas): (WebCore::LayerTextureUpdaterCanvas::contentRect): (WebCore::LayerTextureUpdaterBitmap::~LayerTextureUpdaterBitmap): (WebCore::LayerTextureUpdaterBitmap::orientation):
  • platform/graphics/chromium/LayerTilerChromium.cpp: (WebCore::LayerTilerChromium::create): (WebCore::LayerTilerChromium::LayerTilerChromium): (WebCore::LayerTilerChromium::setTileSize): (WebCore::LayerTilerChromium::prepareToUpdate): (WebCore::LayerTilerChromium::updateRect): (WebCore::LayerTilerChromium::draw):
  • platform/graphics/chromium/LayerTilerChromium.h: (WebCore::LayerTilerChromium::Tile::Tile):
  • platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp: (WebCore::CCHeadsUpDisplay::draw):

2011-05-18 Alok Priyadarshi <alokp@chromium.org> and Adrienne Walker <enne@google.com>

Reviewed by James Robinson.

Split canvas from LayerTilerChromium
https://bugs.webkit.org/show_bug.cgi?id=60719

  • src/WebViewImpl.cpp:
Location:
trunk/Source
Files:
4 added
14 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86804 r86805  
     12011-05-18  Alok Priyadarshi  <alokp@chromium.org> and Adrienne Walker  <enne@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        [chromium] Split canvas from LayerTilerChromium
     6        https://bugs.webkit.org/show_bug.cgi?id=60719
     7
     8        LayerTilerChromium now just does tiling. It delegates the task of painting and updating textures to LayerTextureUpdater.
     9        Also abstracted LayerTextureSubImage to upload texture pixels.
     10
     11        * WebCore.gypi:
     12        * platform/chromium/TraceEvent.h:
     13        * platform/graphics/chromium/ContentLayerChromium.cpp:
     14        (WebCore::ContentLayerChromium::create):
     15        (WebCore::ContentLayerChromium::ContentLayerChromium):
     16        (WebCore::ContentLayerChromium::~ContentLayerChromium):
     17        (WebCore::ContentLayerChromium::paintContentsIfDirty):
     18        (WebCore::ContentLayerChromium::cleanupResources):
     19        (WebCore::ContentLayerChromium::setLayerRenderer):
     20        (WebCore::ContentLayerChromium::createTextureUpdater):
     21        (WebCore::ContentLayerChromium::drawsContent):
     22        (WebCore::ContentLayerChromium::createTilerIfNeeded):
     23        (WebCore::ContentLayerChromium::updateCompositorResources):
     24        * platform/graphics/chromium/ContentLayerChromium.h:
     25        * platform/graphics/chromium/ImageLayerChromium.cpp:
     26        (WebCore::ImageLayerTextureUpdater::ImageLayerTextureUpdater):
     27        (WebCore::ImageLayerTextureUpdater::~ImageLayerTextureUpdater):
     28        (WebCore::ImageLayerTextureUpdater::orientation):
     29        (WebCore::ImageLayerTextureUpdater::prepareToUpdate):
     30        (WebCore::ImageLayerTextureUpdater::updateTextureRect):
     31        (WebCore::ImageLayerTextureUpdater::imageRect):
     32        (WebCore::ImageLayerChromium::paintContentsIfDirty):
     33        (WebCore::ImageLayerChromium::updateCompositorResources):
     34        (WebCore::ImageLayerChromium::createTextureUpdater):
     35        * platform/graphics/chromium/ImageLayerChromium.h:
     36        * platform/graphics/chromium/LayerPainterChromium.h: Added.
     37        * platform/graphics/chromium/LayerRendererChromium.cpp:
     38        (WebCore::LayerRendererChromium::create):
     39        (WebCore::LayerRendererChromium::LayerRendererChromium):
     40        (WebCore::LayerRendererChromium::updateRootLayerContents):
     41        (WebCore::LayerRendererChromium::drawRootLayer):
     42        (WebCore::LayerRendererChromium::updateAndDrawLayers):
     43        (WebCore::LayerRendererChromium::updateLayers):
     44        * platform/graphics/chromium/LayerRendererChromium.h:
     45        * platform/graphics/chromium/LayerTextureSubImage.cpp: Added.
     46        (WebCore::LayerTextureSubImage::LayerTextureSubImage):
     47        (WebCore::LayerTextureSubImage::~LayerTextureSubImage):
     48        (WebCore::LayerTextureSubImage::setSubImageSize):
     49        (WebCore::LayerTextureSubImage::upload):
     50        (WebCore::LayerTextureSubImage::uploadWithTexSubImage):
     51        (WebCore::LayerTextureSubImage::uploadWithMapTexSubImage):
     52        * platform/graphics/chromium/LayerTextureSubImage.h: Copied from Source/WebCore/platform/chromium/TraceEvent.h.
     53        * platform/graphics/chromium/LayerTextureUpdater.h: Copied from Source/WebCore/platform/chromium/TraceEvent.h.
     54        (WebCore::LayerTextureUpdater::LayerTextureUpdater):
     55        (WebCore::LayerTextureUpdater::~LayerTextureUpdater):
     56        (WebCore::LayerTextureUpdater::context):
     57        * platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp: Added.
     58        (WebCore::LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas):
     59        (WebCore::LayerTextureUpdaterCanvas::paintContents):
     60        (WebCore::LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap):
     61        (WebCore::LayerTextureUpdaterBitmap::prepareToUpdate):
     62        (WebCore::LayerTextureUpdaterBitmap::updateTextureRect):
     63        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h: Added.
     64        (WebCore::LayerTextureUpdaterCanvas::~LayerTextureUpdaterCanvas):
     65        (WebCore::LayerTextureUpdaterCanvas::contentRect):
     66        (WebCore::LayerTextureUpdaterBitmap::~LayerTextureUpdaterBitmap):
     67        (WebCore::LayerTextureUpdaterBitmap::orientation):
     68        * platform/graphics/chromium/LayerTilerChromium.cpp:
     69        (WebCore::LayerTilerChromium::create):
     70        (WebCore::LayerTilerChromium::LayerTilerChromium):
     71        (WebCore::LayerTilerChromium::setTileSize):
     72        (WebCore::LayerTilerChromium::prepareToUpdate):
     73        (WebCore::LayerTilerChromium::updateRect):
     74        (WebCore::LayerTilerChromium::draw):
     75        * platform/graphics/chromium/LayerTilerChromium.h:
     76        (WebCore::LayerTilerChromium::Tile::Tile):
     77        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
     78        (WebCore::CCHeadsUpDisplay::draw):
     79
    1802011-05-18  Mark Pilgrim  <pilgrim@chromium.org>
    281
  • trunk/Source/WebCore/WebCore.gypi

    r86765 r86805  
    40414041            'platform/graphics/chromium/LayerChromium.cpp',
    40424042            'platform/graphics/chromium/LayerChromium.h',
     4043            'platform/graphics/chromium/LayerPainterChromium.h',
    40434044            'platform/graphics/chromium/LayerRendererChromium.cpp',
    40444045            'platform/graphics/chromium/LayerRendererChromium.h',
    40454046            'platform/graphics/chromium/LayerTexture.cpp',
    40464047            'platform/graphics/chromium/LayerTexture.h',
     4048            'platform/graphics/chromium/LayerTextureSubImage.cpp',
     4049            'platform/graphics/chromium/LayerTextureSubImage.h',
     4050            'platform/graphics/chromium/LayerTextureUpdater.h',
     4051            'platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp',
     4052            'platform/graphics/chromium/LayerTextureUpdaterCanvas.h',
    40474053            'platform/graphics/chromium/LayerTilerChromium.cpp',
    40484054            'platform/graphics/chromium/LayerTilerChromium.h',
  • trunk/Source/WebCore/platform/chromium/TraceEvent.h

    r86640 r86805  
    2727
    2828#include "PlatformBridge.h"
     29#include <wtf/OwnArrayPtr.h>
    2930
    3031// Implementation detail: trace event macros create temporary variables
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r86640 r86805  
    3737#include "cc/CCLayerImpl.h"
    3838#include "GraphicsContext3D.h"
     39#include "LayerPainterChromium.h"
    3940#include "LayerRendererChromium.h"
    4041#include "LayerTexture.h"
     42#include "LayerTextureUpdaterCanvas.h"
     43#include "LayerTilerChromium.h"
    4144#include "RenderLayerBacking.h"
    4245#include "TextStream.h"
     
    5255namespace WebCore {
    5356
    54 PassRefPtr<ContentLayerChromium> ContentLayerChromium::create(GraphicsLayerChromium* owner)
    55 {
    56     return adoptRef(new ContentLayerChromium(owner));
    57 }
    58 
    59 ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner)
    60     : LayerChromium(owner)
    61     , m_tilingOption(ContentLayerChromium::AutoTile)
    62 {
    63 }
    64 
    65 ContentLayerChromium::~ContentLayerChromium()
    66 {
    67     m_tiler.clear();
    68     LayerChromium::cleanupResources();
    69 }
    70 
    71 class ContentLayerPainter : public TilePaintInterface {
     57class ContentLayerPainter : public LayerPainterChromium {
    7258public:
    7359    explicit ContentLayerPainter(GraphicsLayerChromium* owner)
     
    8672};
    8773
     74PassRefPtr<ContentLayerChromium> ContentLayerChromium::create(GraphicsLayerChromium* owner)
     75{
     76    return adoptRef(new ContentLayerChromium(owner));
     77}
     78
     79ContentLayerChromium::ContentLayerChromium(GraphicsLayerChromium* owner)
     80    : LayerChromium(owner)
     81    , m_tilingOption(ContentLayerChromium::AutoTile)
     82{
     83}
     84
     85ContentLayerChromium::~ContentLayerChromium()
     86{
     87    cleanupResources();
     88}
     89
    8890void ContentLayerChromium::paintContentsIfDirty(const IntRect& targetSurfaceRect)
    8991{
     
    9193    ASSERT(layerRenderer());
    9294
    93     createTilerIfNeeded();
    94 
    95     ContentLayerPainter painter(m_owner);
    9695    updateLayerSize(layerBounds().size());
    9796
     
    104103    m_tiler->invalidateRect(dirty);
    105104
    106     m_tiler->update(painter, layerRect);
     105    m_tiler->prepareToUpdate(layerRect);
    107106    m_dirtyRect = FloatRect();
     107}
     108
     109void ContentLayerChromium::cleanupResources()
     110{
     111    m_tiler.clear();
     112    LayerChromium::cleanupResources();
    108113}
    109114
     
    112117    LayerChromium::setLayerRenderer(layerRenderer);
    113118    createTilerIfNeeded();
    114     m_tiler->setLayerRenderer(layerRenderer);
     119}
     120
     121PassOwnPtr<LayerTextureUpdater> ContentLayerChromium::createTextureUpdater()
     122{
     123    OwnPtr<LayerPainterChromium> painter = adoptPtr(new ContentLayerPainter(m_owner));
     124    return adoptPtr(new LayerTextureUpdaterBitmap(layerRendererContext(), painter.release(), layerRenderer()->contextSupportsMapSub()));
    115125}
    116126
     
    187197}
    188198
     199bool ContentLayerChromium::drawsContent() const
     200{
     201    return m_owner && m_owner->drawsContent() && (!m_tiler || !m_tiler->skipsDraw());
     202}
     203
    189204void ContentLayerChromium::createTilerIfNeeded()
    190205{
    191206    if (m_tiler)
    192207        return;
    193     m_tiler = LayerTilerChromium::create(layerRenderer(), IntSize(defaultTileSize, defaultTileSize), LayerTilerChromium::HasBorderTexels);
     208
     209    m_tiler = LayerTilerChromium::create(
     210        layerRenderer(),
     211        createTextureUpdater(),
     212        IntSize(defaultTileSize, defaultTileSize),
     213        LayerTilerChromium::HasBorderTexels);
    194214}
    195215
    196216void ContentLayerChromium::updateCompositorResources()
    197217{
    198     m_tiler->uploadCanvas();
     218    m_tiler->updateRect();
    199219}
    200220
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h

    r86640 r86805  
    3636
    3737#include "LayerChromium.h"
    38 #include "LayerTilerChromium.h"
    39 #include "TextureManager.h"
    4038
    4139namespace WebCore {
    4240
    4341class LayerTexture;
     42class LayerTilerChromium;
     43class LayerTextureUpdater;
    4444
    4545// A Layer that requires a GraphicsContext to render its contents.
     
    5959
    6060    virtual void draw(const IntRect& targetSurfaceRect);
    61     virtual bool drawsContent() const { return m_owner && m_owner->drawsContent() && (!m_tiler || !m_tiler->skipsDraw()); }
     61    virtual bool drawsContent() const;
    6262
    6363protected:
     
    6767    virtual void dumpLayerProperties(TextStream&, int indent) const;
    6868
     69    virtual void cleanupResources();
    6970    virtual void setLayerRenderer(LayerRendererChromium*);
     71
     72    virtual PassOwnPtr<LayerTextureUpdater> createTextureUpdater();
    7073
    7174    virtual IntRect layerBounds() const;
  • trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

    r86640 r86805  
    3939#include "LayerRendererChromium.h"
    4040#include "LayerTexture.h"
     41#include "LayerTextureSubImage.h"
     42#include "LayerTextureUpdater.h"
    4143
    4244namespace WebCore {
     45
     46class ImageLayerTextureUpdater : public LayerTextureUpdater {
     47public:
     48    ImageLayerTextureUpdater(GraphicsContext3D* context, const PlatformImage& image, bool useMapTexSubImage)
     49        : LayerTextureUpdater(context)
     50        , m_image(image)
     51        , m_texSubImage(useMapTexSubImage)
     52    {
     53    }
     54    virtual ~ImageLayerTextureUpdater() { }
     55
     56    virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
     57
     58    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels)
     59    {
     60        m_texSubImage.setSubImageSize(tileSize);
     61    }
     62
     63    virtual void updateTextureRect(LayerTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
     64    {
     65        texture->bindTexture();
     66
     67        // Source rect should never go outside the image pixels, even if this
     68        // is requested because the texture extends outside the image.
     69        IntRect clippedSourceRect = sourceRect;
     70        clippedSourceRect.intersect(imageRect());
     71
     72        IntRect clippedDestRect = destRect;
     73        clippedDestRect.move(clippedSourceRect.location() - sourceRect.location());
     74        clippedDestRect.setSize(sourceRect.size());
     75
     76        m_texSubImage.upload(m_image.pixels(), imageRect(), clippedSourceRect, clippedDestRect, context());
     77    }
     78
     79private:
     80    IntRect imageRect() const
     81    {
     82        return IntRect(IntPoint::zero(), m_image.size());
     83    }
     84
     85    // FIXME: ImageLayerTextureUpdater should rather own a PlatformImage rather than keeping a reference.
     86    const PlatformImage& m_image;
     87    LayerTextureSubImage m_texSubImage;
     88};
    4389
    4490PassRefPtr<ImageLayerChromium> ImageLayerChromium::create(GraphicsLayerChromium* owner)
     
    81127            m_dirtyRect = IntRect();
    82128        }
     129        m_tiler->prepareToUpdate(paintRect);
    83130    }
    84131}
     
    86133void ImageLayerChromium::updateCompositorResources()
    87134{
    88     IntRect paintRect(IntPoint(0, 0), m_decodedImage.size());
    89     m_tiler->updateFromPixels(paintRect, paintRect, m_decodedImage.pixels());
     135    m_tiler->updateRect();
     136}
     137
     138PassOwnPtr<LayerTextureUpdater> ImageLayerChromium::createTextureUpdater()
     139{
     140    return adoptPtr(new ImageLayerTextureUpdater(layerRendererContext(), m_decodedImage, layerRenderer()->contextSupportsMapSub()));
    90141}
    91142
  • trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h

    r86640 r86805  
    6060    virtual const char* layerTypeAsString() const { return "ImageLayer"; }
    6161
     62    virtual PassOwnPtr<LayerTextureUpdater> createTextureUpdater();
    6263    virtual TransformationMatrix tilingTransform();
    6364    virtual IntRect layerBounds() const;
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r86713 r86805  
    4141#include "GraphicsContext3D.h"
    4242#include "LayerChromium.h"
     43#include "LayerPainterChromium.h"
    4344#include "LayerTexture.h"
     45#include "LayerTextureUpdaterCanvas.h"
    4446#include "NotImplemented.h"
    4547#include "TextStream.h"
     
    9597}
    9698
    97 PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<TilePaintInterface> contentPaint)
     99PassRefPtr<LayerRendererChromium> LayerRendererChromium::create(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<LayerPainterChromium> contentPaint)
    98100{
    99101    if (!context)
     
    108110
    109111LayerRendererChromium::LayerRendererChromium(PassRefPtr<GraphicsContext3D> context,
    110                                              PassOwnPtr<TilePaintInterface> contentPaint)
     112                                             PassOwnPtr<LayerPainterChromium> contentPaint)
    111113    : m_viewportScrollPosition(IntPoint(-1, -1))
    112114    , m_rootLayer(0)
    113     , m_rootLayerContentPaint(contentPaint)
    114115    , m_currentShader(0)
    115116    , m_currentRenderSurface(0)
     
    127128        m_context->getExtensions()->ensureEnabled("GL_CHROMIUM_map_sub");
    128129    m_hardwareCompositing = initializeSharedObjects();
    129     m_rootLayerContentTiler = LayerTilerChromium::create(this, IntSize(256, 256), LayerTilerChromium::NoBorderTexels);
     130
     131    OwnPtr<LayerTextureUpdater> textureUpdater = adoptPtr(new LayerTextureUpdaterBitmap(m_context.get(), contentPaint, m_contextSupportsMapSub));
     132    m_rootLayerContentTiler = LayerTilerChromium::create(this, textureUpdater.release(), IntSize(256, 256), LayerTilerChromium::NoBorderTexels);
    130133    ASSERT(m_rootLayerContentTiler);
    131134
     
    167170{
    168171    TRACE_EVENT("LayerRendererChromium::updateRootLayerContents", this, 0);
    169     m_rootLayerContentTiler->update(*m_rootLayerContentPaint, m_viewportVisibleRect);
     172    m_rootLayerContentTiler->prepareToUpdate(m_viewportVisibleRect);
    170173}
    171174
     
    175178    scroll.translate(-m_viewportVisibleRect.x(), -m_viewportVisibleRect.y());
    176179
    177     m_rootLayerContentTiler->uploadCanvas();
    178180    m_rootLayerContentTiler->draw(m_viewportVisibleRect, scroll, 1.0f);
    179181}
     
    219221
    220222    LayerList renderSurfaceLayerList;
    221 
    222223    updateLayers(renderSurfaceLayerList);
    223224
     
    323324
    324325    updateCompositorResourcesRecursive(m_rootLayer.get());
     326    // Update compositor resources for root layer.
     327    m_rootLayerContentTiler->updateRect();
    325328
    326329    // After updateCompositorResourcesRecursive, set/wait latches for all child
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r86652 r86805  
    6565class GeometryBinding;
    6666class GraphicsContext3D;
     67class LayerPainterChromium;
    6768
    6869// Class that handles drawing of composited render layers using GL.
    6970class LayerRendererChromium : public RefCounted<LayerRendererChromium> {
    7071public:
    71     static PassRefPtr<LayerRendererChromium> create(PassRefPtr<GraphicsContext3D>, PassOwnPtr<TilePaintInterface> contentPaint);
     72    static PassRefPtr<LayerRendererChromium> create(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint);
    7273
    7374    ~LayerRendererChromium();
     
    152153    RefPtr<CCLayerImpl> m_rootCCLayerImpl;
    153154
    154     LayerRendererChromium(PassRefPtr<GraphicsContext3D>, PassOwnPtr<TilePaintInterface> contentPaint);
     155    LayerRendererChromium(PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint);
    155156
    156157    void updateLayers(LayerList& renderSurfaceLayerList);
     
    192193
    193194    RefPtr<LayerChromium> m_rootLayer;
    194     OwnPtr<TilePaintInterface> m_rootLayerContentPaint;
    195195    OwnPtr<LayerTilerChromium> m_rootLayerContentTiler;
    196196
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTextureSubImage.h

    r86804 r86805  
    2323 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    25 #ifndef TraceEvent_h
    26 #define TraceEvent_h
    2725
    28 #include "PlatformBridge.h"
    2926
    30 // Implementation detail: trace event macros create temporary variables
    31 // to keep instrumentation overhead low. These macros give each temporary
    32 // variable a unique name based on the line number to prevent name collissions.
    33 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b) a##b
    34 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(a, b) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b)
    35 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(name_prefix) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(name_prefix, __LINE__)
     27#ifndef LayerTextureSubImage_h
     28#define LayerTextureSubImage_h
    3629
    37 // Issues PlatformBridge::traceEventBegin and traceEventEnd calls for the enclosing scope
    38 #define TRACE_EVENT(name, id, extra) WebCore::internal::ScopeTracer TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(__traceEventScope)(name, id, extra);
     30#if USE(ACCELERATED_COMPOSITING)
     31
     32#include "IntRect.h"
     33#include "IntSize.h"
     34#include <wtf/OwnArrayPtr.h>
    3935
    4036namespace WebCore {
    4137
    42 namespace internal {
     38class GraphicsContext3D;
    4339
    44 // Used by TRACE_EVENT macro. Do not use directly.
    45 class ScopeTracer {
     40class LayerTextureSubImage {
    4641public:
    47     ScopeTracer(const char* name, void*, const char* extra);
    48     ~ScopeTracer();
     42    explicit LayerTextureSubImage(bool useMapSubForUpload);
     43    ~LayerTextureSubImage();
     44
     45    void setSubImageSize(const IntSize&);
     46    void upload(const uint8_t* image, const IntRect& imageRect,
     47                const IntRect& sourceRect, const IntRect& destRect,
     48                GraphicsContext3D*);
    4949
    5050private:
    51     const char* m_name;
    52     void* m_id;
    53     OwnArrayPtr<char> m_extra;
     51    void uploadWithTexSubImage(const uint8_t* image, const IntRect& imageRect,
     52                               const IntRect& sourceRect, const IntRect& destRect,
     53                               GraphicsContext3D*);
     54    void uploadWithMapTexSubImage(const uint8_t* image, const IntRect& imageRect,
     55                                  const IntRect& sourceRect, const IntRect& destRect,
     56                                  GraphicsContext3D*);
     57
     58    bool m_useMapTexSubImage;
     59    IntSize m_subImageSize;
     60    OwnArrayPtr<uint8_t> m_subImage;
    5461};
    5562
    56 inline ScopeTracer::ScopeTracer(const char* name, void* id, const char* extra)
    57     : m_name(name)
    58     , m_id(id)
    59 {
    60     PlatformBridge::traceEventBegin(name, id, extra); \
    61     if (extra)
    62         m_extra = adoptArrayPtr(strdup(extra));
    63 }
     63} // namespace WebCore
     64#endif // USE(ACCELERATED_COMPOSITING)
     65#endif // LayerTextureSubImage_h
    6466
    65 inline ScopeTracer::~ScopeTracer()
    66 {
    67     PlatformBridge::traceEventEnd(m_name, m_id, m_extra.get());
    68 }
    69 
    70 } // namespace internal
    71 
    72 } // namespace WebCore
    73 
    74 #endif
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h

    r86804 r86805  
    2323 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    25 #ifndef TraceEvent_h
    26 #define TraceEvent_h
    2725
    28 #include "PlatformBridge.h"
    2926
    30 // Implementation detail: trace event macros create temporary variables
    31 // to keep instrumentation overhead low. These macros give each temporary
    32 // variable a unique name based on the line number to prevent name collissions.
    33 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b) a##b
    34 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(a, b) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b)
    35 #define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(name_prefix) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(name_prefix, __LINE__)
     27#ifndef LayerTextureUpdater_h
     28#define LayerTextureUpdater_h
    3629
    37 // Issues PlatformBridge::traceEventBegin and traceEventEnd calls for the enclosing scope
    38 #define TRACE_EVENT(name, id, extra) WebCore::internal::ScopeTracer TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(__traceEventScope)(name, id, extra);
     30#if USE(ACCELERATED_COMPOSITING)
    3931
    4032namespace WebCore {
    4133
    42 namespace internal {
     34class GraphicsContext3D;
     35class IntRect;
     36class IntSize;
     37class LayerTexture;
    4338
    44 // Used by TRACE_EVENT macro. Do not use directly.
    45 class ScopeTracer {
     39class LayerTextureUpdater {
    4640public:
    47     ScopeTracer(const char* name, void*, const char* extra);
    48     ~ScopeTracer();
     41    explicit LayerTextureUpdater(GraphicsContext3D* context) : m_context(context) { }
     42    virtual ~LayerTextureUpdater() { }
     43
     44    enum Orientation {
     45        BottomUpOrientation,
     46        TopDownOrientation
     47    };
     48    // Returns the orientation of the texture uploaded by this interface.
     49    virtual Orientation orientation() = 0;
     50    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0;
     51    virtual void updateTextureRect(LayerTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
     52
     53protected:
     54    GraphicsContext3D* context() const { return m_context; }
    4955
    5056private:
    51     const char* m_name;
    52     void* m_id;
    53     OwnArrayPtr<char> m_extra;
     57    // The graphics context with which to update textures.
     58    // It is assumed that the textures are either created in the same context
     59    // or shared with this context.
     60    GraphicsContext3D* m_context;
    5461};
    5562
    56 inline ScopeTracer::ScopeTracer(const char* name, void* id, const char* extra)
    57     : m_name(name)
    58     , m_id(id)
    59 {
    60     PlatformBridge::traceEventBegin(name, id, extra); \
    61     if (extra)
    62         m_extra = adoptArrayPtr(strdup(extra));
    63 }
     63} // namespace WebCore
     64#endif // USE(ACCELERATED_COMPOSITING)
     65#endif // LayerTextureUpdater_h
    6466
    65 inline ScopeTracer::~ScopeTracer()
    66 {
    67     PlatformBridge::traceEventEnd(m_name, m_id, m_extra.get());
    68 }
    69 
    70 } // namespace internal
    71 
    72 } // namespace WebCore
    73 
    74 #endif
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp

    r86640 r86805  
    3636#include "LayerRendererChromium.h"
    3737#include "LayerTexture.h"
     38#include "LayerTextureUpdater.h"
    3839#include "TraceEvent.h"
    3940
    40 #include <wtf/PassOwnArrayPtr.h>
    41 
    4241using namespace std;
    4342
    4443namespace WebCore {
    4544
    46 PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium* layerRenderer, const IntSize& tileSize, BorderTexelOption border)
     45PassOwnPtr<LayerTilerChromium> LayerTilerChromium::create(LayerRendererChromium* layerRenderer, PassOwnPtr<LayerTextureUpdater> textureUpdater, const IntSize& tileSize, BorderTexelOption border)
    4746{
    4847    if (!layerRenderer || tileSize.isEmpty())
    4948        return nullptr;
    5049
    51     return adoptPtr(new LayerTilerChromium(layerRenderer, tileSize, border));
    52 }
    53 
    54 LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, const IntSize& tileSize, BorderTexelOption border)
     50    return adoptPtr(new LayerTilerChromium(layerRenderer, textureUpdater, tileSize, border));
     51}
     52
     53LayerTilerChromium::LayerTilerChromium(LayerRendererChromium* layerRenderer, PassOwnPtr<LayerTextureUpdater> textureUpdater, const IntSize& tileSize, BorderTexelOption border)
    5554    : m_skipsDraw(false)
    5655    , m_tilingData(max(tileSize.width(), tileSize.height()), 0, 0, border == HasBorderTexels)
    57     , m_useMapSubForUploads(layerRenderer->contextSupportsMapSub())
     56    , m_textureUpdater(textureUpdater)
    5857    , m_layerRenderer(layerRenderer)
    5958{
    6059    setTileSize(tileSize);
    61 }
    62 
    63 void LayerTilerChromium::setLayerRenderer(LayerRendererChromium* layerRenderer)
    64 {
    65     if (m_layerRenderer != layerRenderer)
    66         reset();
    67     m_layerRenderer = layerRenderer;
    6860}
    6961
     
    8779
    8880    m_tileSize = size;
    89     if (!m_useMapSubForUploads)
    90         m_tilePixels = adoptArrayPtr(new uint8_t[m_tileSize.width() * m_tileSize.height() * 4]);
    9181    m_tilingData.setMaxTextureSize(max(size.width(), size.height()));
    9282}
     
    231221}
    232222
    233 void LayerTilerChromium::update(TilePaintInterface& painter, const IntRect& contentRect)
     223void LayerTilerChromium::prepareToUpdate(const IntRect& contentRect)
    234224{
    235225    if (m_skipsDraw)
     
    268258        return;
    269259
    270     m_canvas.resize(m_paintRect.size());
    271 
    272     // Assumption: if a tiler is using border texels, then it is because the
    273     // layer is likely to be filtered or transformed. Because of it might be
    274     // transformed, draw the text in grayscale instead of subpixel antialiasing.
    275     PlatformCanvas::Painter::TextOption textOption = m_tilingData.borderTexels() ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText;
    276     PlatformCanvas::Painter canvasPainter(&m_canvas, textOption);
    277     canvasPainter.context()->translate(-m_paintRect.x(), -m_paintRect.y());
    278     {
    279         TRACE_EVENT("LayerTilerChromium::update::paint", this, 0);
    280         painter.paint(*canvasPainter.context(), m_paintRect);
    281     }
    282 }
    283 
    284 void LayerTilerChromium::uploadCanvas()
    285 {
    286     PlatformCanvas::AutoLocker locker(&m_canvas);
    287     {
    288         TRACE_EVENT("LayerTilerChromium::updateFromPixels", this, 0);
    289         updateFromPixels(m_updateRect, m_paintRect, locker.pixels());
    290     }
    291 }
    292 
    293 void LayerTilerChromium::updateFromPixels(const IntRect& contentRect, const IntRect& paintRect, const uint8_t* paintPixels)
     260    m_textureUpdater->prepareToUpdate(m_paintRect, m_tileSize, m_tilingData.borderTexels());
     261}
     262
     263void LayerTilerChromium::updateRect()
    294264{
    295265    // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update.
     
    300270
    301271    int left, top, right, bottom;
    302     contentRectToTileIndices(contentRect, left, top, right, bottom);
     272    contentRectToTileIndices(m_updateRect, left, top, right, bottom);
    303273    for (int j = top; j <= bottom; ++j) {
    304274        for (int i = left; i <= right; ++i) {
     
    315285            // Paint rect not guaranteed to line up on tile boundaries, so
    316286            // make sure that sourceRect doesn't extend outside of it.
    317             sourceRect.intersect(paintRect);
     287            sourceRect.intersect(m_paintRect);
    318288            if (sourceRect.isEmpty())
    319289                continue;
     
    335305
    336306            // Offset from paint rectangle to this tile's dirty rectangle.
    337             IntPoint paintOffset(sourceRect.x() - paintRect.x(), sourceRect.y() - paintRect.y());
     307            IntPoint paintOffset(sourceRect.x() - m_paintRect.x(), sourceRect.y() - m_paintRect.y());
    338308            if (paintOffset.x() < 0)
    339309                CRASH();
    340310            if (paintOffset.y() < 0)
    341311                CRASH();
    342             if (paintOffset.x() + destRect.width() > paintRect.width())
    343                 CRASH();
    344             if (paintOffset.y() + destRect.height() > paintRect.height())
     312            if (paintOffset.x() + destRect.width() > m_paintRect.width())
     313                CRASH();
     314            if (paintOffset.y() + destRect.height() > m_paintRect.height())
    345315                CRASH();
    346316
    347317            tile->texture()->bindTexture();
    348 
    349318            const GC3Dint filter = m_tilingData.borderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
    350319            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
    351320            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
    352321
    353             if (m_useMapSubForUploads) {
    354                 // Upload tile data via a mapped transfer buffer
    355                 Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
    356                 uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
    357                 ASSERT(pixelDest);
    358                 if (paintRect.width() == sourceRect.width() && !paintOffset.x())
    359                     memcpy(pixelDest, &paintPixels[4 * paintOffset.y() * paintRect.width()], paintRect.width() * destRect.height() * 4);
    360                 else {
    361                     // Strides not equal, so do a row-by-row memcpy from the
    362                     // paint results into the pixelDest
    363                     for (int row = 0; row < destRect.height(); ++row)
    364                         memcpy(&pixelDest[destRect.width() * 4 * row],
    365                                &paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())],
    366                                destRect.width() * 4);
    367                 }
    368                 extensions->unmapTexSubImage2DCHROMIUM(pixelDest);
    369             } else {
    370                 const uint8_t* pixelSource;
    371                 if (paintRect.width() == sourceRect.width() && !paintOffset.x())
    372                     pixelSource = &paintPixels[4 * paintOffset.y() * paintRect.width()];
    373                 else {
    374                     // Strides not equal, so do a row-by-row memcpy from the
    375                     // paint results into a temp buffer for uploading.
    376                     for (int row = 0; row < destRect.height(); ++row)
    377                         memcpy(&m_tilePixels[destRect.width() * 4 * row],
    378                                &paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())],
    379                                destRect.width() * 4);
    380 
    381                     pixelSource = &m_tilePixels[0];
    382                 }
    383 
    384 
    385                 GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource));
    386             }
    387 
     322            m_textureUpdater->updateTextureRect(tile->texture(), sourceRect, destRect);
    388323            tile->clearDirty();
    389324        }
     
    431366            float texScaleX = tileRect.width() / tileWidth;
    432367            float texScaleY = tileRect.height() / tileHeight;
    433 
     368            // OpenGL coordinate system is bottom-up.
     369            // If tile texture is top-down, we need to flip the texture coordinates.
     370            if (m_textureUpdater->orientation() == LayerTextureUpdater::TopDownOrientation) {
     371                texTranslateY += 1.0;
     372                texScaleY *= -1.0;
     373            }
    434374            drawTexturedQuad(context, layerRenderer()->projectionMatrix(), tileMatrix, tileRect.width(), tileRect.height(), opacity, texTranslateX, texTranslateY, texScaleX, texScaleY, program);
    435375        }
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h

    r86640 r86805  
    3232#include "LayerChromium.h"
    3333#include "LayerTexture.h"
    34 #include "PlatformCanvas.h"
    3534#include "TilingData.h"
    3635#include <wtf/HashTraits.h>
    37 #include <wtf/OwnArrayPtr.h>
    3836#include <wtf/RefCounted.h>
    3937
     
    4240class GraphicsContext3D;
    4341class LayerRendererChromium;
    44 
    45 class TilePaintInterface {
    46 public:
    47     virtual void paint(GraphicsContext& context, const IntRect& contentRect) = 0;
    48 };
     42class LayerTextureUpdater;
    4943
    5044class LayerTilerChromium {
     
    5347    enum BorderTexelOption { HasBorderTexels, NoBorderTexels };
    5448
    55     static PassOwnPtr<LayerTilerChromium> create(LayerRendererChromium*, const IntSize& tileSize, BorderTexelOption);
     49    static PassOwnPtr<LayerTilerChromium> create(LayerRendererChromium*, PassOwnPtr<LayerTextureUpdater>, const IntSize& tileSize, BorderTexelOption);
    5650
    5751    ~LayerTilerChromium();
     
    6155    void invalidateEntireLayer();
    6256
    63     // Paint all invalidations and missing tiles needed to draw the contentRect
    64     // into the internal canvas.
    65     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.
    71     void updateFromPixels(const IntRect& contentRect, const IntRect& paintRect, const uint8_t* pixels);
    72 
     57    // Prepare data needed to update textures that instersect with contentRect.
     58    void prepareToUpdate(const IntRect& contentRect);
     59    // Update invalid textures that intersect with contentRect provided in prepareToUpdate().
     60    void updateRect();
    7361    // Draw all tiles that intersect with the content rect.
    7462    void draw(const IntRect& contentRect, const TransformationMatrix&, float opacity);
     
    7866    // Change the tile size.  This may invalidate all the existing tiles.
    7967    void setTileSize(const IntSize& size);
    80     void setLayerRenderer(LayerRendererChromium*);
    8168
    8269    bool skipsDraw() const { return m_skipsDraw; }
     
    8875
    8976private:
    90     LayerTilerChromium(LayerRendererChromium*, const IntSize& tileSize, BorderTexelOption);
     77    LayerTilerChromium(LayerRendererChromium*, PassOwnPtr<LayerTextureUpdater>, const IntSize& tileSize, BorderTexelOption);
    9178
    9279    class Tile : public RefCounted<Tile> {
    9380        WTF_MAKE_NONCOPYABLE(Tile);
    9481    public:
    95         explicit Tile(PassOwnPtr<LayerTexture> tex) : m_tex(tex), m_i(-1), m_j(-1) {}
     82        explicit Tile(PassOwnPtr<LayerTexture> tex) : m_tex(tex), m_i(-1), m_j(-1) { }
    9683
    9784        LayerTexture* texture() { return m_tex.get(); }
     
    158145    Vector<RefPtr<Tile> > m_unusedTiles;
    159146
    160     // State held between update and uploadCanvas.
     147    // State held between update and upload.
    161148    IntRect m_paintRect;
    162149    IntRect m_updateRect;
    163     PlatformCanvas m_canvas;
    164 
    165     // Cache a tile-sized pixel buffer to draw into.
    166     OwnArrayPtr<uint8_t> m_tilePixels;
    167150
    168151    TilingData m_tilingData;
    169152
    170     // Whether the tiler will use GL_CHROMIUM_map_sub for texture uploads.
    171     bool m_useMapSubForUploads;
    172 
     153    OwnPtr<LayerTextureUpdater> m_textureUpdater;
    173154    LayerRendererChromium* m_layerRenderer;
    174155};
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp

    r86788 r86805  
    3535#include "LayerRendererChromium.h"
    3636#include "LayerTexture.h"
     37#include "PlatformCanvas.h"
    3738#include "TextRun.h"
    3839#include "TextStream.h"
     
    116117            extensions->unmapTexSubImage2DCHROMIUM(pixelDest);
    117118        } else
    118             GLC(context.get(), context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));
     119            GLC(context, context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));
    119120    }
    120121
  • trunk/Source/WebKit/chromium/ChangeLog

    r86799 r86805  
     12011-05-18  Alok Priyadarshi  <alokp@chromium.org> and Adrienne Walker  <enne@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        Split canvas from LayerTilerChromium
     6        https://bugs.webkit.org/show_bug.cgi?id=60719
     7
     8        * src/WebViewImpl.cpp:
     9
    1102011-05-18  Brett Wilson  <brettw@chromium.org>
    211
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r86640 r86805  
    7373#include "KeyboardCodes.h"
    7474#include "KeyboardEvent.h"
     75#include "LayerPainterChromium.h"
    7576#include "MIMETypeRegistry.h"
    7677#include "NodeRenderStyle.h"
     
    24102411}
    24112412
    2412 class WebViewImplContentPainter : public TilePaintInterface {
     2413class WebViewImplContentPainter : public LayerPainterChromium {
    24132414    WTF_MAKE_NONCOPYABLE(WebViewImplContentPainter);
    24142415public:
Note: See TracChangeset for help on using the changeset viewer.