WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Draft patch
TBS-gif-bugzilla.diff (text/plain), 13.37 KB, created by
Nandor Huszka
on 2013-03-14 01:37:37 PDT
(
hide
)
Description:
Draft patch
Filename:
MIME Type:
Creator:
Nandor Huszka
Created:
2013-03-14 01:37:37 PDT
Size:
13.37 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index deedc73..4dd0e34 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,59 @@ >+2013-03-14 Nándor Huszka <hnandor@inf.u-szeged.hu> >+ >+ [WK2] TiledBackingStore: invisible GIFs are animated >+ https://bugs.webkit.org/show_bug.cgi?id=112327 >+ >+ The patch stops painting invisible animations, and restart drawing them when they are visible again. >+ How it works: >+ >+ 1. before painting (in BitmapImage::draw) an animated BitmapImage asks TiledBackingStore >+ whether it is visible (TiledBackingStore::isVisible) >+ - yes: paint it >+ - no: do not paint it >+ >+ 2. TBS remembers an invisible animated image (TiledBackingStore::savePseudoDirtyRect) >+ - splits image's rect between tiles >+ - every tile save the appropriate slice of image rect (Tile::savePseudoDirtyRect) >+ >+ * image is visible again because of scrolling * >+ >+ 3. (in coverWithTilesIfNeeded) TBS checks previously saved invisible animated images (optimizeDirtyRects) >+ - every tile checks its own rect set (Tile::optimizeDirtyRect): stored rects (that are visible now) >+ will be united with dirty rect >+ >+ * every tiles' dirty rect will be repainted * >+ => previously freezed but now visible animated images will be animated again * >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * CMakeLists.txt: >+ * Target.pri: >+ * WebCore.gypi: >+ * platform/graphics/Tile.cpp: Added. >+ (WebCore): >+ (WebCore::Tile::savePseudoDirtyRect): >+ (WebCore::Tile::optimizeDirtyRect): >+ * platform/graphics/Tile.h: >+ (Tile): >+ * platform/graphics/TiledBackingStore.cpp: >+ (WebCore): >+ (WebCore::TiledBackingStore::TiledBackingStore): >+ (WebCore::TiledBackingStore::coverWithTilesIfNeeded): >+ (WebCore::TiledBackingStore::optimizeDirtyRects): >+ (WebCore::TiledBackingStore::isVisible): >+ (WebCore::TiledBackingStore::savePseudoDirtyRect): >+ * platform/graphics/TiledBackingStore.h: >+ (TiledBackingStore): >+ * platform/graphics/cairo/BitmapImageCairo.cpp: >+ (WebCore): >+ (WebCore::BitmapImage::draw): >+ * platform/graphics/texmap/coordinated/CoordinatedTile.cpp: >+ (WebCore::CoordinatedTile::CoordinatedTile): >+ * platform/graphics/texmap/coordinated/CoordinatedTile.h: >+ (CoordinatedTile): >+ > 2013-03-08 Huang Dongsung <luxtella@company100.net> > > [EFL][Qt] REGRESSION(r144787): A fixed element lags when scrolling and wheeling. >diff --git a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp b/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp >index d0953cc..fa46f56 100644 >--- a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp >@@ -31,9 +31,16 @@ > #include "ImageObserver.h" > #include "NativeImageCairo.h" > #include "PlatformContextCairo.h" >+#if USE(TILED_BACKING_STORE) >+#include "TiledBackingStore.h" >+#endif > #include <cairo.h> > > namespace WebCore { >+#if USE(TILED_BACKING_STORE) >+// FIXME: we should access TBS through Frame >+extern TiledBackingStore* tbs; >+#endif > > PassRefPtr<BitmapImage> BitmapImage::create(cairo_surface_t* surface) > { >@@ -81,7 +88,13 @@ void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo > { > if (!dst.width() || !dst.height() || !src.width() || !src.height()) > return; >- >+#if USE(TILED_BACKING_STORE) >+ bool visible = tbs->isVisible(dst); >+ bool animated = (m_currentFrame > 0); >+ // Do not paint an invisible animated image. >+ if (!visible && animated) >+ return; >+#endif > startAnimation(); > > NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame); >diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.h b/Source/WebCore/platform/graphics/TiledBackingStore.h >index 6ac8da7..ddd1251 100644 >--- a/Source/WebCore/platform/graphics/TiledBackingStore.h >+++ b/Source/WebCore/platform/graphics/TiledBackingStore.h >@@ -23,6 +23,7 @@ > #if USE(TILED_BACKING_STORE) > > #include "FloatPoint.h" >+#include "FloatRect.h" > #include "IntPoint.h" > #include "IntRect.h" > #include "Tile.h" >@@ -80,6 +81,8 @@ public: > > void setSupportsAlpha(bool); > >+ bool isVisible(const FloatRect&); >+ > private: > void startTileBufferUpdateTimer(); > void startBackingStoreUpdateTimer(double = 0); >@@ -110,6 +113,9 @@ private: > > void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coordinate&); > >+ void optimizeDirtyRects(); >+ void savePseudoDirtyRect(const FloatRect&); >+ > private: > TiledBackingStoreClient* m_client; > OwnPtr<TiledBackingStoreBackend> m_backend; >diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.cpp b/Source/WebCore/platform/graphics/TiledBackingStore.cpp >index 790945b..c6008fc 100644 >--- a/Source/WebCore/platform/graphics/TiledBackingStore.cpp >+++ b/Source/WebCore/platform/graphics/TiledBackingStore.cpp >@@ -28,6 +28,9 @@ > namespace WebCore { > > static const int defaultTileDimension = 512; >+// FIXME: for the time being we pass TBS to BitmapImage this way, >+// but it should be accessed through Frame. >+TiledBackingStore* tbs; > > static IntPoint innerBottomRight(const IntRect& rect) > { >@@ -49,6 +52,8 @@ TiledBackingStore::TiledBackingStore(TiledBackingStoreClient* client, PassOwnPtr > , m_supportsAlpha(false) > , m_pendingTileCreation(false) > { >+ // FIXME >+ tbs = this; > } > > TiledBackingStore::~TiledBackingStore() >@@ -73,11 +78,54 @@ void TiledBackingStore::coverWithTilesIfNeeded() > IntRect visibleRect = this->visibleRect(); > IntRect rect = mapFromContents(m_client->tiledBackingStoreContentsRect()); > >+ // Animations that became visible should be painted also. >+ optimizeDirtyRects(); >+ > bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != rect; > if (didChange || m_pendingTileCreation) > createTiles(); > } > >+// Optimization: examine saved pseudo-dirty rects and if it is needed complete dirty rects with them. >+void TiledBackingStore::optimizeDirtyRects() >+{ >+ IntRect visibleRect = this->visibleRect(); >+ >+ TileMap::iterator end = m_tiles.end(); >+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { >+ IntRect tileRect = it->value->rect(); >+ if (tileRect.intersects(visibleRect)) >+ it->value->optimizeDirtyRect(visibleRect); >+ } >+} >+ >+// In addition it can be used in order to avoid the painting of an invisible animation. >+bool TiledBackingStore::isVisible(const FloatRect& rect) >+{ >+ FloatRect visibleRect(m_visibleRect); >+ if (visibleRect.intersects(rect)) >+ return true; >+ >+ // If rect is completely invisible, store it. >+ savePseudoDirtyRect(rect); >+ >+ return false; >+} >+ >+// This method makes sense when we call it with an invisible animation's rect. >+// Pseudo-dirty rect: should only be painted before it becomes visible. >+void TiledBackingStore::savePseudoDirtyRect(const FloatRect& rect) >+{ >+ // Rect may intersect more tiles, so split it up between tiles. >+ TileMap::iterator end = m_tiles.end(); >+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { >+ FloatRect tileRect = it->value->rect(); >+ FloatRect pseudoDirtyRectSlice = intersection(tileRect, rect); >+ if (!pseudoDirtyRectSlice.isEmpty()) >+ it->value->savePseudoDirtyRect(pseudoDirtyRectSlice); >+ } >+} >+ > void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect) > { > IntRect dirtyRect(mapFromContents(contentsDirtyRect)); >diff --git a/Source/WebCore/platform/graphics/Tile.h b/Source/WebCore/platform/graphics/Tile.h >index fa25ca2..2763bee 100644 >--- a/Source/WebCore/platform/graphics/Tile.h >+++ b/Source/WebCore/platform/graphics/Tile.h >@@ -25,6 +25,7 @@ > #include "IntPoint.h" > #include "IntPointHash.h" > #include "IntRect.h" >+#include "FloatRect.h" > #include <wtf/RefCounted.h> > > namespace WebCore { >@@ -47,6 +48,17 @@ public: > virtual const Tile::Coordinate& coordinate() const = 0; > virtual const IntRect& rect() const = 0; > virtual void resize(const WebCore::IntSize&) = 0; >+ >+ void savePseudoDirtyRect(const FloatRect&); >+ void optimizeDirtyRect(const IntRect&); >+ >+protected: >+ // Moved from CoordinatedTile, because savePseudoDirtyRect and optimizeDirtyRect use it. >+ IntRect m_dirtyRect; >+ >+private: >+ // Stores rects that are not visible now, so we didn't paint them, but they may become visible later. >+ Vector<FloatRect> m_pseudoDirtyRects; > }; > > } >diff --git a/Source/WebCore/platform/graphics/Tile.cpp b/Source/WebCore/platform/graphics/Tile.cpp >new file mode 100644 >index 0000000..b85e20d >--- /dev/null >+++ b/Source/WebCore/platform/graphics/Tile.cpp >@@ -0,0 +1,61 @@ >+/* >+ Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies) >+ >+ This library is free software; you can redistribute it and/or >+ modify it under the terms of the GNU Library General Public >+ License as published by the Free Software Foundation; either >+ version 2 of the License, or (at your option) any later version. >+ >+ This library is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ Library General Public License for more details. >+ >+ You should have received a copy of the GNU Library General Public License >+ along with this library; see the file COPYING.LIB. If not, write to >+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ Boston, MA 02110-1301, USA. >+ */ >+ >+#include "config.h" >+ >+#if USE(TILED_BACKING_STORE) >+ >+#include "Tile.h" >+ >+namespace WebCore { >+ >+// Puts a rect into m_pseudoDirtyRects. >+void Tile::savePseudoDirtyRect(const FloatRect& rect) >+{ >+ // If we have already saved a rect, don't save it. >+ unsigned size = m_pseudoDirtyRects.size(); >+ for (unsigned n = 0; n < size; ++n) { >+ if (m_pseudoDirtyRects[n].contains(rect)) >+ return; >+ } >+ >+ m_pseudoDirtyRects.append(rect); >+} >+ >+void Tile::optimizeDirtyRect(const IntRect& rect) >+{ >+ FloatRect visibleRect(rect); >+ >+ // Traverse saved pseudo dirty rects. >+ unsigned lastElementNeedToKeep = 0; >+ while (m_pseudoDirtyRects.size() != lastElementNeedToKeep) { >+ FloatRect pseudoDirtyRect = m_pseudoDirtyRects[lastElementNeedToKeep]; >+ if (pseudoDirtyRect.intersects(visibleRect)) { >+ m_dirtyRect.unite(enclosingIntRect(pseudoDirtyRect)); >+ m_pseudoDirtyRects.remove(lastElementNeedToKeep); >+ } else { >+ // Skip invisible rect. >+ lastElementNeedToKeep++; >+ } >+ } >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h >index be99bfd..3f1f851 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h >@@ -64,7 +64,6 @@ private: > IntRect m_rect; > > uint32_t m_ID; >- IntRect m_dirtyRect; > > OwnPtr<ImageBuffer> m_localBuffer; > }; >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp >index 9f9d34e..b8806e5 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp >@@ -43,8 +43,8 @@ CoordinatedTile::CoordinatedTile(CoordinatedTileClient* client, TiledBackingStor > , m_coordinate(tileCoordinate) > , m_rect(tiledBackingStore->tileRectForCoordinate(tileCoordinate)) > , m_ID(InvalidCoordinatedTileID) >- , m_dirtyRect(m_rect) > { >+ m_dirtyRect = m_rect; > } > > CoordinatedTile::~CoordinatedTile() >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 1e5ade9..78db268 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -1961,6 +1961,7 @@ set(WebCore_SOURCES > platform/graphics/SurrogatePairAwareTextIterator.cpp > platform/graphics/SVGGlyph.cpp > platform/graphics/TextRun.cpp >+ platform/graphics/Tile.cpp > platform/graphics/TiledBackingStore.cpp > platform/graphics/WidthIterator.cpp > diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri >index 1b655fb..96e11a1 100644 >--- a/Source/WebCore/Target.pri >+++ b/Source/WebCore/Target.pri >@@ -1045,6 +1045,7 @@ SOURCES += \ > platform/graphics/SurrogatePairAwareTextIterator.cpp \ > platform/graphics/TextRun.cpp \ > platform/graphics/TextTrackRepresentation.cpp \ >+ platform/graphics/Tile.cpp \ > platform/graphics/TiledBackingStore.cpp \ > platform/graphics/transforms/AffineTransform.cpp \ > platform/graphics/transforms/TransformationMatrix.cpp \ >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index fcc1dbe..67e7896 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -3947,6 +3947,7 @@ > 'platform/graphics/TextRun.cpp', > 'platform/graphics/TextTrackRepresentation.cpp', > 'platform/graphics/TextTrackRepresentation.h', >+ 'platform/graphics/Tile.cpp', > 'platform/graphics/Tile.h', > 'platform/graphics/TiledBackingStore.cpp', > 'platform/graphics/TiledBackingStore.h', >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 112327
:
193086
|
196299
|
197232
|
198478
|
198618