⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 99813 in webkit


Ignore:
Timestamp:
Nov 9, 2011, 9:45:25 PM (15 years ago)
Author:
commit-queue@webkit.org
Message:

[Chromium] Add support for painting into an SkPicture and then rasterizing into tile-sized chunks.
https://bugs.webkit.org/show_bug.cgi?id=71388

Patch by David Reveman <reveman@chromium.org> on 2011-11-09
Reviewed by James Robinson.

Add UpdatableTexture class, which allows texture updater to
allocate tile specific resources and paint tiles separately.
Rename texture uploader classes and move them to separate files.

No new tests. Covered by existing tests.

  • WebCore.gypi:
  • platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp: Added.

(WebCore::BitmapCanvasLayerTextureUpdater::Texture::Texture):
(WebCore::BitmapCanvasLayerTextureUpdater::Texture::~Texture):
(WebCore::BitmapCanvasLayerTextureUpdater::Texture::updateRect):
(WebCore::BitmapCanvasLayerTextureUpdater::create):
(WebCore::BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater):
(WebCore::BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater):
(WebCore::BitmapCanvasLayerTextureUpdater::createTexture):
(WebCore::BitmapCanvasLayerTextureUpdater::sampledTexelFormat):
(WebCore::BitmapCanvasLayerTextureUpdater::prepareToUpdate):
(WebCore::BitmapCanvasLayerTextureUpdater::updateTextureRect):

  • platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h.

(WebCore::BitmapCanvasLayerTextureUpdater::Texture::textureUpdater):
(WebCore::BitmapCanvasLayerTextureUpdater::orientation):

  • platform/graphics/chromium/ContentLayerChromium.cpp:

(WebCore::ContentLayerChromium::createTextureUpdater):

  • platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp: Renamed from Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp.

(WebCore::FrameBuffer::FrameBuffer::FrameBuffer):
(WebCore::FrameBuffer::FrameBuffer::~FrameBuffer):
(WebCore::FrameBuffer::FrameBuffer::initialize):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::create):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::FrameBufferSkPictureCanvasLayerTextureUpdater):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::~FrameBufferSkPictureCanvasLayerTextureUpdater):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::createTexture):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::sampledTexelFormat):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):

  • platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h.

(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::textureUpdater):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::orientation):

  • platform/graphics/chromium/ImageLayerChromium.cpp:

(WebCore::ImageLayerTextureUpdater::Texture::Texture):
(WebCore::ImageLayerTextureUpdater::Texture::updateRect):
(WebCore::ImageLayerTextureUpdater::Texture::textureUpdater):
(WebCore::ImageLayerTextureUpdater::createTexture):
(WebCore::ImageLayerTextureUpdater::prepareToUpdate):

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

(WebCore::LayerTextureUpdater::Texture::~Texture):
(WebCore::LayerTextureUpdater::Texture::texture):
(WebCore::LayerTextureUpdater::Texture::prepareRect):
(WebCore::LayerTextureUpdater::Texture::Texture):
(WebCore::LayerTextureUpdater::prepareToUpdate):

  • platform/graphics/chromium/LayerTextureUpdaterCanvas.h: Removed.
  • platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h.

(WebCore::SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater):
(WebCore::SkPictureCanvasLayerTextureUpdater::~SkPictureCanvasLayerTextureUpdater):
(WebCore::SkPictureCanvasLayerTextureUpdater::prepareToUpdate):
(WebCore::SkPictureCanvasLayerTextureUpdater::drawPicture):

  • platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h.
  • platform/graphics/chromium/TiledLayerChromium.cpp:

(WebCore::UpdatableTile::UpdatableTile):
(WebCore::UpdatableTile::texture):
(WebCore::UpdatableTile::managedTexture):
(WebCore::TiledLayerChromium::updateCompositorResources):
(WebCore::TiledLayerChromium::pushPropertiesTo):
(WebCore::TiledLayerChromium::createTile):
(WebCore::TiledLayerChromium::protectTileTextures):
(WebCore::TiledLayerChromium::prepareToUpdate):

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

(WebCore::CCTextureUpdater::append):
(WebCore::CCTextureUpdater::update):

  • platform/graphics/chromium/cc/CCTextureUpdater.h:
Location:
trunk/Source/WebCore
Files:
1 added
1 deleted
9 edited
6 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r99809 r99813  
     12011-11-09  David Reveman  <reveman@chromium.org>
     2
     3        [Chromium] Add support for painting into an SkPicture and then rasterizing into tile-sized chunks.
     4        https://bugs.webkit.org/show_bug.cgi?id=71388
     5
     6        Reviewed by James Robinson.
     7
     8        Add UpdatableTexture class, which allows texture updater to
     9        allocate tile specific resources and paint tiles separately.
     10        Rename texture uploader classes and move them to separate files.
     11
     12        No new tests. Covered by existing tests.
     13
     14        * WebCore.gypi:
     15        * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp: Added.
     16        (WebCore::BitmapCanvasLayerTextureUpdater::Texture::Texture):
     17        (WebCore::BitmapCanvasLayerTextureUpdater::Texture::~Texture):
     18        (WebCore::BitmapCanvasLayerTextureUpdater::Texture::updateRect):
     19        (WebCore::BitmapCanvasLayerTextureUpdater::create):
     20        (WebCore::BitmapCanvasLayerTextureUpdater::BitmapCanvasLayerTextureUpdater):
     21        (WebCore::BitmapCanvasLayerTextureUpdater::~BitmapCanvasLayerTextureUpdater):
     22        (WebCore::BitmapCanvasLayerTextureUpdater::createTexture):
     23        (WebCore::BitmapCanvasLayerTextureUpdater::sampledTexelFormat):
     24        (WebCore::BitmapCanvasLayerTextureUpdater::prepareToUpdate):
     25        (WebCore::BitmapCanvasLayerTextureUpdater::updateTextureRect):
     26        * platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h.
     27        (WebCore::BitmapCanvasLayerTextureUpdater::Texture::textureUpdater):
     28        (WebCore::BitmapCanvasLayerTextureUpdater::orientation):
     29        * platform/graphics/chromium/ContentLayerChromium.cpp:
     30        (WebCore::ContentLayerChromium::createTextureUpdater):
     31        * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp: Renamed from Source/WebCore/platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp.
     32        (WebCore::FrameBuffer::FrameBuffer::FrameBuffer):
     33        (WebCore::FrameBuffer::FrameBuffer::~FrameBuffer):
     34        (WebCore::FrameBuffer::FrameBuffer::initialize):
     35        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture):
     36        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture):
     37        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect):
     38        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::create):
     39        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::FrameBufferSkPictureCanvasLayerTextureUpdater):
     40        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::~FrameBufferSkPictureCanvasLayerTextureUpdater):
     41        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::createTexture):
     42        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::sampledTexelFormat):
     43        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
     44        * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h.
     45        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::textureUpdater):
     46        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::orientation):
     47        * platform/graphics/chromium/ImageLayerChromium.cpp:
     48        (WebCore::ImageLayerTextureUpdater::Texture::Texture):
     49        (WebCore::ImageLayerTextureUpdater::Texture::updateRect):
     50        (WebCore::ImageLayerTextureUpdater::Texture::textureUpdater):
     51        (WebCore::ImageLayerTextureUpdater::createTexture):
     52        (WebCore::ImageLayerTextureUpdater::prepareToUpdate):
     53        * platform/graphics/chromium/LayerRendererChromium.cpp:
     54        * platform/graphics/chromium/LayerTextureUpdater.h:
     55        (WebCore::LayerTextureUpdater::Texture::~Texture):
     56        (WebCore::LayerTextureUpdater::Texture::texture):
     57        (WebCore::LayerTextureUpdater::Texture::prepareRect):
     58        (WebCore::LayerTextureUpdater::Texture::Texture):
     59        (WebCore::LayerTextureUpdater::prepareToUpdate):
     60        * platform/graphics/chromium/LayerTextureUpdaterCanvas.h: Removed.
     61        * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h.
     62        (WebCore::SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater):
     63        (WebCore::SkPictureCanvasLayerTextureUpdater::~SkPictureCanvasLayerTextureUpdater):
     64        (WebCore::SkPictureCanvasLayerTextureUpdater::prepareToUpdate):
     65        (WebCore::SkPictureCanvasLayerTextureUpdater::drawPicture):
     66        * platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h.
     67        * platform/graphics/chromium/TiledLayerChromium.cpp:
     68        (WebCore::UpdatableTile::UpdatableTile):
     69        (WebCore::UpdatableTile::texture):
     70        (WebCore::UpdatableTile::managedTexture):
     71        (WebCore::TiledLayerChromium::updateCompositorResources):
     72        (WebCore::TiledLayerChromium::pushPropertiesTo):
     73        (WebCore::TiledLayerChromium::createTile):
     74        (WebCore::TiledLayerChromium::protectTileTextures):
     75        (WebCore::TiledLayerChromium::prepareToUpdate):
     76        * platform/graphics/chromium/cc/CCTextureUpdater.cpp:
     77        (WebCore::CCTextureUpdater::append):
     78        (WebCore::CCTextureUpdater::update):
     79        * platform/graphics/chromium/cc/CCTextureUpdater.h:
     80
    1812011-11-09  Kevin Ollivier  <kevino@theolliviers.com>
    282
  • trunk/Source/WebCore/WebCore.gypi

    r99750 r99813  
    34483448            'platform/graphics/cg/PatternCG.cpp',
    34493449            'platform/graphics/cg/TransformationMatrixCG.cpp',
     3450            'platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.cpp',
     3451            'platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h',
    34503452            'platform/graphics/chromium/Canvas2DLayerChromium.cpp',
    34513453            'platform/graphics/chromium/Canvas2DLayerChromium.h',
    34523454            'platform/graphics/chromium/CanvasLayerChromium.cpp',
    34533455            'platform/graphics/chromium/CanvasLayerChromium.h',
     3456            'platform/graphics/chromium/CanvasLayerTextureUpdater.cpp',
     3457            'platform/graphics/chromium/CanvasLayerTextureUpdater.h',
    34543458            'platform/graphics/chromium/ComplexTextControllerLinux.cpp',
    34553459            'platform/graphics/chromium/ComplexTextControllerLinux.h',
     
    34723476            'platform/graphics/chromium/FontUtilsChromiumWin.cpp',
    34733477            'platform/graphics/chromium/FontUtilsChromiumWin.h',
     3478            'platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp',
     3479            'platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h',
    34743480            'platform/graphics/chromium/GeometryBinding.cpp',
    34753481            'platform/graphics/chromium/GeometryBinding.h',
     
    34953501            'platform/graphics/chromium/LayerTextureSubImage.h',
    34963502            'platform/graphics/chromium/LayerTextureUpdater.h',
    3497             'platform/graphics/chromium/LayerTextureUpdaterCanvas.cpp',
    3498             'platform/graphics/chromium/LayerTextureUpdaterCanvas.h',
    34993503            'platform/graphics/chromium/NonCompositedContentHost.cpp',
    35003504            'platform/graphics/chromium/NonCompositedContentHost.h',
     
    35183522            'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp',
    35193523            'platform/graphics/chromium/SimpleFontDataLinux.cpp',
     3524            'platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp',
     3525            'platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h',
    35203526            'platform/graphics/chromium/TrackingTextureAllocator.cpp',
    35213527            'platform/graphics/chromium/TrackingTextureAllocator.h',
  • trunk/Source/WebCore/platform/graphics/chromium/BitmapCanvasLayerTextureUpdater.h

    r99812 r99813  
    2525
    2626
    27 #ifndef LayerTextureUpdater_h
    28 #define LayerTextureUpdater_h
     27#ifndef BitmapCanvasLayerTextureUpdater_h
     28#define BitmapCanvasLayerTextureUpdater_h
    2929
    3030#if USE(ACCELERATED_COMPOSITING)
    3131
    32 #include "GraphicsTypes3D.h"
    33 #include <wtf/RefCounted.h>
     32#include "CanvasLayerTextureUpdater.h"
     33#include "LayerTextureSubImage.h"
     34#include "PlatformCanvas.h"
    3435
    3536namespace WebCore {
    3637
    37 class GraphicsContext3D;
    38 class IntRect;
    39 class IntSize;
    40 class ManagedTexture;
    41 class TextureAllocator;
     38class LayerPainterChromium;
    4239
    43 class LayerTextureUpdater : public RefCounted<LayerTextureUpdater> {
     40// A CanvasLayerTextureUpdater with an internal bitmap.
     41class BitmapCanvasLayerTextureUpdater : public CanvasLayerTextureUpdater {
    4442public:
    45     virtual ~LayerTextureUpdater() { }
     43    class Texture : public LayerTextureUpdater::Texture {
     44    public:
     45        Texture(BitmapCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>);
     46        virtual ~Texture();
    4647
    47     enum Orientation {
    48         BottomUpOrientation,
    49         TopDownOrientation,
    50         InvalidOrientation,
     48        virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect);
     49
     50    private:
     51        BitmapCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; }
     52
     53        BitmapCanvasLayerTextureUpdater* m_textureUpdater;
    5154    };
    52     enum SampledTexelFormat {
    53         SampledTexelFormatRGBA,
    54         SampledTexelFormatBGRA,
    55         SampledTexelFormatInvalid,
    56     };
    57     // Returns the orientation of the texture uploaded by this interface.
    58     virtual Orientation orientation() = 0;
    59     // Returns the format of the texel uploaded by this interface.
    60     // This format should not be confused by texture internal format.
    61     // This format specifies the component order in the sampled texel.
    62     // If the format is TexelFormatBGRA, vec4.x is blue and vec4.z is red.
    63     virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0;
    64     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0;
    65     virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
     55
     56    static PassRefPtr<BitmapCanvasLayerTextureUpdater> create(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
     57    virtual ~BitmapCanvasLayerTextureUpdater();
     58
     59    virtual PassRefPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*);
     60    virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
     61    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
     62    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
     63    void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
     64
     65private:
     66    BitmapCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>, bool useMapTexSubImage);
     67
     68    PlatformCanvas m_canvas;
     69    LayerTextureSubImage m_texSubImage;
    6670};
    6771
    6872} // namespace WebCore
    6973#endif // USE(ACCELERATED_COMPOSITING)
    70 #endif // LayerTextureUpdater_h
     74#endif // BitmapCanvasLayerTextureUpdater_h
  • trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp

    r99812 r99813  
    2424 */
    2525
    26 #ifndef CCTextureUpdater_h
    27 #define CCTextureUpdater_h
    2826
    29 #include "IntRect.h"
    30 #include <wtf/Vector.h>
     27#include "config.h"
     28
     29#if USE(ACCELERATED_COMPOSITING)
     30
     31#include "CanvasLayerTextureUpdater.h"
     32
     33#include "GraphicsContext.h"
     34#include "LayerPainterChromium.h"
     35#include "TraceEvent.h"
    3136
    3237namespace WebCore {
    3338
    34 class GraphicsContext3D;
    35 class LayerTextureUpdater;
    36 class ManagedTexture;
    37 class TextureAllocator;
    38 
    39 class CCTextureUpdater {
    40 public:
    41     CCTextureUpdater(TextureAllocator*);
    42     ~CCTextureUpdater();
    43 
    44     void append(ManagedTexture*, LayerTextureUpdater*, const IntRect& sourceRect, const IntRect& destRect);
    45 
    46     bool hasMoreUpdates() const;
    47 
    48     // Update some textures. Returns true if more textures left to process.
    49     bool update(GraphicsContext3D*, size_t count);
    50 
    51     void clear();
    52 
    53     TextureAllocator* allocator() { return m_allocator; }
    54 
    55 private:
    56     struct UpdateEntry {
    57         ManagedTexture* m_texture;
    58         LayerTextureUpdater* m_updater;
    59         IntRect m_sourceRect;
    60         IntRect m_destRect;
    61     };
    62 
    63     TextureAllocator* m_allocator;
    64     size_t m_entryIndex;
    65     Vector<UpdateEntry> m_entries;
    66 };
    67 
     39CanvasLayerTextureUpdater::CanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
     40    : m_painter(painter)
     41{
    6842}
    6943
    70 #endif // CCTextureUpdater_h
     44CanvasLayerTextureUpdater::~CanvasLayerTextureUpdater()
     45{
     46}
     47
     48void CanvasLayerTextureUpdater::paintContents(GraphicsContext& context, const IntRect& contentRect)
     49{
     50    context.translate(-contentRect.x(), -contentRect.y());
     51    {
     52        TRACE_EVENT("CanvasLayerTextureUpdater::paint", this, 0);
     53        m_painter->paint(context, contentRect);
     54    }
     55    m_contentRect = contentRect;
     56}
     57
     58} // namespace WebCore
     59#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.h

    r99812 r99813  
    2424 */
    2525
    26 #ifndef CCTextureUpdater_h
    27 #define CCTextureUpdater_h
    2826
    29 #include "IntRect.h"
    30 #include <wtf/Vector.h>
     27#ifndef CanvasLayerTextureUpdater_h
     28#define CanvasLayerTextureUpdater_h
     29
     30#if USE(ACCELERATED_COMPOSITING)
     31
     32#include "LayerTextureUpdater.h"
    3133
    3234namespace WebCore {
    3335
    3436class GraphicsContext3D;
    35 class LayerTextureUpdater;
    36 class ManagedTexture;
    37 class TextureAllocator;
     37class LayerPainterChromium;
    3838
    39 class CCTextureUpdater {
     39// A LayerTextureUpdater with an internal canvas.
     40class CanvasLayerTextureUpdater : public LayerTextureUpdater {
    4041public:
    41     CCTextureUpdater(TextureAllocator*);
    42     ~CCTextureUpdater();
     42    virtual ~CanvasLayerTextureUpdater();
    4343
    44     void append(ManagedTexture*, LayerTextureUpdater*, const IntRect& sourceRect, const IntRect& destRect);
     44protected:
     45    explicit CanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);
    4546
    46     bool hasMoreUpdates() const;
    47 
    48     // Update some textures. Returns true if more textures left to process.
    49     bool update(GraphicsContext3D*, size_t count);
    50 
    51     void clear();
    52 
    53     TextureAllocator* allocator() { return m_allocator; }
     47    void paintContents(GraphicsContext&, const IntRect& contentRect);
     48    const IntRect& contentRect() const { return m_contentRect; }
    5449
    5550private:
    56     struct UpdateEntry {
    57         ManagedTexture* m_texture;
    58         LayerTextureUpdater* m_updater;
    59         IntRect m_sourceRect;
    60         IntRect m_destRect;
    61     };
    62 
    63     TextureAllocator* m_allocator;
    64     size_t m_entryIndex;
    65     Vector<UpdateEntry> m_entries;
     51    IntRect m_contentRect;
     52    OwnPtr<LayerPainterChromium> m_painter;
    6653};
    6754
    68 }
    69 
    70 #endif // CCTextureUpdater_h
     55} // namespace WebCore
     56#endif // USE(ACCELERATED_COMPOSITING)
     57#endif // CanvasLayerTextureUpdater_h
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r98277 r99813  
    3535#include "ContentLayerChromium.h"
    3636
     37#include "BitmapCanvasLayerTextureUpdater.h"
     38#include "FrameBufferSkPictureCanvasLayerTextureUpdater.h"
    3739#include "LayerPainterChromium.h"
    3840#include "LayerRendererChromium.h"
    39 #include "LayerTextureUpdaterCanvas.h"
    4041#include "PlatformSupport.h"
    4142#include "cc/CCLayerTreeHost.h"
     
    123124#if USE(SKIA)
    124125    if (host->settings().acceleratePainting) {
    125         m_textureUpdater = LayerTextureUpdaterSkPicture::create(ContentLayerPainter::create(m_delegate));
     126        m_textureUpdater = FrameBufferSkPictureCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate));
    126127        return;
    127128    }
    128129#endif // USE(SKIA)
    129130
    130     m_textureUpdater = LayerTextureUpdaterBitmap::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub);
     131    m_textureUpdater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(m_delegate), host->layerRendererCapabilities().usingMapSub);
    131132}
    132133
  • trunk/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp

    r99812 r99813  
    2828
    2929#if USE(ACCELERATED_COMPOSITING)
     30#if USE(SKIA)
    3031
    31 #include "LayerTextureUpdaterCanvas.h"
     32#include "FrameBufferSkPictureCanvasLayerTextureUpdater.h"
    3233
    33 #include "Extensions3D.h"
    34 #include "GraphicsContext.h"
    3534#include "LayerPainterChromium.h"
    36 #include "ManagedTexture.h"
    37 #include "PlatformColor.h"
    38 #include "TraceEvent.h"
    39 
    40 #if USE(SKIA)
    41 #include "GrContext.h"
    42 #include "PlatformContextSkia.h"
    4335#include "SkCanvas.h"
    4436#include "SkGpuDevice.h"
    45 #endif // USE(SKIA)
    4637
    4738namespace WebCore {
    4839
    49 #if USE(SKIA)
    5040namespace {
    5141
     
    10595
    10696} // namespace
    107 #endif // USE(SKIA)
    10897
    109 LayerTextureUpdaterCanvas::LayerTextureUpdaterCanvas(PassOwnPtr<LayerPainterChromium> painter)
    110     : m_painter(painter)
     98FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::Texture(FrameBufferSkPictureCanvasLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture)
     99    : LayerTextureUpdater::Texture(texture)
     100    , m_textureUpdater(textureUpdater)
    111101{
    112102}
    113103
    114 void LayerTextureUpdaterCanvas::paintContents(GraphicsContext& context, const IntRect& contentRect)
    115 {
    116     context.translate(-contentRect.x(), -contentRect.y());
    117     {
    118         TRACE_EVENT("LayerTextureUpdaterCanvas::paint", this, 0);
    119         m_painter->paint(context, contentRect);
    120     }
    121     m_contentRect = contentRect;
    122 }
    123 
    124 PassRefPtr<LayerTextureUpdaterBitmap> LayerTextureUpdaterBitmap::create(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
    125 {
    126     return adoptRef(new LayerTextureUpdaterBitmap(painter, useMapTexSubImage));
    127 }
    128 
    129 LayerTextureUpdaterBitmap::LayerTextureUpdaterBitmap(PassOwnPtr<LayerPainterChromium> painter, bool useMapTexSubImage)
    130     : LayerTextureUpdaterCanvas(painter)
    131     , m_texSubImage(useMapTexSubImage)
     104FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture()
    132105{
    133106}
    134107
    135 LayerTextureUpdater::SampledTexelFormat LayerTextureUpdaterBitmap::sampledTexelFormat(GC3Denum textureFormat)
     108void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect)
    136109{
    137     // The component order may be bgra if we uploaded bgra pixels to rgba textures.
    138     return PlatformColor::sameComponentOrder(textureFormat) ?
    139             LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdater::SampledTexelFormatBGRA;
     110    textureUpdater()->updateTextureRect(context, allocator, texture(), sourceRect, destRect);
    140111}
    141112
    142 void LayerTextureUpdaterBitmap::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels)
     113PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> FrameBufferSkPictureCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter)
    143114{
    144     m_texSubImage.setSubImageSize(tileSize);
    145 
    146     m_canvas.resize(contentRect.size());
    147     // Assumption: if a tiler is using border texels, then it is because the
    148     // layer is likely to be filtered or transformed. Because of it might be
    149     // transformed, draw the text in grayscale instead of subpixel antialiasing.
    150     PlatformCanvas::Painter::TextOption textOption =
    151         borderTexels ? PlatformCanvas::Painter::GrayscaleText : PlatformCanvas::Painter::SubpixelText;
    152     PlatformCanvas::Painter canvasPainter(&m_canvas, textOption);
    153     paintContents(*canvasPainter.context(), contentRect);
     115    return adoptRef(new FrameBufferSkPictureCanvasLayerTextureUpdater(painter));
    154116}
    155117
    156 void LayerTextureUpdaterBitmap::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
    157 {
    158     PlatformCanvas::AutoLocker locker(&m_canvas);
    159 
    160     texture->bindTexture(context, allocator);
    161     m_texSubImage.upload(locker.pixels(), contentRect(), sourceRect, destRect, texture->format(), context);
    162 }
    163 
    164 #if USE(SKIA)
    165 PassRefPtr<LayerTextureUpdaterSkPicture> LayerTextureUpdaterSkPicture::create(PassOwnPtr<LayerPainterChromium> painter)
    166 {
    167     return adoptRef(new LayerTextureUpdaterSkPicture(painter));
    168 }
    169 
    170 LayerTextureUpdaterSkPicture::LayerTextureUpdaterSkPicture(PassOwnPtr<LayerPainterChromium> painter)
    171     : LayerTextureUpdaterCanvas(painter)
     118FrameBufferSkPictureCanvasLayerTextureUpdater::FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
     119    : SkPictureCanvasLayerTextureUpdater(painter)
    172120{
    173121}
    174122
    175 LayerTextureUpdaterSkPicture::~LayerTextureUpdaterSkPicture()
     123FrameBufferSkPictureCanvasLayerTextureUpdater::~FrameBufferSkPictureCanvasLayerTextureUpdater()
    176124{
    177125}
    178126
    179 LayerTextureUpdater::SampledTexelFormat LayerTextureUpdaterSkPicture::sampledTexelFormat(GC3Denum textureFormat)
     127PassRefPtr<LayerTextureUpdater::Texture> FrameBufferSkPictureCanvasLayerTextureUpdater::createTexture(TextureManager* manager)
     128{
     129    return adoptRef(new Texture(this, ManagedTexture::create(manager)));
     130}
     131
     132LayerTextureUpdater::SampledTexelFormat FrameBufferSkPictureCanvasLayerTextureUpdater::sampledTexelFormat(GC3Denum textureFormat)
    180133{
    181134    // Here we directly render to the texture, so the component order is always correct.
     
    183136}
    184137
    185 void LayerTextureUpdaterSkPicture::prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels)
    186 {
    187     SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height());
    188     PlatformContextSkia platformContext(canvas);
    189     GraphicsContext graphicsContext(&platformContext);
    190     paintContents(graphicsContext, contentRect);
    191     m_picture.endRecording();
    192 }
    193 
    194 void LayerTextureUpdaterSkPicture::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
     138void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
    195139{
    196140    // Make sure SKIA uses the correct GL context.
     
    208152    canvas->translate(contentRect().x() - sourceRect.x() + destRect.x(),
    209153                      contentRect().y() - sourceRect.y() + destRect.y());
    210     canvas->drawPicture(m_picture);
     154    drawPicture(canvas);
    211155
    212156    // Flush SKIA context so that all the rendered stuff appears on the texture.
    213157    context->grContext()->flush();
    214158}
    215 #endif // USE(SKIA)
    216159
    217160} // namespace WebCore
     161#endif // USE(SKIA)
    218162#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h

    r99812 r99813  
    2525
    2626
    27 #ifndef LayerTextureUpdater_h
    28 #define LayerTextureUpdater_h
     27#ifndef FrameBufferSkPictureCanvasLayerTextureUpdater_h
     28#define FrameBufferSkPictureCanvasLayerTextureUpdater_h
    2929
    3030#if USE(ACCELERATED_COMPOSITING)
     31#if USE(SKIA)
    3132
    32 #include "GraphicsTypes3D.h"
    33 #include <wtf/RefCounted.h>
     33#include "SkPictureCanvasLayerTextureUpdater.h"
    3434
    3535namespace WebCore {
    3636
    37 class GraphicsContext3D;
    38 class IntRect;
    39 class IntSize;
    40 class ManagedTexture;
    41 class TextureAllocator;
     37class FrameBufferSkPictureCanvasLayerTextureUpdater : public SkPictureCanvasLayerTextureUpdater {
     38public:
     39    class Texture : public LayerTextureUpdater::Texture {
     40    public:
     41        Texture(FrameBufferSkPictureCanvasLayerTextureUpdater*, PassOwnPtr<ManagedTexture>);
     42        virtual ~Texture();
    4243
    43 class LayerTextureUpdater : public RefCounted<LayerTextureUpdater> {
    44 public:
    45     virtual ~LayerTextureUpdater() { }
     44        virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect);
    4645
    47     enum Orientation {
    48         BottomUpOrientation,
    49         TopDownOrientation,
    50         InvalidOrientation,
     46    private:
     47        FrameBufferSkPictureCanvasLayerTextureUpdater* textureUpdater() { return m_textureUpdater; }
     48
     49        FrameBufferSkPictureCanvasLayerTextureUpdater* m_textureUpdater;
    5150    };
    52     enum SampledTexelFormat {
    53         SampledTexelFormatRGBA,
    54         SampledTexelFormatBGRA,
    55         SampledTexelFormatInvalid,
    56     };
    57     // Returns the orientation of the texture uploaded by this interface.
    58     virtual Orientation orientation() = 0;
    59     // Returns the format of the texel uploaded by this interface.
    60     // This format should not be confused by texture internal format.
    61     // This format specifies the component order in the sampled texel.
    62     // If the format is TexelFormatBGRA, vec4.x is blue and vec4.z is red.
    63     virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0;
    64     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0;
    65     virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
     51
     52    static PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> create(PassOwnPtr<LayerPainterChromium>);
     53    virtual ~FrameBufferSkPictureCanvasLayerTextureUpdater();
     54
     55    virtual PassRefPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*);
     56    virtual Orientation orientation() { return LayerTextureUpdater::TopDownOrientation; }
     57    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat);
     58    void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
     59
     60private:
     61    explicit FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);
    6662};
    67 
    6863} // namespace WebCore
     64#endif // USE(SKIA)
    6965#endif // USE(ACCELERATED_COMPOSITING)
    70 #endif // LayerTextureUpdater_h
     66#endif // FrameBufferSkPictureCanvasLayerTextureUpdater_h
  • trunk/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

    r98055 r99813  
    4747class ImageLayerTextureUpdater : public LayerTextureUpdater {
    4848public:
     49    class Texture : public LayerTextureUpdater::Texture {
     50    public:
     51        Texture(ImageLayerTextureUpdater* textureUpdater, PassOwnPtr<ManagedTexture> texture)
     52            : LayerTextureUpdater::Texture(texture)
     53            , m_textureUpdater(textureUpdater)
     54        {
     55        }
     56
     57        virtual void updateRect(GraphicsContext3D* context, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect)
     58        {
     59            textureUpdater()->updateTextureRect(context, allocator, texture(), sourceRect, destRect);
     60        }
     61
     62    private:
     63        ImageLayerTextureUpdater* textureUpdater() { return m_textureUpdater; }
     64
     65        ImageLayerTextureUpdater* m_textureUpdater;
     66    };
     67
    4968    static PassRefPtr<ImageLayerTextureUpdater> create(bool useMapTexSubImage)
    5069    {
     
    5372
    5473    virtual ~ImageLayerTextureUpdater() { }
     74
     75    virtual PassRefPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager)
     76    {
     77        return adoptRef(new Texture(this, ManagedTexture::create(manager)));
     78    }
    5579
    5680    virtual Orientation orientation() { return LayerTextureUpdater::BottomUpOrientation; }
     
    6286    }
    6387
    64     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int /* borderTexels */)
     88    virtual void prepareToUpdate(const IntRect& /* contentRect */, const IntSize& tileSize, int /* borderTexels */)
    6589    {
    6690        m_texSubImage.setSubImageSize(tileSize);
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r99774 r99813  
    3636
    3737#include "Canvas2DLayerChromium.h"
     38#include "CanvasLayerTextureUpdater.h"
    3839#include "Extensions3DChromium.h"
    3940#include "FloatQuad.h"
     
    4243#include "LayerChromium.h"
    4344#include "LayerPainterChromium.h"
    44 #include "LayerTextureUpdaterCanvas.h"
    4545#include "ManagedTexture.h"
    4646#include "NonCompositedContentHost.h"
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h

    r96186 r99813  
    3030#if USE(ACCELERATED_COMPOSITING)
    3131
     32#include "ManagedTexture.h"
    3233#include "GraphicsTypes3D.h"
    3334#include <wtf/RefCounted.h>
     
    3839class IntRect;
    3940class IntSize;
    40 class ManagedTexture;
    4141class TextureAllocator;
     42class TextureManager;
    4243
    4344class LayerTextureUpdater : public RefCounted<LayerTextureUpdater> {
    4445public:
     46    // Allows texture uploaders to store per-tile resources.
     47    class Texture : public RefCounted<Texture> {
     48    public:
     49        virtual ~Texture() { }
     50
     51        ManagedTexture* texture() { return m_texture.get(); }
     52        virtual void prepareRect(const IntRect& /* sourceRect */) { }
     53        virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect& sourceRect, const IntRect& destRect) = 0;
     54    protected:
     55        explicit Texture(PassOwnPtr<ManagedTexture> texture) : m_texture(texture) { }
     56
     57    private:
     58        OwnPtr<ManagedTexture> m_texture;
     59    };
     60
    4561    virtual ~LayerTextureUpdater() { }
    4662
     
    5571        SampledTexelFormatInvalid,
    5672    };
     73    virtual PassRefPtr<Texture> createTexture(TextureManager*) = 0;
    5774    // Returns the orientation of the texture uploaded by this interface.
    5875    virtual Orientation orientation() = 0;
     
    6279    // If the format is TexelFormatBGRA, vec4.x is blue and vec4.z is red.
    6380    virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) = 0;
    64     virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels) = 0;
    65     virtual void updateTextureRect(GraphicsContext3D*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect) = 0;
     81    virtual void prepareToUpdate(const IntRect& /* contentRect */, const IntSize& /* tileSize */, int /* borderTexels */) { }
    6682};
    6783
  • trunk/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.cpp

    r99812 r99813  
    2424 */
    2525
    26 #ifndef CCTextureUpdater_h
    27 #define CCTextureUpdater_h
    2826
    29 #include "IntRect.h"
    30 #include <wtf/Vector.h>
     27#include "config.h"
     28
     29#if USE(ACCELERATED_COMPOSITING)
     30#if USE(SKIA)
     31
     32#include "SkPictureCanvasLayerTextureUpdater.h"
     33
     34#include "GraphicsContext.h"
     35#include "LayerPainterChromium.h"
     36#include "PlatformContextSkia.h"
     37#include "SkCanvas.h"
     38#include "TraceEvent.h"
    3139
    3240namespace WebCore {
    3341
    34 class GraphicsContext3D;
    35 class LayerTextureUpdater;
    36 class ManagedTexture;
    37 class TextureAllocator;
    38 
    39 class CCTextureUpdater {
    40 public:
    41     CCTextureUpdater(TextureAllocator*);
    42     ~CCTextureUpdater();
    43 
    44     void append(ManagedTexture*, LayerTextureUpdater*, const IntRect& sourceRect, const IntRect& destRect);
    45 
    46     bool hasMoreUpdates() const;
    47 
    48     // Update some textures. Returns true if more textures left to process.
    49     bool update(GraphicsContext3D*, size_t count);
    50 
    51     void clear();
    52 
    53     TextureAllocator* allocator() { return m_allocator; }
    54 
    55 private:
    56     struct UpdateEntry {
    57         ManagedTexture* m_texture;
    58         LayerTextureUpdater* m_updater;
    59         IntRect m_sourceRect;
    60         IntRect m_destRect;
    61     };
    62 
    63     TextureAllocator* m_allocator;
    64     size_t m_entryIndex;
    65     Vector<UpdateEntry> m_entries;
    66 };
    67 
     42SkPictureCanvasLayerTextureUpdater::SkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
     43    : CanvasLayerTextureUpdater(painter)
     44{
    6845}
    6946
    70 #endif // CCTextureUpdater_h
     47SkPictureCanvasLayerTextureUpdater::~SkPictureCanvasLayerTextureUpdater()
     48{
     49}
     50
     51void SkPictureCanvasLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize& /* tileSize */, int /* borderTexels */)
     52{
     53    SkCanvas* canvas = m_picture.beginRecording(contentRect.width(), contentRect.height());
     54    PlatformContextSkia platformContext(canvas);
     55    GraphicsContext graphicsContext(&platformContext);
     56    paintContents(graphicsContext, contentRect);
     57    m_picture.endRecording();
     58}
     59
     60void SkPictureCanvasLayerTextureUpdater::drawPicture(SkCanvas* canvas)
     61{
     62    TRACE_EVENT("SkPictureCanvasLayerTextureUpdater::drawPicture", this, 0);
     63    canvas->drawPicture(m_picture);
     64}
     65
     66} // namespace WebCore
     67#endif // USE(SKIA)
     68#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/chromium/SkPictureCanvasLayerTextureUpdater.h

    r99812 r99813  
    2424 */
    2525
    26 #ifndef CCTextureUpdater_h
    27 #define CCTextureUpdater_h
    2826
    29 #include "IntRect.h"
    30 #include <wtf/Vector.h>
     27#ifndef SkPictureCanvasLayerTextureUpdater_h
     28#define SkPictureCanvasLayerTextureUpdater_h
     29
     30#if USE(ACCELERATED_COMPOSITING)
     31#if USE(SKIA)
     32
     33#include "CanvasLayerTextureUpdater.h"
     34#include "SkPicture.h"
     35
     36class SkCanvas;
    3137
    3238namespace WebCore {
    3339
    34 class GraphicsContext3D;
    35 class LayerTextureUpdater;
    36 class ManagedTexture;
    37 class TextureAllocator;
     40class LayerPainterChromium;
    3841
    39 class CCTextureUpdater {
     42class SkPictureCanvasLayerTextureUpdater : public CanvasLayerTextureUpdater {
    4043public:
    41     CCTextureUpdater(TextureAllocator*);
    42     ~CCTextureUpdater();
     44    virtual ~SkPictureCanvasLayerTextureUpdater();
    4345
    44     void append(ManagedTexture*, LayerTextureUpdater*, const IntRect& sourceRect, const IntRect& destRect);
     46protected:
     47    explicit SkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);
    4548
    46     bool hasMoreUpdates() const;
    47 
    48     // Update some textures. Returns true if more textures left to process.
    49     bool update(GraphicsContext3D*, size_t count);
    50 
    51     void clear();
    52 
    53     TextureAllocator* allocator() { return m_allocator; }
     49    virtual void prepareToUpdate(const IntRect& contentRect, const IntSize& tileSize, int borderTexels);
     50    void drawPicture(SkCanvas*);
    5451
    5552private:
    56     struct UpdateEntry {
    57         ManagedTexture* m_texture;
    58         LayerTextureUpdater* m_updater;
    59         IntRect m_sourceRect;
    60         IntRect m_destRect;
    61     };
    62 
    63     TextureAllocator* m_allocator;
    64     size_t m_entryIndex;
    65     Vector<UpdateEntry> m_entries;
     53    SkPicture m_picture; // Recording canvas.
    6654};
    6755
    68 }
    69 
    70 #endif // CCTextureUpdater_h
     56} // namespace WebCore
     57#endif // USE(SKIA)
     58#endif // USE(ACCELERATED_COMPOSITING)
     59#endif // SkPictureCanvasLayerTextureUpdater_h
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r98360 r99813  
    5252    WTF_MAKE_NONCOPYABLE(UpdatableTile);
    5353public:
    54     explicit UpdatableTile(PassOwnPtr<ManagedTexture> tex) : m_tex(tex) { }
    55 
    56     ManagedTexture* texture() { return m_tex.get(); }
     54    explicit UpdatableTile(PassRefPtr<LayerTextureUpdater::Texture> texture) : m_texture(texture) { }
     55
     56    LayerTextureUpdater::Texture* texture() { return m_texture.get(); }
     57    ManagedTexture* managedTexture() { return m_texture->texture(); }
    5758
    5859    bool dirty() const { return !m_dirtyLayerRect.isEmpty(); }
     
    6162    // Layer-space dirty rectangle that needs to be repainted.
    6263    IntRect m_dirtyLayerRect;
     64    // Content-space rectangle that needs to be updated.
     65    IntRect m_updateRect;
    6366private:
    64     OwnPtr<ManagedTexture> m_tex;
     67    RefPtr<LayerTextureUpdater::Texture> m_texture;
    6568};
    6669
     
    168171                continue;
    169172
    170             // Calculate page-space rectangle to copy from.
    171             IntRect sourceRect = m_tiler->tileContentRect(tile);
    172             const IntPoint anchor = sourceRect.location();
    173             sourceRect.intersect(m_tiler->layerRectToContentRect(tile->m_dirtyLayerRect));
    174             // Paint rect not guaranteed to line up on tile boundaries, so
    175             // make sure that sourceRect doesn't extend outside of it.
    176             sourceRect.intersect(m_paintRect);
    177             if (sourceRect.isEmpty())
    178                 continue;
    179 
    180             ASSERT(tile->texture()->isReserved());
     173            IntRect sourceRect = tile->m_updateRect;
     174            if (tile->m_updateRect.isEmpty())
     175                continue;
     176
     177            ASSERT(tile->managedTexture()->isReserved());
     178            const IntPoint anchor = m_tiler->tileContentRect(tile).location();
    181179
    182180            // Calculate tile-space rectangle to upload into.
     
    198196                CRASH();
    199197
    200             tile->texture()->bindTexture(context, updater.allocator());
     198            tile->managedTexture()->bindTexture(context, updater.allocator());
    201199            const GC3Dint filter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
    202200            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
    203201            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
    204202
    205             updater.append(tile->texture(), textureUpdater(), sourceRect, destRect);
     203            updater.append(tile->texture(), sourceRect, destRect);
    206204            tile->clearDirty();
    207205        }
     
    241239        int j = iter->first.second;
    242240        UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get());
    243         if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat))
     241        if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat))
    244242            continue;
    245243
    246         tiledLayer->syncTextureId(i, j, tile->texture()->textureId());
     244        tiledLayer->syncTextureId(i, j, tile->managedTexture()->textureId());
    247245    }
    248246}
     
    262260UpdatableTile* TiledLayerChromium::createTile(int i, int j)
    263261{
    264     RefPtr<UpdatableTile> tile = adoptRef(new UpdatableTile(ManagedTexture::create(textureManager())));
     262    RefPtr<UpdatableTile> tile = adoptRef(new UpdatableTile(textureUpdater()->createTexture(textureManager())));
    265263    m_tiler->addTile(tile, i, j);
    266264    tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile.get());
     
    310308        for (int i = left; i <= right; ++i) {
    311309            UpdatableTile* tile = tileAt(i, j);
    312             if (!tile || !tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat))
    313                 continue;
    314 
    315             tile->texture()->reserve(m_tiler->tileSize(), m_textureFormat);
     310            if (!tile || !tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat))
     311                continue;
     312
     313            tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat);
    316314        }
    317315    }
     
    347345                tile = createTile(i, j);
    348346
    349             if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat))
     347            if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat))
    350348                tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile);
    351349
    352             if (!tile->texture()->reserve(m_tiler->tileSize(), m_textureFormat)) {
     350            if (!tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat)) {
    353351                m_skipsDraw = true;
    354352                cleanupResources();
     
    375373    RefPtr<LayerTextureUpdater> protector(textureUpdater());
    376374    textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels());
     375
     376    m_tiler->contentRectToTileIndices(m_requestedUpdateRect, left, top, right, bottom);
     377    for (int j = top; j <= bottom; ++j) {
     378        for (int i = left; i <= right; ++i) {
     379            UpdatableTile* tile = tileAt(i, j);
     380            if (!tile)
     381                tile = createTile(i, j);
     382            else if (!tile->dirty())
     383                continue;
     384
     385            // Calculate content-space rectangle to copy from.
     386            IntRect sourceRect = m_tiler->tileContentRect(tile);
     387            const IntPoint anchor = sourceRect.location();
     388            sourceRect.intersect(m_tiler->layerRectToContentRect(tile->m_dirtyLayerRect));
     389            // Paint rect not guaranteed to line up on tile boundaries, so
     390            // make sure that sourceRect doesn't extend outside of it.
     391            sourceRect.intersect(m_paintRect);
     392
     393            tile->m_updateRect = sourceRect;
     394            if (sourceRect.isEmpty())
     395                continue;
     396
     397            tile->texture()->prepareRect(sourceRect);
     398        }
     399    }
    377400}
    378401
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp

    r98915 r99813  
    4949}
    5050
    51 void CCTextureUpdater::append(ManagedTexture* texture, LayerTextureUpdater* updater, const IntRect& sourceRect, const IntRect& destRect)
     51void CCTextureUpdater::append(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect)
    5252{
    5353    ASSERT(texture);
    54     ASSERT(updater);
    5554
    5655    UpdateEntry entry;
    5756    entry.m_texture = texture;
    58     entry.m_updater = updater;
    5957    entry.m_sourceRect = sourceRect;
    6058    entry.m_destRect = destRect;
     
    7270    for (; m_entryIndex < maxIndex; ++m_entryIndex) {
    7371        UpdateEntry& entry = m_entries[m_entryIndex];
    74         entry.m_updater->updateTextureRect(context, m_allocator, entry.m_texture, entry.m_sourceRect, entry.m_destRect);
     72        entry.m_texture->updateRect(context, m_allocator, entry.m_sourceRect, entry.m_destRect);
    7573    }
    7674
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h

    r98915 r99813  
    2828
    2929#include "IntRect.h"
     30#include "LayerTextureUpdater.h"
    3031#include <wtf/Vector.h>
    3132
     
    3334
    3435class GraphicsContext3D;
    35 class LayerTextureUpdater;
    36 class ManagedTexture;
    3736class TextureAllocator;
    3837
     
    4241    ~CCTextureUpdater();
    4342
    44     void append(ManagedTexture*, LayerTextureUpdater*, const IntRect& sourceRect, const IntRect& destRect);
     43    void append(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect);
    4544
    4645    bool hasMoreUpdates() const;
     
    5554private:
    5655    struct UpdateEntry {
    57         ManagedTexture* m_texture;
    58         LayerTextureUpdater* m_updater;
     56        LayerTextureUpdater::Texture* m_texture;
    5957        IntRect m_sourceRect;
    6058        IntRect m_destRect;
Note: See TracChangeset for help on using the changeset viewer.