Skip to content

Commit

Permalink
[Skia] Purge caches on memory pressure
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270634

Reviewed by Carlos Garcia Campos.

* Source/WebCore/PlatformWPE.cmake:
* Source/WebCore/page/MemoryRelease.cpp:
* Source/WebCore/page/skia/MemoryReleaseSkia.cpp: Added.
(WebCore::platformReleaseMemory):

Canonical link: https://commits.webkit.org/275967@main
  • Loading branch information
Scony authored and carlosgcampos committed Mar 12, 2024
1 parent fd23a60 commit ba92338
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source/WebCore/page/MemoryRelease.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ void logMemoryStatistics(LogMemoryStatisticsReason reason)
#endif

#if !PLATFORM(COCOA)
#if !USE(SKIA)
void platformReleaseMemory(Critical) { }
#endif
void platformReleaseGraphicsMemory(Critical) { }
void jettisonExpensiveObjectsOnTopLevelNavigation() { }
void registerMemoryReleaseNotifyCallbacks() { }
Expand Down
32 changes: 32 additions & 0 deletions Source/WebCore/page/skia/MemoryReleaseSkia.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2024 Igalia S.L
*
* 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"
#include "MemoryRelease.h"

#include <skia/core/SkGraphics.h>

namespace WebCore {

void platformReleaseMemory(Critical)
{
SkGraphics::PurgeAllCaches();
}

} // namespace WebCore
2 changes: 2 additions & 0 deletions Source/WebCore/platform/SourcesSkia.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.

page/skia/MemoryReleaseSkia.cpp

platform/graphics/skia/TransformationMatrixSkia.cpp
platform/graphics/skia/ColorSkia.cpp
platform/graphics/skia/ComplexTextControllerSkia.cpp
Expand Down

0 comments on commit ba92338

Please sign in to comment.