⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 136151 in webkit


Ignore:
Timestamp:
Nov 29, 2012, 12:34:41 PM (14 years ago)
Author:
Beth Dakin
Message:

​https://bugs.webkit.org/show_bug.cgi?id=103577
TiledDrawingArea should recycle tiles
-and corresponding-
<rdar://problem/12714586>

Reviewed by Simon Fraser.

New class LayerPool will keep a list of layers to reuse so that
we can avoid creating and destroying so many layer.

When removing layers, add them to the LayerPool

  • platform/graphics/ca/mac/TileCache.mm:

(WebCore::TileCache::revalidateTiles):

Before creating a new layer, try to get one of the appropriate size
from the LayerPool.
(WebCore::TileCache::createTileLayer):

New class.

  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/ca/mac/LayerPool.h: Added.

(WebCore):
(LayerPool):
(WebCore::LayerPool::capacity):
(WebCore::LayerPool::canReuseLayerWithSize):

  • platform/graphics/ca/mac/LayerPool.mm: Added.

(WebCore):
(WebCore::LayerPool:: LayerPool):
(WebCore::LayerPool::sharedPool):
(WebCore::LayerPool::bytesBackingLayerWithPixelSize):
(WebCore::LayerPool::listOfLayersWithSize):
(WebCore::LayerPool::addLayer):
(WebCore::LayerPool::takeLayerWithSize):
(WebCore::LayerPool::decayedCapacity):
(WebCore::LayerPool::schedulePrune):
(WebCore::LayerPool::prune):
(WebCore::LayerPool::drain):

If we're under memory pressure, drain the LayerPool

  • platform/mac/MemoryPressureHandlerMac.mm:

(WebCore::MemoryPressureHandler::releaseMemory):

