Changeset 142366 in webkit


Ignore:
Timestamp:
Feb 9, 2013 10:15:14 AM (11 years ago)
Author:
rafael.lobo@openbossa.org
Message:

[TexMap] Separate classes per file in TextureMapperBackingStore.h
https://bugs.webkit.org/show_bug.cgi?id=109333

Reviewed by Noam Rosenthal.

TextureMapperBackingStore.h had the classes TextureMapperBackingStore,
TextureMapperTiledBackingStore, TextureMapperSurfaceBackingStore and
TextureMapperTile which was quite confusing. Now each one has its
own header and its own source file.

No new tests needed, refactoring only.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • platform/graphics/texmap/GraphicsLayerTextureMapper.h:
  • platform/graphics/texmap/TextureMapperBackingStore.cpp:
  • platform/graphics/texmap/TextureMapperBackingStore.h:
  • platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp: Added.

(WebCore):
(WebCore::TextureMapperSurfaceBackingStore::setGraphicsSurface):
(WebCore::TextureMapperSurfaceBackingStore::swapBuffersIfNeeded):
(WebCore::TextureMapperSurfaceBackingStore::texture):
(WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):

  • platform/graphics/texmap/TextureMapperSurfaceBackingStore.h: Added.

(WebCore):
(TextureMapperSurfaceBackingStore):
(WebCore::TextureMapperSurfaceBackingStore::create):
(WebCore::TextureMapperSurfaceBackingStore::~TextureMapperSurfaceBackingStore):
(WebCore::TextureMapperSurfaceBackingStore::TextureMapperSurfaceBackingStore):

  • platform/graphics/texmap/TextureMapperTile.cpp: Added.

(WebCore):
(WebCore::TextureMapperTile::updateContents):
(WebCore::TextureMapperTile::paint):

  • platform/graphics/texmap/TextureMapperTile.h: Added.

(WebCore):
(TextureMapperTile):
(WebCore::TextureMapperTile::texture):
(WebCore::TextureMapperTile::rect):
(WebCore::TextureMapperTile::setTexture):
(WebCore::TextureMapperTile::setRect):
(WebCore::TextureMapperTile::~TextureMapperTile):
(WebCore::TextureMapperTile::TextureMapperTile):

  • platform/graphics/texmap/TextureMapperTiledBackingStore.cpp: Copied from Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp.

