Changeset 137293 in webkit


Ignore:
Timestamp:
Dec 11, 2012 4:53:55 AM (11 years ago)
Author:
Christophe Dumez
Message:

[CoordinatedGraphics] Use unsigned integers for UpdateAtlas IDs
https://bugs.webkit.org/show_bug.cgi?id=104654

Reviewed by Kenneth Rohde Christiansen.

UpdateAtlas currently uses *signed* integer type for its identifier.
Due to the way we generate those IDs, it is safer to use *unsigned*
integers. This is because the generated ID will overflow at some
point and the C and C++ language standards say that overflow of a
signed value is undefined behaviour.

This patch switches to unsigned integer type for UpdateAtlas IDs
since unsigned integers are guaranteed to wrap around on overflow.

  • Shared/SurfaceUpdateInfo.h:

(SurfaceUpdateInfo):

  • UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:

(WebKit::LayerTreeCoordinatorProxy::createUpdateAtlas):
(WebKit::LayerTreeCoordinatorProxy::removeUpdateAtlas):

  • UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:

(LayerTreeCoordinatorProxy):

  • UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:

(WebCore::CoordinatedGraphicsLayer::beginContentUpdate):

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:

(CoordinatedGraphicsLayerClient):
(CoordinatedGraphicsLayer):

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.h:

(CoordinatedTileClient):

  • WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:

(WebKit::LayerTreeCoordinator::createUpdateAtlas):
(WebKit::LayerTreeCoordinator::removeUpdateAtlas):
(WebKit::LayerTreeCoordinator::beginContentUpdate):

  • WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h:

(LayerTreeCoordinator):

  • WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:

(WebKit::UpdateAtlas::UpdateAtlas):
(WebKit::UpdateAtlas::~UpdateAtlas):
(WebKit::UpdateAtlas::beginPaintingOnAvailableBuffer):

  • WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h:

(UpdateAtlasClient):
(UpdateAtlas):

