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

Changeset 185396 in webkit


Ignore:
Timestamp:
Jun 9, 2015, 5:46:51 PM (11 years ago)
Author:
akling@apple.com
Message:

GraphicsContext state stack wasting lots of memory when empty.
<​https://webkit.org/b/145817>

Reviewed by Geoffrey Garen.

Give the GraphicsContextState stack an inline capacity of 1, and make sure
to free any heap-allocated backing store when the stack goes empty.

The 1 is because HTMLCanvasElement keeps one "save" on the underlying
GraphicsContext at all times, and this prevents those canvases from always
sitting on an empty stack with 16 capacity.

This saves ~520 kB on cnet.com video pages.

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::restore):

  • platform/graphics/GraphicsContext.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185395 r185396  
     12015-06-09  Andreas Kling  <akling@apple.com>
     2
     3        GraphicsContext state stack wasting lots of memory when empty.
     4        <https://webkit.org/b/145817>
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Give the GraphicsContextState stack an inline capacity of 1, and make sure
     9        to free any heap-allocated backing store when the stack goes empty.
     10
     11        The 1 is because HTMLCanvasElement keeps one "save" on the underlying
     12        GraphicsContext at all times, and this prevents those canvases from always
     13        sitting on an empty stack with 16 capacity.
     14
     15        This saves ~520 kB on cnet.com video pages.
     16
     17        * platform/graphics/GraphicsContext.cpp:
     18        (WebCore::GraphicsContext::restore):
     19        * platform/graphics/GraphicsContext.h:
     20
    1212015-06-09  Said Abou-Hallawa  <sabouhallawa@apple.com>
    222
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r182516 r185396  
    135135    m_stack.removeLast();
    136136
     137    // Make sure we deallocate the state stack buffer when it goes empty.
     138    // Canvas elements will immediately save() again, but that goes into inline capacity.
     139    if (m_stack.isEmpty())
     140        m_stack.clear();
     141
    137142    restorePlatformState();
    138143}
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r183314 r185396  
    560560
    561561        GraphicsContextState m_state;
    562         Vector<GraphicsContextState> m_stack;
     562        Vector<GraphicsContextState, 1> m_stack;
    563563        bool m_updatingControlTints;
    564564        unsigned m_transparencyCount;
Note: See TracChangeset for help on using the changeset viewer.