| Differences between
and this patch
- a/Source/WebCore/ChangeLog +56 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2013-03-14  NĂ¡ndor Huszka  <hnandor@inf.u-szeged.hu>
2
3
        [WK2] TiledBackingStore: invisible GIFs are animated
4
        https://bugs.webkit.org/show_bug.cgi?id=112327
5
6
        The patch stops painting invisible animations, and restart drawing them when they are visible again. 
7
        How it works:
8
9
        1. before painting (in BitmapImage::draw) an animated BitmapImage asks TiledBackingStore 
10
           whether it is visible (TiledBackingStore::isVisible)
11
             - yes: paint it
12
             - no: do not paint it
13
14
        2. TBS remembers an invisible animated image (TiledBackingStore::savePseudoDirtyRect)
15
             - splits image's rect between tiles
16
             - every tile save the appropriate slice of image rect (Tile::savePseudoDirtyRect)
17
18
        * image is visible again because of scrolling *
19
20
        3. (in coverWithTilesIfNeeded) TBS checks previously saved invisible animated images (optimizeDirtyRects)
21
             - every tile checks its own rect set (Tile::optimizeDirtyRect): stored rects (that are visible now) 
22
               will be united with dirty rect
23
24
        * every tiles' dirty rect will be repainted *
25
          => previously freezed but now visible animated images will be animated again *
26
27
        Reviewed by NOBODY (OOPS!).
28
29
        No new tests (OOPS!).
30
31
        * CMakeLists.txt:
32
        * Target.pri:
33
        * WebCore.gypi:
34
        * platform/graphics/Tile.cpp: Added.
35
        (WebCore):
36
        (WebCore::Tile::savePseudoDirtyRect):
37
        (WebCore::Tile::optimizeDirtyRect):
38
        * platform/graphics/Tile.h:
39
        (Tile):
40
        * platform/graphics/TiledBackingStore.cpp:
41
        (WebCore):
42
        (WebCore::TiledBackingStore::TiledBackingStore):
43
        (WebCore::TiledBackingStore::coverWithTilesIfNeeded):
44
        (WebCore::TiledBackingStore::optimizeDirtyRects):
45
        (WebCore::TiledBackingStore::isVisible):
46
        (WebCore::TiledBackingStore::savePseudoDirtyRect):
47
        * platform/graphics/TiledBackingStore.h:
48
        (TiledBackingStore):
49
        * platform/graphics/cairo/BitmapImageCairo.cpp:
50
        (WebCore):
51
        (WebCore::BitmapImage::draw):
52
        * platform/graphics/texmap/coordinated/CoordinatedTile.cpp:
53
        (WebCore::CoordinatedTile::CoordinatedTile):
54
        * platform/graphics/texmap/coordinated/CoordinatedTile.h:
55
        (CoordinatedTile):
56
1
2013-03-08  Huang Dongsung  <luxtella@company100.net>
57
2013-03-08  Huang Dongsung  <luxtella@company100.net>
2
58
3
        [EFL][Qt] REGRESSION(r144787): A fixed element lags when scrolling and wheeling.
59
        [EFL][Qt] REGRESSION(r144787): A fixed element lags when scrolling and wheeling.
- a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp -1 / +14 lines
Lines 31-39 a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp_sec1
31
#include "ImageObserver.h"
31
#include "ImageObserver.h"
32
#include "NativeImageCairo.h"
32
#include "NativeImageCairo.h"
33
#include "PlatformContextCairo.h"
33
#include "PlatformContextCairo.h"
34
#if USE(TILED_BACKING_STORE)
35
#include "TiledBackingStore.h"
36
#endif
34
#include <cairo.h>
37
#include <cairo.h>
35
38
36
namespace WebCore {
39
namespace WebCore {
40
#if USE(TILED_BACKING_STORE)
41
// FIXME: we should access TBS through Frame
42
extern TiledBackingStore* tbs;
43
#endif
37
44
38
PassRefPtr<BitmapImage> BitmapImage::create(cairo_surface_t* surface)
45
PassRefPtr<BitmapImage> BitmapImage::create(cairo_surface_t* surface)
39
{
46
{
Lines 81-87 void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp_sec2
81
{
88
{
82
    if (!dst.width() || !dst.height() || !src.width() || !src.height())
89
    if (!dst.width() || !dst.height() || !src.width() || !src.height())
83
        return;
90
        return;
84
91
#if USE(TILED_BACKING_STORE)
92
    bool visible = tbs->isVisible(dst);
93
    bool animated = (m_currentFrame > 0);
94
    // Do not paint an invisible animated image.
95
    if (!visible && animated)
96
        return;
97
#endif
85
    startAnimation();
98
    startAnimation();
86
99
87
    NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame);
100
    NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame);
- a/Source/WebCore/platform/graphics/TiledBackingStore.h +6 lines
Lines 23-28 a/Source/WebCore/platform/graphics/TiledBackingStore.h_sec1
23
#if USE(TILED_BACKING_STORE)
23
#if USE(TILED_BACKING_STORE)
24
24
25
#include "FloatPoint.h"
25
#include "FloatPoint.h"
26
#include "FloatRect.h"
26
#include "IntPoint.h"
27
#include "IntPoint.h"
27
#include "IntRect.h"
28
#include "IntRect.h"
28
#include "Tile.h"
29
#include "Tile.h"
Lines 80-85 public: a/Source/WebCore/platform/graphics/TiledBackingStore.h_sec2
80
81
81
    void setSupportsAlpha(bool);
82
    void setSupportsAlpha(bool);
82
83
84
    bool isVisible(const FloatRect&);
85
83
private:
86
private:
84
    void startTileBufferUpdateTimer();
87
    void startTileBufferUpdateTimer();
85
    void startBackingStoreUpdateTimer(double = 0);
88
    void startBackingStoreUpdateTimer(double = 0);
Lines 110-115 private: a/Source/WebCore/platform/graphics/TiledBackingStore.h_sec3
110
113
111
    void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coordinate&);
114
    void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coordinate&);
112
115
116
    void optimizeDirtyRects();
117
    void savePseudoDirtyRect(const FloatRect&);
118
113
private:
119
private:
114
    TiledBackingStoreClient* m_client;
120
    TiledBackingStoreClient* m_client;
115
    OwnPtr<TiledBackingStoreBackend> m_backend;
121
    OwnPtr<TiledBackingStoreBackend> m_backend;
- a/Source/WebCore/platform/graphics/TiledBackingStore.cpp +48 lines
Lines 28-33 a/Source/WebCore/platform/graphics/TiledBackingStore.cpp_sec1
28
namespace WebCore {
28
namespace WebCore {
29
29
30
static const int defaultTileDimension = 512;
30
static const int defaultTileDimension = 512;
31
// FIXME: for the time being we pass TBS to BitmapImage this way,
32
// but it should be accessed through Frame.
33
TiledBackingStore* tbs;
31
34
32
static IntPoint innerBottomRight(const IntRect& rect)
35
static IntPoint innerBottomRight(const IntRect& rect)
33
{
36
{
Lines 49-54 TiledBackingStore::TiledBackingStore(TiledBackingStoreClient* client, PassOwnPtr a/Source/WebCore/platform/graphics/TiledBackingStore.cpp_sec2
49
    , m_supportsAlpha(false)
52
    , m_supportsAlpha(false)
50
    , m_pendingTileCreation(false)
53
    , m_pendingTileCreation(false)
51
{
54
{
55
    // FIXME
56
    tbs = this;
52
}
57
}
53
58
54
TiledBackingStore::~TiledBackingStore()
59
TiledBackingStore::~TiledBackingStore()
Lines 73-83 void TiledBackingStore::coverWithTilesIfNeeded() a/Source/WebCore/platform/graphics/TiledBackingStore.cpp_sec3
73
    IntRect visibleRect = this->visibleRect();
78
    IntRect visibleRect = this->visibleRect();
74
    IntRect rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
79
    IntRect rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
75
80
81
    // Animations that became visible should be painted also.
82
    optimizeDirtyRects();
83
76
    bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != rect;
84
    bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != rect;
77
    if (didChange || m_pendingTileCreation)
85
    if (didChange || m_pendingTileCreation)
78
        createTiles();
86
        createTiles();
79
}
87
}
80
88
89
// Optimization: examine saved pseudo-dirty rects and if it is needed complete dirty rects with them.
90
void TiledBackingStore::optimizeDirtyRects()
91
{
92
    IntRect visibleRect = this->visibleRect();
93
94
    TileMap::iterator end = m_tiles.end();
95
    for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
96
        IntRect tileRect = it->value->rect();
97
        if (tileRect.intersects(visibleRect))
98
            it->value->optimizeDirtyRect(visibleRect);
99
    }
100
}
101
102
// In addition it can be used in order to avoid the painting of an invisible animation.
103
bool TiledBackingStore::isVisible(const FloatRect& rect)
104
{
105
    FloatRect visibleRect(m_visibleRect);
106
    if (visibleRect.intersects(rect))
107
        return true;
108
109
    // If rect is completely invisible, store it.
110
    savePseudoDirtyRect(rect);
111
112
    return false;
113
}
114
115
// This method makes sense when we call it with an invisible animation's rect.
116
// Pseudo-dirty rect: should only be painted before it becomes visible.
117
void TiledBackingStore::savePseudoDirtyRect(const FloatRect& rect)
118
{
119
    // Rect may intersect more tiles, so split it up between tiles.
120
    TileMap::iterator end = m_tiles.end();
121
    for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
122
        FloatRect tileRect = it->value->rect();
123
        FloatRect pseudoDirtyRectSlice = intersection(tileRect, rect);
124
        if (!pseudoDirtyRectSlice.isEmpty())
125
            it->value->savePseudoDirtyRect(pseudoDirtyRectSlice);
126
    }
127
}
128
81
void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect)
129
void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect)
82
{
130
{
83
    IntRect dirtyRect(mapFromContents(contentsDirtyRect));
131
    IntRect dirtyRect(mapFromContents(contentsDirtyRect));
- a/Source/WebCore/platform/graphics/Tile.h +12 lines
Lines 25-30 a/Source/WebCore/platform/graphics/Tile.h_sec1
25
#include "IntPoint.h"
25
#include "IntPoint.h"
26
#include "IntPointHash.h"
26
#include "IntPointHash.h"
27
#include "IntRect.h"
27
#include "IntRect.h"
28
#include "FloatRect.h"
28
#include <wtf/RefCounted.h>
29
#include <wtf/RefCounted.h>
29
30
30
namespace WebCore {
31
namespace WebCore {
Lines 47-52 public: a/Source/WebCore/platform/graphics/Tile.h_sec2
47
    virtual const Tile::Coordinate& coordinate() const = 0;
48
    virtual const Tile::Coordinate& coordinate() const = 0;
48
    virtual const IntRect& rect() const = 0;
49
    virtual const IntRect& rect() const = 0;
49
    virtual void resize(const WebCore::IntSize&) = 0;
50
    virtual void resize(const WebCore::IntSize&) = 0;
51
52
    void savePseudoDirtyRect(const FloatRect&);
53
    void optimizeDirtyRect(const IntRect&);
54
55
protected:
56
    // Moved from CoordinatedTile, because savePseudoDirtyRect and optimizeDirtyRect use it.
57
    IntRect m_dirtyRect;
58
59
private:
60
    // Stores rects that are not visible now, so we didn't paint them, but they may become visible later.
61
    Vector<FloatRect> m_pseudoDirtyRects;
50
};
62
};
51
63
52
}
64
}
- a/Source/WebCore/platform/graphics/Tile.cpp +61 lines
Line 0 a/Source/WebCore/platform/graphics/Tile.cpp_sec1
1
/*
2
 Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
3
4
 This library is free software; you can redistribute it and/or
5
 modify it under the terms of the GNU Library General Public
6
 License as published by the Free Software Foundation; either
7
 version 2 of the License, or (at your option) any later version.
8
9
 This library is distributed in the hope that it will be useful,
10
 but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 Library General Public License for more details.
13
14
 You should have received a copy of the GNU Library General Public License
15
 along with this library; see the file COPYING.LIB.  If not, write to
16
 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 Boston, MA 02110-1301, USA.
18
 */
19
20
#include "config.h"
21
22
#if USE(TILED_BACKING_STORE)
23
24
#include "Tile.h"
25
26
namespace WebCore {
27
28
// Puts a rect into m_pseudoDirtyRects.
29
void Tile::savePseudoDirtyRect(const FloatRect& rect)
30
{
31
    // If we have already saved a rect, don't save it.
32
    unsigned size = m_pseudoDirtyRects.size();
33
    for (unsigned n = 0; n < size; ++n) {
34
        if (m_pseudoDirtyRects[n].contains(rect))
35
            return;
36
    }
37
38
    m_pseudoDirtyRects.append(rect);
39
}
40
41
void Tile::optimizeDirtyRect(const IntRect& rect)
42
{
43
    FloatRect visibleRect(rect);
44
45
    // Traverse saved pseudo dirty rects.
46
    unsigned lastElementNeedToKeep = 0;
47
    while (m_pseudoDirtyRects.size() != lastElementNeedToKeep) {
48
        FloatRect pseudoDirtyRect = m_pseudoDirtyRects[lastElementNeedToKeep];
49
        if (pseudoDirtyRect.intersects(visibleRect)) {
50
            m_dirtyRect.unite(enclosingIntRect(pseudoDirtyRect));
51
            m_pseudoDirtyRects.remove(lastElementNeedToKeep);
52
        } else {
53
            // Skip invisible rect.
54
            lastElementNeedToKeep++;
55
        }
56
    }
57
}
58
59
}
60
61
#endif
- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h -1 lines
Lines 64-70 private: a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h_sec1
64
    IntRect m_rect;
64
    IntRect m_rect;
65
65
66
    uint32_t m_ID;
66
    uint32_t m_ID;
67
    IntRect m_dirtyRect;
68
67
69
    OwnPtr<ImageBuffer> m_localBuffer;
68
    OwnPtr<ImageBuffer> m_localBuffer;
70
};
69
};
- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp -1 / +1 lines
Lines 43-50 CoordinatedTile::CoordinatedTile(CoordinatedTileClient* client, TiledBackingStor a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp_sec1
43
    , m_coordinate(tileCoordinate)
43
    , m_coordinate(tileCoordinate)
44
    , m_rect(tiledBackingStore->tileRectForCoordinate(tileCoordinate))
44
    , m_rect(tiledBackingStore->tileRectForCoordinate(tileCoordinate))
45
    , m_ID(InvalidCoordinatedTileID)
45
    , m_ID(InvalidCoordinatedTileID)
46
    , m_dirtyRect(m_rect)
47
{
46
{
47
    m_dirtyRect = m_rect;
48
}
48
}
49
49
50
CoordinatedTile::~CoordinatedTile()
50
CoordinatedTile::~CoordinatedTile()
- a/Source/WebCore/CMakeLists.txt -1 / +3 lines
Lines 1961-1966 set(WebCore_SOURCES a/Source/WebCore/CMakeLists.txt_sec1
1961
    platform/graphics/SurrogatePairAwareTextIterator.cpp
1961
    platform/graphics/SurrogatePairAwareTextIterator.cpp
1962
    platform/graphics/SVGGlyph.cpp
1962
    platform/graphics/SVGGlyph.cpp
1963
    platform/graphics/TextRun.cpp
1963
    platform/graphics/TextRun.cpp
1964
    platform/graphics/Tile.cpp
1964
    platform/graphics/TiledBackingStore.cpp
1965
    platform/graphics/TiledBackingStore.cpp
1965
    platform/graphics/WidthIterator.cpp
1966
    platform/graphics/WidthIterator.cpp
1966
diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri
1967
diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri
1967
-- a/Source/WebCore/Target.pri
1968
++ b/Source/WebCore/Target.pri
Lines 1045-1050 SOURCES += \ a/Source/WebCore/CMakeLists.txt_sec2
1045
    platform/graphics/SurrogatePairAwareTextIterator.cpp \
1045
    platform/graphics/SurrogatePairAwareTextIterator.cpp \
1046
    platform/graphics/TextRun.cpp \
1046
    platform/graphics/TextRun.cpp \
1047
    platform/graphics/TextTrackRepresentation.cpp \
1047
    platform/graphics/TextTrackRepresentation.cpp \
1048
    platform/graphics/Tile.cpp \
1048
    platform/graphics/TiledBackingStore.cpp \
1049
    platform/graphics/TiledBackingStore.cpp \
1049
    platform/graphics/transforms/AffineTransform.cpp \
1050
    platform/graphics/transforms/AffineTransform.cpp \
1050
    platform/graphics/transforms/TransformationMatrix.cpp \
1051
    platform/graphics/transforms/TransformationMatrix.cpp \
- a/Source/WebCore/WebCore.gypi +1 lines
Lines 3947-3952 a/Source/WebCore/WebCore.gypi_sec1
3947
            'platform/graphics/TextRun.cpp',
3947
            'platform/graphics/TextRun.cpp',
3948
            'platform/graphics/TextTrackRepresentation.cpp',
3948
            'platform/graphics/TextTrackRepresentation.cpp',
3949
            'platform/graphics/TextTrackRepresentation.h',
3949
            'platform/graphics/TextTrackRepresentation.h',
3950
            'platform/graphics/Tile.cpp',
3950
            'platform/graphics/Tile.h',
3951
            'platform/graphics/Tile.h',
3951
            'platform/graphics/TiledBackingStore.cpp',
3952
            'platform/graphics/TiledBackingStore.cpp',
3952
            'platform/graphics/TiledBackingStore.h',
3953
            'platform/graphics/TiledBackingStore.h',

Return to Bug 112327