Title: [129791] trunk/Source/WebKit2
- Revision
- 129791
- Author
- commit-qu...@webkit.org
- Date
- 2012-09-27 12:44:29 -0700 (Thu, 27 Sep 2012)
Log Message
[Cairo] Unnecessary creation of ShareableBitmap's for directly composited images
https://bugs.webkit.org/show_bug.cgi?id=97745
Patch by Helder Correia <helder.corr...@nokia.com> on 2012-09-27
Reviewed by Martin Robinson.
In LayerTreeCoordinator::adoptImageBackingStore(), there is a
PLATFORM(QT) code path to check for identical images, but nothing is
done for Cairo, which results in the occurrence of avoidable resource
allocations.
The issue happens in e.g. http://www.webkit.org/blog-files/leaves/,
where there are many leaves flying around while they're produced out of
only four bitmaps.
This patch uses pointers to cairo_surface_t's as the key to the hashmap
that caches bitmaps. This can be safely done since we own the references.
We artificially increment the surface references in adoptImageBackingStore()
and decrement them in releaseImageBackingStore().
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
(WebKit::LayerTreeCoordinator::adoptImageBackingStore):
(WebKit::LayerTreeCoordinator::releaseImageBackingStore):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (129790 => 129791)
--- trunk/Source/WebKit2/ChangeLog 2012-09-27 19:33:57 UTC (rev 129790)
+++ trunk/Source/WebKit2/ChangeLog 2012-09-27 19:44:29 UTC (rev 129791)
@@ -1,3 +1,28 @@
+2012-09-27 Helder Correia <helder.corr...@nokia.com>
+
+ [Cairo] Unnecessary creation of ShareableBitmap's for directly composited images
+ https://bugs.webkit.org/show_bug.cgi?id=97745
+
+ Reviewed by Martin Robinson.
+
+ In LayerTreeCoordinator::adoptImageBackingStore(), there is a
+ PLATFORM(QT) code path to check for identical images, but nothing is
+ done for Cairo, which results in the occurrence of avoidable resource
+ allocations.
+
+ The issue happens in e.g. http://www.webkit.org/blog-files/leaves/,
+ where there are many leaves flying around while they're produced out of
+ only four bitmaps.
+
+ This patch uses pointers to cairo_surface_t's as the key to the hashmap
+ that caches bitmaps. This can be safely done since we own the references.
+ We artificially increment the surface references in adoptImageBackingStore()
+ and decrement them in releaseImageBackingStore().
+
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
+ (WebKit::LayerTreeCoordinator::adoptImageBackingStore):
+ (WebKit::LayerTreeCoordinator::releaseImageBackingStore):
+
2012-09-27 Anders Carlsson <ander...@apple.com>
Stop using dispatch_get_current_queue
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp (129790 => 129791)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp 2012-09-27 19:33:57 UTC (rev 129790)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp 2012-09-27 19:44:29 UTC (rev 129791)
@@ -454,6 +454,14 @@
return InvalidWebLayerID;
key = nativeImage->cacheKey();
+#elif USE(CAIRO)
+ NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame();
+ if (!nativeImage)
+ return InvalidWebLayerID;
+ // This can be safely done since we own the reference.
+ // A corresponding cairo_surface_destroy() is ensured in releaseImageBackingStore().
+ cairo_surface_t* cairoSurface = cairo_surface_reference(nativeImage->surface());
+ key = reinterpret_cast<int64_t>(cairoSurface);
#endif
HashMap<int64_t, int>::iterator it = m_directlyCompositedImageRefCounts.find(key);
@@ -490,6 +498,11 @@
return;
m_directlyCompositedImageRefCounts.remove(it);
+#if USE(CAIRO)
+ // Complement the referencing in adoptImageBackingStore().
+ cairo_surface_t* cairoSurface = reinterpret_cast<cairo_surface_t*>(key);
+ cairo_surface_destroy(cairoSurface);
+#endif
m_webPage->send(Messages::LayerTreeCoordinatorProxy::DestroyDirectlyCompositedImage(key));
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes