Avoid putting empty-sized surfaces into IOSurfacePool
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jul 2014 01:26:24 +0000 (01:26 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jul 2014 01:26:24 +0000 (01:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135136
<rdar://problem/17478407>

Reviewed by Simon Fraser.

* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::addSurface):
Avoid adding 0x0 surfaces to the pool, because they will wreak havoc
when their size is used as the key in the CachedSurfaceMap.
Additionally, avoid any empty sizes, because they're just pointless.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@171332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp

index 59ceee45e1902a3d1cee0addb880717c654274f3..259278b1fd9becde37c7e5794b21b510c3b73f0c 100644 (file)
@@ -1,3 +1,16 @@
+2014-07-21  Tim Horton  <timothy_horton@apple.com>
+
+        Avoid putting empty-sized surfaces into IOSurfacePool
+        https://bugs.webkit.org/show_bug.cgi?id=135136
+
+        Reviewed by Simon Fraser.
+
+        * platform/graphics/cg/IOSurfacePool.cpp:
+        (WebCore::IOSurfacePool::addSurface):
+        Avoid adding 0x0 surfaces to the pool, because they will wreak havoc
+        when their size is used as the key in the CachedSurfaceMap.
+        Additionally, avoid any empty sizes, because they're just pointless.
+
 2014-07-21  Beth Dakin  <bdakin@apple.com>
 
         WK1 should always setAcceleratedCompositingForFixedPositionEnabled(true) on 
 2014-07-21  Beth Dakin  <bdakin@apple.com>
 
         WK1 should always setAcceleratedCompositingForFixedPositionEnabled(true) on 
index 0c609a81baddcb70e9a83bbde3562b6c10e1514c..a941c930589216d4d35aa72fd9e44a74da9d2ae5 100644 (file)
@@ -164,6 +164,11 @@ void IOSurfacePool::addSurface(IOSurface* surface)
     if (surface->totalBytes() > m_maximumBytesCached)
         return;
 
     if (surface->totalBytes() > m_maximumBytesCached)
         return;
 
+    // There's no reason to pool empty surfaces; we should never allocate them in the first place.
+    // This also covers isZero(), which would cause trouble when used as the key in m_cachedSurfaces.
+    if (surface->size().isEmpty())
+        return;
+
     bool surfaceIsInUse = surface->isInUse();
 
     willAddSurface(surface, surfaceIsInUse);
     bool surfaceIsInUse = surface->isInUse();
 
     willAddSurface(surface, surfaceIsInUse);