Location:
trunk/Source/WebCore
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r136150 r136151  
     12012-11-29  Beth Dakin  <bdakin@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=103577
     4        TiledDrawingArea should recycle tiles
     5        -and corresponding-
     6        <rdar://problem/12714586>
     7
     8        Reviewed by Simon Fraser.
     9
     10        New class LayerPool will keep a list of layers to reuse so that
     11        we can avoid creating and destroying so many layer.
     12
     13        When removing layers, add them to the LayerPool
     14        * platform/graphics/ca/mac/TileCache.mm:
     15        (WebCore::TileCache::revalidateTiles):
     16
     17        Before creating a new layer, try to get one of the appropriate size
     18        from the LayerPool.
     19        (WebCore::TileCache::createTileLayer):
     20
     21        New class.
     22        * WebCore.xcodeproj/project.pbxproj:
     23        * platform/graphics/ca/mac/LayerPool.h: Added.
     24        (WebCore):
     25        (LayerPool):
     26        (WebCore::LayerPool::capacity):
     27        (WebCore::LayerPool::canReuseLayerWithSize):
     28        * platform/graphics/ca/mac/LayerPool.mm: Added.
     29        (WebCore):
     30        (WebCore::LayerPool:: LayerPool):
     31        (WebCore::LayerPool::sharedPool):
     32        (WebCore::LayerPool::bytesBackingLayerWithPixelSize):
     33        (WebCore::LayerPool::listOfLayersWithSize):
     34        (WebCore::LayerPool::addLayer):
     35        (WebCore::LayerPool::takeLayerWithSize):
     36        (WebCore::LayerPool::decayedCapacity):
     37        (WebCore::LayerPool::schedulePrune):
     38        (WebCore::LayerPool::prune):
     39        (WebCore::LayerPool::drain):
     40
     41        If we're under memory pressure, drain the LayerPool
     42        * platform/mac/MemoryPressureHandlerMac.mm:
     43        (WebCore::MemoryPressureHandler::releaseMemory):
     44
    1452012-11-29  Julien Chaffraix  <jchaffraix@webkit.org>
    246
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r136150 r136151  
    34313431                93F6F1ED127F70B10055CB06 /* WebGLContextEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F6F1EA127F70B10055CB06 /* WebGLContextEvent.cpp */; };
    34323432                93F6F1EE127F70B10055CB06 /* WebGLContextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F6F1EB127F70B10055CB06 /* WebGLContextEvent.h */; };
     3433                93F72AF31666EDFC002A02BD /* LayerPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F72AF11666EDFC002A02BD /* LayerPool.h */; };
     3434                93F72AF41666EDFC002A02BD /* LayerPool.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93F72AF21666EDFC002A02BD /* LayerPool.mm */; };
    34333435                93F925430F7EF5B8007E37C9 /* CheckedRadioButtons.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F925410F7EF5B8007E37C9 /* CheckedRadioButtons.h */; settings = {ATTRIBUTES = (Private, ); }; };
    34343436                93F925440F7EF5B8007E37C9 /* CheckedRadioButtons.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F925420F7EF5B8007E37C9 /* CheckedRadioButtons.cpp */; };
    … …  
    59305932                CDB859FA160D494900E5B07F /* JSMediaKeyEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB859F8160D493E00E5B07F /* JSMediaKeyEvent.cpp */; };
    59315933                CDB859FB160D494F00E5B07F /* JSMediaKeyError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB859F0160D42DD00E5B07F /* JSMediaKeyError.cpp */; };
     5934                CDC69DD61632026C007C38DF /* WebCoreFullScreenWarningView.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC69DD41632026C007C38DF /* WebCoreFullScreenWarningView.h */; settings = {ATTRIBUTES = (Private, ); }; };
     5935                CDC69DD71632026C007C38DF /* WebCoreFullScreenWarningView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC69DD51632026C007C38DF /* WebCoreFullScreenWarningView.mm */; };
    59325936                CDC69DDA16371FD4007C38DF /* WebCoreFullScreenPlaceholderView.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC69DD816371FD3007C38DF /* WebCoreFullScreenPlaceholderView.h */; settings = {ATTRIBUTES = (Private, ); }; };
    59335937                CDC69DDB16371FD4007C38DF /* WebCoreFullScreenPlaceholderView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC69DD916371FD3007C38DF /* WebCoreFullScreenPlaceholderView.mm */; };
    5934                 CDC69DD61632026C007C38DF /* WebCoreFullScreenWarningView.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC69DD41632026C007C38DF /* WebCoreFullScreenWarningView.h */; settings = {ATTRIBUTES = (Private, ); }; };
    5935                 CDC69DD71632026C007C38DF /* WebCoreFullScreenWarningView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC69DD51632026C007C38DF /* WebCoreFullScreenWarningView.mm */; };
    59365938                CDD525D7145B6DD0008D204D /* JSHTMLMediaElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDF65CCC145B6AFE00C4C7AA /* JSHTMLMediaElementCustom.cpp */; };
    59375939                CDEA763014608A53008B31F1 /* PlatformClockCA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDEA762E146084DE008B31F1 /* PlatformClockCA.cpp */; };
    … …  
    1068610688                93F6F1EB127F70B10055CB06 /* WebGLContextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLContextEvent.h; path = canvas/WebGLContextEvent.h; sourceTree = "<group>"; };
    1068710689                93F6F1EC127F70B10055CB06 /* WebGLContextEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLContextEvent.idl; path = canvas/WebGLContextEvent.idl; sourceTree = "<group>"; };
     10690                93F72AF11666EDFC002A02BD /* LayerPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LayerPool.h; path = ca/mac/LayerPool.h; sourceTree = "<group>"; };
     10691                93F72AF21666EDFC002A02BD /* LayerPool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LayerPool.mm; path = ca/mac/LayerPool.mm; sourceTree = "<group>"; };
    1068810692                93F8B3050A300FE100F61AB8 /* CodeGenerator.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; name = CodeGenerator.pm; path = scripts/CodeGenerator.pm; sourceTree = "<group>"; };
    1068910693                93F8B3060A300FEA00F61AB8 /* CodeGeneratorJS.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; name = CodeGeneratorJS.pm; path = ../scripts/CodeGeneratorJS.pm; sourceTree = "<group>"; wrapsLines = 0; };
    … …  
    1335913363                CDB859F9160D493E00E5B07F /* JSMediaKeyEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaKeyEvent.h; sourceTree = "<group>"; };
    1336013364                CDBD93BA1333BD4B002570E3 /* fullscreenQuickTime.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = fullscreenQuickTime.css; sourceTree = "<group>"; };
     13365                CDC69DD41632026C007C38DF /* WebCoreFullScreenWarningView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWarningView.h; sourceTree = "<group>"; };
     13366                CDC69DD51632026C007C38DF /* WebCoreFullScreenWarningView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWarningView.mm; sourceTree = "<group>"; };
    1336113367                CDC69DD816371FD3007C38DF /* WebCoreFullScreenPlaceholderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenPlaceholderView.h; sourceTree = "<group>"; };
    1336213368                CDC69DD916371FD3007C38DF /* WebCoreFullScreenPlaceholderView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenPlaceholderView.mm; sourceTree = "<group>"; };
    13363                 CDC69DD41632026C007C38DF /* WebCoreFullScreenWarningView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWarningView.h; sourceTree = "<group>"; };
    13364                 CDC69DD51632026C007C38DF /* WebCoreFullScreenWarningView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWarningView.mm; sourceTree = "<group>"; };
    1336513369                CDCE5CD014633BC900D47CCA /* EventTargetFactory.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventTargetFactory.in; sourceTree = "<group>"; };
    1336613370                CDEA762C14608224008B31F1 /* Clock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Clock.h; sourceTree = "<group>"; };
    … …  
    1539915403                                1AA71609149BC4DB0016EC19 /* TileCache.h */,
    1540015404                                1AA71608149BC4DA0016EC19 /* TileCache.mm */,
     15405                                93F72AF11666EDFC002A02BD /* LayerPool.h */,
     15406                                93F72AF21666EDFC002A02BD /* LayerPool.mm */,
    1540115407                                0F580FA11496939100FB5BD8 /* WebTileCacheLayer.h */,
    1540215408                                0F580FA21496939100FB5BD8 /* WebTileCacheLayer.mm */,
    … …  
    2584125847                                31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */,
    2584225848                                15B8B7C91652C5220036EF55 /* JSWebKitCSSMixFunctionValue.h in Headers */,
     25849                                93F72AF31666EDFC002A02BD /* LayerPool.h in Headers */,
    2584325850                        );
    2584425851                        runOnlyForDeploymentPostprocessing = 0;
    … …  
    2894428951                                15B8B7C81652C5220036EF55 /* JSWebKitCSSMixFunctionValue.cpp in Sources */,
    2894528952                                86BA766E166427A8005BE5D1 /* FrameLoadRequest.cpp in Sources */,
     28953                                93F72AF41666EDFC002A02BD /* LayerPool.mm in Sources */,
    2894628954                        );
    2894728955                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm

    r135053 r136151  
    3030#import "PlatformCALayer.h"
    3131#import "Region.h"
     32#import "LayerPool.h"
    3233#import "WebLayer.h"
    3334#import "WebTileCacheLayer.h"
    … …  
    420421    // we might want to remove the ones below the coverage rect but keep the ones above.
    421422    for (size_t i = 0; i < tilesToRemove.size(); ++i)
    422         m_tiles.remove(tilesToRemove[i]);
     423        LayerPool::sharedPool()->addLayer(m_tiles.take(tilesToRemove[i]));
    423424
    424425    TileIndex topLeft;
    … …  
    488489RetainPtr<WebTileLayer> TileCache::createTileLayer(const IntRect& tileRect)
    489490{
    490     RetainPtr<WebTileLayer> layer = adoptNS([[WebTileLayer alloc] init]);
     491    RetainPtr<WebTileLayer> layer = LayerPool::sharedPool()->takeLayerWithSize(tileRect.size());
     492    if (layer) {
     493        // If we were able to restore a layer from the LayerPool, we should call setNeedsDisplay to
     494        // ensure we avoid stale content.
     495        [layer setNeedsDisplay];
     496    } else
     497        layer = adoptNS([[WebTileLayer alloc] init]);
    491498    [layer.get() setAnchorPoint:CGPointZero];
    492499    [layer.get() setFrame:tileRect];
  • trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm

    r122670 r136151  
    3131#import <WebCore/MemoryCache.h>
    3232#import <WebCore/PageCache.h>
     33#import <WebCore/LayerPool.h>
    3334#import <wtf/CurrentTime.h>
    3435#import <wtf/FastMalloc.h>
    … …  
    149150    memoryCache()->pruneToPercentage(critical ? 0 : 0.5f);
    150151
     152    LayerPool::sharedPool()->drain();
     153
    151154    gcController().discardAllCompiledCode();
    152155
Note: See TracChangeset for help on using the changeset viewer.