(WebCore):
(WebCore::TextureMapperTiledBackingStore::TextureMapperTiledBackingStore):
(WebCore::TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded):
(WebCore::TextureMapperTiledBackingStore::adjustedTransformForRect):
(WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
(WebCore::TextureMapperTiledBackingStore::drawBorder):
(WebCore::TextureMapperTiledBackingStore::drawRepaintCounter):
(WebCore::TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded):
(WebCore::TextureMapperTiledBackingStore::updateContents):
(WebCore::TextureMapperTiledBackingStore::texture):

  • platform/graphics/texmap/TextureMapperTiledBackingStore.h: Added.

(WebCore):
(TextureMapperTiledBackingStore):
(WebCore::TextureMapperTiledBackingStore::create):
(WebCore::TextureMapperTiledBackingStore::~TextureMapperTiledBackingStore):
(WebCore::TextureMapperTiledBackingStore::setContentsToImage):
(WebCore::TextureMapperTiledBackingStore::rect):

  • platform/graphics/texmap/coordinated/CoordinatedBackingStore.h:
  • platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
Location:
trunk/Source/WebCore
Files:
5 added
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r142193 r142366  
    20172017    platform/graphics/texmap/TextureMapperImageBuffer.cpp
    20182018    platform/graphics/texmap/TextureMapperLayer.cpp
     2019    platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp
     2020    platform/graphics/texmap/TextureMapperTile.cpp
     2021    platform/graphics/texmap/TextureMapperTiledBackingStore.cpp
    20192022
    20202023    platform/graphics/transforms/AffineTransform.cpp
  • trunk/Source/WebCore/ChangeLog

    r142365 r142366  
     12013-02-09  Rafael Brandao  <rafael.lobo@openbossa.org>
     2
     3        [TexMap] Separate classes per file in TextureMapperBackingStore.h
     4        https://bugs.webkit.org/show_bug.cgi?id=109333
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        TextureMapperBackingStore.h had the classes TextureMapperBackingStore,
     9        TextureMapperTiledBackingStore, TextureMapperSurfaceBackingStore and
     10        TextureMapperTile which was quite confusing. Now each one has its
     11        own header and its own source file.
     12
     13        No new tests needed, refactoring only.
     14
     15        * CMakeLists.txt:
     16        * GNUmakefile.list.am:
     17        * Target.pri:
     18        * WebCore.gypi:
     19        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
     20        * platform/graphics/texmap/TextureMapperBackingStore.cpp:
     21        * platform/graphics/texmap/TextureMapperBackingStore.h:
     22        * platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp: Added.
     23        (WebCore):
     24        (WebCore::TextureMapperSurfaceBackingStore::setGraphicsSurface):
     25        (WebCore::TextureMapperSurfaceBackingStore::swapBuffersIfNeeded):
     26        (WebCore::TextureMapperSurfaceBackingStore::texture):
     27        (WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):
     28        * platform/graphics/texmap/TextureMapperSurfaceBackingStore.h: Added.
     29        (WebCore):
     30        (TextureMapperSurfaceBackingStore):
     31        (WebCore::TextureMapperSurfaceBackingStore::create):
     32        (WebCore::TextureMapperSurfaceBackingStore::~TextureMapperSurfaceBackingStore):
     33        (WebCore::TextureMapperSurfaceBackingStore::TextureMapperSurfaceBackingStore):
     34        * platform/graphics/texmap/TextureMapperTile.cpp: Added.
     35        (WebCore):
     36        (WebCore::TextureMapperTile::updateContents):
     37        (WebCore::TextureMapperTile::paint):
     38        * platform/graphics/texmap/TextureMapperTile.h: Added.
     39        (WebCore):
     40        (TextureMapperTile):
     41        (WebCore::TextureMapperTile::texture):
     42        (WebCore::TextureMapperTile::rect):
     43        (WebCore::TextureMapperTile::setTexture):
     44        (WebCore::TextureMapperTile::setRect):
     45        (WebCore::TextureMapperTile::~TextureMapperTile):
     46        (WebCore::TextureMapperTile::TextureMapperTile):
     47        * platform/graphics/texmap/TextureMapperTiledBackingStore.cpp: Copied from Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp.
     48        (WebCore):
     49        (WebCore::TextureMapperTiledBackingStore::TextureMapperTiledBackingStore):
     50        (WebCore::TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded):
     51        (WebCore::TextureMapperTiledBackingStore::adjustedTransformForRect):
     52        (WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
     53        (WebCore::TextureMapperTiledBackingStore::drawBorder):
     54        (WebCore::TextureMapperTiledBackingStore::drawRepaintCounter):
     55        (WebCore::TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded):
     56        (WebCore::TextureMapperTiledBackingStore::updateContents):
     57        (WebCore::TextureMapperTiledBackingStore::texture):
     58        * platform/graphics/texmap/TextureMapperTiledBackingStore.h: Added.
     59        (WebCore):
     60        (TextureMapperTiledBackingStore):
     61        (WebCore::TextureMapperTiledBackingStore::create):
     62        (WebCore::TextureMapperTiledBackingStore::~TextureMapperTiledBackingStore):
     63        (WebCore::TextureMapperTiledBackingStore::setContentsToImage):
     64        (WebCore::TextureMapperTiledBackingStore::rect):
     65        * platform/graphics/texmap/coordinated/CoordinatedBackingStore.h:
     66        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
     67
    1682013-02-09  Philip Rogers  <pdr@google.com>
    269
  • trunk/Source/WebCore/GNUmakefile.list.am

    r142193 r142366  
    64846484        Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp \
    64856485        Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h \
    6486         Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h
     6486        Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h \
     6487        Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp \
     6488        Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.h \
     6489        Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp \
     6490        Source/WebCore/platform/graphics/texmap/TextureMapperTile.h \
     6491        Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp \
     6492        Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h
    64876493endif  # END USE_TEXTURE_MAPPER_CAIRO
    64886494
     
    65096515        Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp \
    65106516        Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h \
    6511         Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h
     6517        Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h \
     6518        Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp \
     6519        Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.h \
     6520        Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp \
     6521        Source/WebCore/platform/graphics/texmap/TextureMapperTile.h \
     6522        Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp \
     6523        Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h
    65126524endif  # END USE_TEXTURE_MAPPER_GL
    65136525endif  # USE_ACCELERATED_COMPOSITING
  • trunk/Source/WebCore/Target.pri

    r142355 r142366  
    3131    Modules/geolocation/GeolocationController.cpp \
    3232    Modules/geolocation/NavigatorGeolocation.cpp \
    33     \
    3433    Modules/webdatabase/DOMWindowWebDatabase.cpp \
    3534    Modules/webdatabase/Database.cpp \
     
    4039    Modules/webdatabase/DatabaseSync.cpp \
    4140    Modules/webdatabase/WorkerContextWebDatabase.cpp \
    42     \
    4341    accessibility/AccessibilityImageMapLink.cpp \
    4442    accessibility/AccessibilityMediaControls.cpp \
     
    22712269    platform/graphics/texmap/TextureMapperLayer.h \
    22722270    platform/graphics/texmap/TextureMapperPlatformLayer.h \
     2271    platform/graphics/texmap/TextureMapperSurfaceBackingStore.h \
     2272    platform/graphics/texmap/TextureMapperTile.h \
     2273    platform/graphics/texmap/TextureMapperTiledBackingStore.h \
    22732274    platform/graphics/Tile.h \
    22742275    platform/graphics/TiledBackingStore.h \
     
    29052906    platform/graphics/texmap/TextureMapperImageBuffer.cpp \
    29062907    platform/graphics/texmap/TextureMapperLayer.cpp \
     2908    platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp \
     2909    platform/graphics/texmap/TextureMapperTile.cpp \
     2910    platform/graphics/texmap/TextureMapperTiledBackingStore.cpp \
    29072911    platform/network/DNSResolveQueue.cpp \
    29082912    platform/network/MIMESniffing.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r142193 r142366  
    41914191            'platform/graphics/texmap/TextureMapperLayer.h',
    41924192            'platform/graphics/texmap/TextureMapperPlatformLayer.h',
     4193            'platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp',
     4194            'platform/graphics/texmap/TextureMapperSurfaceBackingStore.h',
     4195            'platform/graphics/texmap/TextureMapperTile.cpp',
     4196            'platform/graphics/texmap/TextureMapperTile.h',
     4197            'platform/graphics/texmap/TextureMapperTiledBackingStore.cpp',
     4198            'platform/graphics/texmap/TextureMapperTiledBackingStore.h',
    41934199            'platform/graphics/transforms/IdentityTransformOperation.h',
    41944200            'platform/graphics/transforms/Matrix3DTransformOperation.cpp',
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h

    r141543 r142366  
    2525#include "Image.h"
    2626#include "TextureMapperLayer.h"
     27#include "TextureMapperTiledBackingStore.h"
    2728#include "Timer.h"
    2829
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp

    r141637 r142366  
    3434namespace WebCore {
    3535
    36 #if USE(GRAPHICS_SURFACE)
    37 void TextureMapperSurfaceBackingStore::setGraphicsSurface(PassRefPtr<GraphicsSurface> surface)
    38 {
    39     m_graphicsSurface = surface;
    40 }
    41 
    42 void TextureMapperSurfaceBackingStore::swapBuffersIfNeeded(uint32_t)
    43 {
    44     if (m_graphicsSurface)
    45         m_graphicsSurface->swapBuffers();
    46 }
    47 
    48 PassRefPtr<BitmapTexture> TextureMapperSurfaceBackingStore::texture() const
    49 {
    50     // FIXME: Instead of just returning an empty texture, we should wrap the texture contents into a BitmapTexture.
    51     RefPtr<BitmapTexture> emptyTexture;
    52     return emptyTexture;
    53 }
    54 
    55 void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
    56 {
    57     if (m_graphicsSurface)
    58         m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, transform, opacity, mask);
    59 }
    60 #endif
    61 
    62 void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
    63 {
    64     IntRect targetRect = enclosingIntRect(m_rect);
    65     targetRect.intersect(dirtyRect);
    66     if (targetRect.isEmpty())
    67         return;
    68     IntPoint sourceOffset = targetRect.location();
    69 
    70     // Normalize sourceRect to the buffer's coordinates.
    71     sourceOffset.move(-dirtyRect.x(), -dirtyRect.y());
    72 
    73     // Normalize targetRect to the texture's coordinates.
    74     targetRect.move(-m_rect.x(), -m_rect.y());
    75     if (!m_texture) {
    76         m_texture = textureMapper->createTexture();
    77         m_texture->reset(targetRect.size(), image->currentFrameKnownToBeOpaque() ? 0 : BitmapTexture::SupportsAlpha);
    78     }
    79 
    80     m_texture->updateContents(image, targetRect, sourceOffset, updateContentsFlag);
    81 }
    82 
    83 void TextureMapperTile::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
    84 {
    85     IntRect targetRect = enclosingIntRect(m_rect);
    86     targetRect.intersect(dirtyRect);
    87     if (targetRect.isEmpty())
    88         return;
    89     IntPoint sourceOffset = targetRect.location();
    90 
    91     // Normalize targetRect to the texture's coordinates.
    92     targetRect.move(-m_rect.x(), -m_rect.y());
    93 
    94     if (!m_texture) {
    95         m_texture = textureMapper->createTexture();
    96         m_texture->reset(targetRect.size(), BitmapTexture::SupportsAlpha);
    97     }
    98 
    99     m_texture->updateContents(textureMapper, sourceLayer, targetRect, sourceOffset, updateContentsFlag);
    100 }
    101 
    102 void TextureMapperTile::paint(TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, BitmapTexture* mask, const unsigned exposedEdges)
    103 {
    104     if (texture().get())
    105         textureMapper->drawTexture(*texture().get(), rect(), transform, opacity, mask, exposedEdges);
    106 }
    107 
    108 TextureMapperTiledBackingStore::TextureMapperTiledBackingStore()
    109 {
    110 }
    111 
    112 void TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded(TextureMapper* textureMapper)
    113 {
    114     if (!m_image)
    115         return;
    116 
    117     updateContents(textureMapper, m_image.get(), m_image->size(), m_image->rect(), BitmapTexture::UpdateCannotModifyOriginalImageData);
    118     m_image.clear();
    119 }
    120 
    12136unsigned TextureMapperBackingStore::calculateExposedTileEdges(const FloatRect& totalRect, const FloatRect& tileRect)
    12237{
     
    13348}
    13449
    135 TransformationMatrix TextureMapperTiledBackingStore::adjustedTransformForRect(const FloatRect& targetRect)
    136 {
    137     return TransformationMatrix::rectToRect(rect(), targetRect);
    138 }
    139 
    140 void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
    141 {
    142     updateContentsFromImageIfNeeded(textureMapper);
    143     TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
    144     for (size_t i = 0; i < m_tiles.size(); ++i)
    145         m_tiles[i].paint(textureMapper, adjustedTransform, opacity, mask, calculateExposedTileEdges(rect(), m_tiles[i].rect()));
    146 }
    147 
    148 void TextureMapperTiledBackingStore::drawBorder(TextureMapper* textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
    149 {
    150     TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
    151     for (size_t i = 0; i < m_tiles.size(); ++i)
    152         textureMapper->drawBorder(borderColor, borderWidth, m_tiles[i].rect(), adjustedTransform);
    153 }
    154 
    155 void TextureMapperTiledBackingStore::drawRepaintCounter(TextureMapper* textureMapper, int repaintCount, const Color& borderColor, const FloatRect& targetRect, const TransformationMatrix& transform)
    156 {
    157     TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
    158     for (size_t i = 0; i < m_tiles.size(); ++i)
    159         textureMapper->drawRepaintCounter(repaintCount, borderColor, m_tiles[i].rect().location(), adjustedTransform);
    160 }
    161 
    162 void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatSize& size, const IntSize& tileSize, bool hasAlpha)
    163 {
    164     if (size == m_size)
    165         return;
    166 
    167     m_size = size;
    168 
    169     Vector<FloatRect> tileRectsToAdd;
    170     Vector<int> tileIndicesToRemove;
    171     static const size_t TileEraseThreshold = 6;
    172 
    173     // This method recycles tiles. We check which tiles we need to add, which to remove, and use as many
    174     // removable tiles as replacement for new tiles when possible.
    175     for (float y = 0; y < m_size.height(); y += tileSize.height()) {
    176         for (float x = 0; x < m_size.width(); x += tileSize.width()) {
    177             FloatRect tileRect(x, y, tileSize.width(), tileSize.height());
    178             tileRect.intersect(rect());
    179             tileRectsToAdd.append(tileRect);
    180         }
    181     }
    182 
    183     // Check which tiles need to be removed, and which already exist.
    184     for (int i = m_tiles.size() - 1; i >= 0; --i) {
    185         FloatRect oldTile = m_tiles[i].rect();
    186         bool existsAlready = false;
    187 
    188         for (int j = tileRectsToAdd.size() - 1; j >= 0; --j) {
    189             FloatRect newTile = tileRectsToAdd[j];
    190             if (oldTile != newTile)
    191                 continue;
    192 
    193             // A tile that we want to add already exists, no need to add or remove it.
    194             existsAlready = true;
    195             tileRectsToAdd.remove(j);
    196             break;
    197         }
    198 
    199         // This tile is not needed.
    200         if (!existsAlready)
    201             tileIndicesToRemove.append(i);
    202     }
    203 
    204     // Recycle removable tiles to be used for newly requested tiles.
    205     for (size_t i = 0; i < tileRectsToAdd.size(); ++i) {
    206         if (!tileIndicesToRemove.isEmpty()) {
    207             // We recycle an existing tile for usage with a new tile rect.
    208             TextureMapperTile& tile = m_tiles[tileIndicesToRemove.last()];
    209             tileIndicesToRemove.removeLast();
    210             tile.setRect(tileRectsToAdd[i]);
    211 
    212             if (tile.texture())
    213                 tile.texture()->reset(enclosingIntRect(tile.rect()).size(), hasAlpha ? BitmapTexture::SupportsAlpha : 0);
    214             continue;
    215         }
    216 
    217         m_tiles.append(TextureMapperTile(tileRectsToAdd[i]));
    218     }
    219 
    220     // Remove unnecessary tiles, if they weren't recycled.
    221     // We use a threshold to make sure we don't create/destroy tiles too eagerly.
    222     for (size_t i = 0; i < tileIndicesToRemove.size() && m_tiles.size() > TileEraseThreshold; ++i)
    223         m_tiles.remove(tileIndicesToRemove[i]);
    224 }
    225 
    226 void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
    227 {
    228     createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), !image->currentFrameKnownToBeOpaque());
    229     for (size_t i = 0; i < m_tiles.size(); ++i)
    230         m_tiles[i].updateContents(textureMapper, image, dirtyRect, updateContentsFlag);
    231 }
    232 
    233 void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
    234 {
    235     createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), true);
    236     for (size_t i = 0; i < m_tiles.size(); ++i)
    237         m_tiles[i].updateContents(textureMapper, sourceLayer, dirtyRect, updateContentsFlag);
    238 }
    239 
    240 PassRefPtr<BitmapTexture> TextureMapperTiledBackingStore::texture() const
    241 {
    242     for (size_t i = 0; i < m_tiles.size(); ++i) {
    243         RefPtr<BitmapTexture> texture = m_tiles[i].texture();
    244         if (texture)
    245             return texture;
    246     }
    247 
    248     return PassRefPtr<BitmapTexture>();
    249 }
    250 
    25150}
    25251#endif
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h

    r140821 r142366  
    4444    virtual ~TextureMapperBackingStore() { }
    4545
    46 
    4746protected:
    4847    static unsigned calculateExposedTileEdges(const FloatRect& totalRect, const FloatRect& tileRect);
    49 };
    50 
    51 #if USE(GRAPHICS_SURFACE)
    52 class TextureMapperSurfaceBackingStore : public TextureMapperBackingStore {
    53 public:
    54     static PassRefPtr<TextureMapperSurfaceBackingStore> create() { return adoptRef(new TextureMapperSurfaceBackingStore); }
    55     void setGraphicsSurface(PassRefPtr<GraphicsSurface>);
    56     void swapBuffersIfNeeded(uint32_t frontBuffer);
    57     virtual PassRefPtr<BitmapTexture> texture() const;
    58     virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
    59     virtual ~TextureMapperSurfaceBackingStore() { }
    60 
    61 private:
    62     TextureMapperSurfaceBackingStore()
    63         : TextureMapperBackingStore()
    64         { }
    65 
    66     RefPtr<GraphicsSurface> m_graphicsSurface;
    67 };
    68 #endif
    69 
    70 class TextureMapperTile {
    71 public:
    72     inline PassRefPtr<BitmapTexture> texture() const { return m_texture; }
    73     inline FloatRect rect() const { return m_rect; }
    74     inline void setTexture(BitmapTexture* texture) { m_texture = texture; }
    75     inline void setRect(const FloatRect& rect) { m_rect = rect; }
    76 
    77     void updateContents(TextureMapper*, Image*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
    78     void updateContents(TextureMapper*, GraphicsLayer*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
    79     virtual void paint(TextureMapper*, const TransformationMatrix&, float, BitmapTexture*, const unsigned exposedEdges);
    80     virtual ~TextureMapperTile() { }
    81 
    82     explicit TextureMapperTile(const FloatRect& rect)
    83         : m_rect(rect)
    84     {
    85     }
    86 
    87 private:
    88     RefPtr<BitmapTexture> m_texture;
    89     FloatRect m_rect;
    90 };
    91 
    92 class TextureMapperTiledBackingStore : public TextureMapperBackingStore {
    93 public:
    94     static PassRefPtr<TextureMapperTiledBackingStore> create() { return adoptRef(new TextureMapperTiledBackingStore); }
    95     virtual ~TextureMapperTiledBackingStore() { }
    96 
    97     virtual PassRefPtr<BitmapTexture> texture() const OVERRIDE;
    98     virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE;
    99     virtual void drawBorder(TextureMapper*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
    100     virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) OVERRIDE;
    101     void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
    102     void updateContents(TextureMapper*, GraphicsLayer*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
    103 
    104     void setContentsToImage(Image* image) { m_image = image; }
    105 
    106 private:
    107     TextureMapperTiledBackingStore();
    108     void createOrDestroyTilesIfNeeded(const FloatSize& backingStoreSize, const IntSize& tileSize, bool hasAlpha);
    109     void updateContentsFromImageIfNeeded(TextureMapper*);
    110     TransformationMatrix adjustedTransformForRect(const FloatRect&);
    111     inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
    112 
    113     Vector<TextureMapperTile> m_tiles;
    114     FloatSize m_size;
    115     RefPtr<Image> m_image;
    11648};
    11749
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp

    r142365 r142366  
    2121
    2222#if USE(ACCELERATED_COMPOSITING)
    23 #include "TextureMapperBackingStore.h"
     23#include "TextureMapperTiledBackingStore.h"
    2424
    25 #include "GraphicsLayer.h"
    2625#include "ImageBuffer.h"
    2726#include "TextureMapper.h"
    2827
    29 #if USE(GRAPHICS_SURFACE)
    30 #include "GraphicsSurface.h"
    31 #include "TextureMapperGL.h"
    32 #endif
    33 
    3428namespace WebCore {
    3529
    36 #if USE(GRAPHICS_SURFACE)
    37 void TextureMapperSurfaceBackingStore::setGraphicsSurface(PassRefPtr<GraphicsSurface> surface)
    38 {
    39     m_graphicsSurface = surface;
    40 }
    41 
    42 void TextureMapperSurfaceBackingStore::swapBuffersIfNeeded(uint32_t)
    43 {
    44     if (m_graphicsSurface)
    45         m_graphicsSurface->swapBuffers();
    46 }
    47 
    48 PassRefPtr<BitmapTexture> TextureMapperSurfaceBackingStore::texture() const
    49 {
    50     // FIXME: Instead of just returning an empty texture, we should wrap the texture contents into a BitmapTexture.
    51     RefPtr<BitmapTexture> emptyTexture;
    52     return emptyTexture;
    53 }
    54 
    55 void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
    56 {
    57     if (m_graphicsSurface)
    58         m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, transform, opacity, mask);
    59 }
    60 #endif
    61 
    62 void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
    63 {
    64     IntRect targetRect = enclosingIntRect(m_rect);
    65     targetRect.intersect(dirtyRect);
    66     if (targetRect.isEmpty())
    67         return;
    68     IntPoint sourceOffset = targetRect.location();
    69 
    70     // Normalize sourceRect to the buffer's coordinates.
    71     sourceOffset.move(-dirtyRect.x(), -dirtyRect.y());
    72 
    73     // Normalize targetRect to the texture's coordinates.
    74     targetRect.move(-m_rect.x(), -m_rect.y());
    75     if (!m_texture) {
    76         m_texture = textureMapper->createTexture();
    77         m_texture->reset(targetRect.size(), image->currentFrameKnownToBeOpaque() ? 0 : BitmapTexture::SupportsAlpha);
    78     }
    79 
    80     m_texture->updateContents(image, targetRect, sourceOffset, updateContentsFlag);
    81 }
    82 
    83 void TextureMapperTile::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
    84 {
    85     IntRect targetRect = enclosingIntRect(m_rect);
    86     targetRect.intersect(dirtyRect);
    87     if (targetRect.isEmpty())
    88         return;
    89     IntPoint sourceOffset = targetRect.location();
    90 
    91     // Normalize targetRect to the texture's coordinates.
    92     targetRect.move(-m_rect.x(), -m_rect.y());
    93 
    94     if (!m_texture) {
    95         m_texture = textureMapper->createTexture();
    96         m_texture->reset(targetRect.size(), BitmapTexture::SupportsAlpha);
    97     }
    98 
    99     m_texture->updateContents(textureMapper, sourceLayer, targetRect, sourceOffset, updateContentsFlag);
    100 }
    101 
    102 void TextureMapperTile::paint(TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, BitmapTexture* mask, const unsigned exposedEdges)
    103 {
    104     if (texture().get())
    105         textureMapper->drawTexture(*texture().get(), rect(), transform, opacity, mask, exposedEdges);
    106 }
     30class GraphicsLayer;
    10731
    10832TextureMapperTiledBackingStore::TextureMapperTiledBackingStore()
     
    11741    updateContents(textureMapper, m_image.get(), m_image->size(), m_image->rect(), BitmapTexture::UpdateCannotModifyOriginalImageData);
    11842    m_image.clear();
    119 }
    120 
    121 unsigned TextureMapperBackingStore::calculateExposedTileEdges(const FloatRect& totalRect, const FloatRect& tileRect)
    122 {
    123     unsigned exposedEdges = TextureMapper::NoEdges;
    124     if (!tileRect.x())
    125         exposedEdges |= TextureMapper::LeftEdge;
    126     if (!tileRect.y())
    127         exposedEdges |= TextureMapper::TopEdge;
    128     if (tileRect.width() + tileRect.x() >= totalRect.width())
    129         exposedEdges |= TextureMapper::RightEdge;
    130     if (tileRect.height() + tileRect.y() >= totalRect.height())
    131         exposedEdges |= TextureMapper::BottomEdge;
    132     return exposedEdges;
    13343}
    13444
     
    249159}
    250160
    251 }
     161} // namespace WebCore
    252162#endif
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.h

    r141543 r142366  
    2525#include "TextureMapper.h"
    2626#include "TextureMapperBackingStore.h"
     27#include "TextureMapperTile.h"
    2728#include <wtf/HashMap.h>
    2829#include <wtf/HashSet.h>
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h

    r141543 r142366  
    3838#include <wtf/ThreadingPrimitives.h>
    3939#include <wtf/Vector.h>
     40
     41#if USE(GRAPHICS_SURFACE)
     42#include "TextureMapperSurfaceBackingStore.h"
     43#endif
    4044
    4145namespace WebCore {
Note: See TracChangeset for help on using the changeset viewer.