Location:
trunk/Source/WebKit2
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r137278 r137293  
     12012-12-11  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        [CoordinatedGraphics] Use unsigned integers for UpdateAtlas IDs
     4        https://bugs.webkit.org/show_bug.cgi?id=104654
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        UpdateAtlas currently uses *signed* integer type for its identifier.
     9        Due to the way we generate those IDs, it is safer to use *unsigned*
     10        integers. This is because the generated ID will overflow at some
     11        point and the C and C++ language standards say that overflow of a
     12        signed value is undefined behaviour.
     13
     14        This patch switches to unsigned integer type for UpdateAtlas IDs
     15        since unsigned integers are guaranteed to wrap around on overflow.
     16
     17        * Shared/SurfaceUpdateInfo.h:
     18        (SurfaceUpdateInfo):
     19        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:
     20        (WebKit::LayerTreeCoordinatorProxy::createUpdateAtlas):
     21        (WebKit::LayerTreeCoordinatorProxy::removeUpdateAtlas):
     22        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:
     23        (LayerTreeCoordinatorProxy):
     24        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
     25        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
     26        (WebCore::CoordinatedGraphicsLayer::beginContentUpdate):
     27        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
     28        (CoordinatedGraphicsLayerClient):
     29        (CoordinatedGraphicsLayer):
     30        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.h:
     31        (CoordinatedTileClient):
     32        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
     33        (WebKit::LayerTreeCoordinator::createUpdateAtlas):
     34        (WebKit::LayerTreeCoordinator::removeUpdateAtlas):
     35        (WebKit::LayerTreeCoordinator::beginContentUpdate):
     36        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h:
     37        (LayerTreeCoordinator):
     38        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:
     39        (WebKit::UpdateAtlas::UpdateAtlas):
     40        (WebKit::UpdateAtlas::~UpdateAtlas):
     41        (WebKit::UpdateAtlas::beginPaintingOnAvailableBuffer):
     42        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h:
     43        (UpdateAtlasClient):
     44        (UpdateAtlas):
     45
    1462012-12-11  Jinwoo Song  <jinwoo7.song@samsung.com>
    247
  • trunk/Source/WebKit2/Shared/SurfaceUpdateInfo.h

    r133270 r137293  
    4747
    4848    // The id of the update atlas including the shareable bitmap containing the updates.
    49     int atlasID;
     49    uint32_t atlasID;
    5050
    5151    // The offset in the bitmap where the rendered contents are.
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp

    r137117 r137293  
    7979}
    8080
    81 void LayerTreeCoordinatorProxy::createUpdateAtlas(int atlasID, const WebCoordinatedSurface::Handle& handle)
     81void LayerTreeCoordinatorProxy::createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle& handle)
    8282{
    8383    ASSERT(!m_surfaces.contains(atlasID));
     
    8585}
    8686
    87 void LayerTreeCoordinatorProxy::removeUpdateAtlas(int atlasID)
     87void LayerTreeCoordinatorProxy::removeUpdateAtlas(uint32_t atlasID)
    8888{
    8989    ASSERT(m_surfaces.contains(atlasID));
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h

    r137117 r137293  
    7070    void updateTileForLayer(CoordinatedLayerID, uint32_t tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&);
    7171    void removeTileForLayer(CoordinatedLayerID, uint32_t tileID);
    72     void createUpdateAtlas(int atlasID, const WebCoordinatedSurface::Handle&);
    73     void removeUpdateAtlas(int atlasID);
     72    void createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle&);
     73    void removeUpdateAtlas(uint32_t atlasID);
    7474    void createImageBacking(CoordinatedImageBackingID);
    7575    void updateImageBacking(CoordinatedImageBackingID, const WebCoordinatedSurface::Handle&);
     
    103103    float m_lastSentScale;
    104104    WebCore::FloatPoint m_lastSentTrajectoryVector;
    105     typedef HashMap<int /* atlasID */, RefPtr<CoordinatedSurface> > SurfaceMap;
     105    typedef HashMap<uint32_t /* atlasID */, RefPtr<CoordinatedSurface> > SurfaceMap;
    106106    SurfaceMap m_surfaces;
    107107};
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in

    r137117 r137293  
    3434    UpdateTileForLayer(uint32_t layerID, uint32_t tileID, WebCore::IntRect tileRect, WebKit::SurfaceUpdateInfo updateInfo)
    3535    RemoveTileForLayer(uint32_t layerID, uint32_t tileID)
    36     CreateUpdateAtlas(int atlasID, WebKit::WebCoordinatedSurface::Handle handle)
    37     RemoveUpdateAtlas(int atlasID)
     36    CreateUpdateAtlas(uint32_t atlasID, WebKit::WebCoordinatedSurface::Handle handle)
     37    RemoveUpdateAtlas(uint32_t atlasID)
    3838    CreateImageBacking(uint64_t imageID)
    3939    UpdateImageBacking(uint64_t imageID, WebKit::WebCoordinatedSurface::Handle handle)
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp

    r137117 r137293  
    736736}
    737737
    738 PassOwnPtr<GraphicsContext> CoordinatedGraphicsLayer::beginContentUpdate(const IntSize& size, int& atlas, IntPoint& offset)
     738PassOwnPtr<GraphicsContext> CoordinatedGraphicsLayer::beginContentUpdate(const IntSize& size, uint32_t& atlas, IntPoint& offset)
    739739{
    740740    if (!m_coordinator)
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h

    r137117 r137293  
    7575    virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*) = 0;
    7676    virtual void syncFixedLayers() = 0;
    77     virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, CoordinatedSurface::Flags, int& atlasID, WebCore::IntPoint&) = 0;
     77    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, WebCore::IntPoint&) = 0;
    7878};
    7979}
     
    159159    virtual void updateTile(uint32_t tileID, const WebKit::SurfaceUpdateInfo&, const IntRect&) OVERRIDE;
    160160    virtual void removeTile(uint32_t tileID) OVERRIDE;
    161     virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, int& atlasID, IntPoint&) OVERRIDE;
     161    virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, uint32_t& atlasID, IntPoint&) OVERRIDE;
    162162
    163163    void setCoordinator(WebKit::CoordinatedGraphicsLayerClient*);
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.h

    r136658 r137293  
    7979    virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&) = 0;
    8080    virtual void removeTile(uint32_t tileID) = 0;
    81     virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, int& atlasID, WebCore::IntPoint&) = 0;
     81    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, uint32_t& atlasID, WebCore::IntPoint&) = 0;
    8282};
    8383
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp

    r137117 r137293  
    667667}
    668668
    669 void LayerTreeCoordinator::createUpdateAtlas(int atlasID, const WebCoordinatedSurface::Handle& handle)
     669void LayerTreeCoordinator::createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle& handle)
    670670{
    671671    m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateUpdateAtlas(atlasID, handle));
    672672}
    673673
    674 void LayerTreeCoordinator::removeUpdateAtlas(int atlasID)
     674void LayerTreeCoordinator::removeUpdateAtlas(uint32_t atlasID)
    675675{
    676676    if (m_isPurging)
     
    777777}
    778778
    779 PassOwnPtr<GraphicsContext> LayerTreeCoordinator::beginContentUpdate(const IntSize& size, CoordinatedSurface::Flags flags, int& atlasID, IntPoint& offset)
     779PassOwnPtr<GraphicsContext> LayerTreeCoordinator::beginContentUpdate(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset)
    780780{
    781781    OwnPtr<GraphicsContext> graphicsContext;
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h

    r137117 r137293  
    105105    virtual void syncFixedLayers();
    106106
    107     virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, CoordinatedSurface::Flags, int& atlasID, WebCore::IntPoint&);
     107    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, WebCore::IntPoint&);
    108108
    109109    // UpdateAtlasClient
    110     virtual void createUpdateAtlas(int atlasID, const WebCoordinatedSurface::Handle&);
    111     virtual void removeUpdateAtlas(int atlasID);
     110    virtual void createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle&);
     111    virtual void removeUpdateAtlas(uint32_t atlasID);
    112112
    113113#if ENABLE(REQUEST_ANIMATION_FRAME)
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp

    r137117 r137293  
    3636    , m_flags(flags)
    3737    , m_inactivityInSeconds(0)
    38     , m_isVaild(true)
     38    , m_isValid(true)
    3939{
    40     static int nextID = 0;
     40    static uint32_t nextID = 0;
    4141    m_ID = ++nextID;
    4242    IntSize size = nextPowerOfTwo(IntSize(dimension, dimension));
     
    4444
    4545    if (!static_cast<WebCoordinatedSurface*>(m_surface.get())->createHandle(m_handle)) {
    46         m_isVaild = false;
     46        m_isValid = false;
    4747        return;
    4848    }
     
    5252UpdateAtlas::~UpdateAtlas()
    5353{
    54     if (m_isVaild)
     54    if (m_isValid)
    5555        m_client->removeUpdateAtlas(m_ID);
    5656}
     
    6969}
    7070
    71 PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(int& atlasID, const WebCore::IntSize& size, IntPoint& offset)
     71PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(uint32_t& atlasID, const WebCore::IntSize& size, IntPoint& offset)
    7272{
    7373    m_inactivityInSeconds = 0;
     
    7979        return PassOwnPtr<GraphicsContext>();
    8080
    81     if (!m_isVaild)
     81    if (!m_isValid)
    8282        return PassOwnPtr<GraphicsContext>();
    8383
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h

    r137117 r137293  
    3636class UpdateAtlasClient {
    3737public:
    38     virtual void createUpdateAtlas(int atlasID, const WebCoordinatedSurface::Handle&) = 0;
    39     virtual void removeUpdateAtlas(int atlasID) = 0;
     38    virtual void createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle&) = 0;
     39    virtual void removeUpdateAtlas(uint32_t atlasID) = 0;
    4040};
    4141
     
    4949
    5050    // Returns a null pointer of there is no available buffer.
    51     PassOwnPtr<WebCore::GraphicsContext> beginPaintingOnAvailableBuffer(int& atlasID, const WebCore::IntSize&, WebCore::IntPoint& offset);
     51    PassOwnPtr<WebCore::GraphicsContext> beginPaintingOnAvailableBuffer(uint32_t& atlasID, const WebCore::IntSize&, WebCore::IntPoint& offset);
    5252    void didSwapBuffers();
    5353    bool supportsAlpha() const { return m_surface->supportsAlpha(); }
     
    7575    WebCoordinatedSurface::Handle m_handle;
    7676    double m_inactivityInSeconds;
    77     int m_ID;
    78     bool m_isVaild;
     77    uint32_t m_ID;
     78    bool m_isValid;
    7979};
    8080
Note: See TracChangeset for help on using the changeset viewer.