Changeset 251654 in webkit


Ignore:
Timestamp:
Oct 28, 2019 8:06:07 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r251651.
https://bugs.webkit.org/show_bug.cgi?id=203488

It's causing crashes in several tests (Requested by KaL on
#webkit).

Reverted changeset:

"ImageDecoders: use a thread safe data buffer for Cairo
backing store"
https://bugs.webkit.org/show_bug.cgi?id=201727
https://trac.webkit.org/changeset/251651

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251651 r251654  
     12019-10-28  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r251651.
     4        https://bugs.webkit.org/show_bug.cgi?id=203488
     5
     6        It's causing crashes in several tests (Requested by KaL on
     7        #webkit).
     8
     9        Reverted changeset:
     10
     11        "ImageDecoders: use a thread safe data buffer for Cairo
     12        backing store"
     13        https://bugs.webkit.org/show_bug.cgi?id=201727
     14        https://trac.webkit.org/changeset/251651
     15
    1162019-10-28  Charlie Turner  <cturner@igalia.com>
    217
  • trunk/Source/WebCore/platform/graphics/ImageBackingStore.h

    r251651 r251654  
    6060            return false;
    6161
    62         m_pixels = RGBAPixelBufferThreadSafeRefCounted::create(size);
    63 
    64         if (!m_pixels->isValid())
     62        Vector<char> buffer;
     63        size_t bufferSize = size.area().unsafeGet() * sizeof(RGBA32);
     64
     65        if (!buffer.tryReserveCapacity(bufferSize))
    6566            return false;
    6667
     68        buffer.grow(bufferSize);
     69        m_pixels = SharedBuffer::create(WTFMove(buffer));
     70        m_pixelsPtr = reinterpret_cast<RGBA32*>(const_cast<char*>(m_pixels->data()));
    6771        m_size = size;
    6872        m_frameRect = IntRect(IntPoint(), m_size);
     
    8387    void clear()
    8488    {
    85         m_pixels->zeroPixelData();
     89        memset(m_pixelsPtr, 0, (m_size.area() * sizeof(RGBA32)).unsafeGet());
    8690    }
    8791
     
    130134    {
    131135        ASSERT(inBounds(IntPoint(x, y)));
    132         return m_pixels->pixelAt(x, y);
     136        return m_pixelsPtr + y * m_size.width() + x;
    133137    }
    134138
     
    186190
    187191private:
    188     class RGBAPixelBufferThreadSafeRefCounted : public ThreadSafeRefCounted<RGBAPixelBufferThreadSafeRefCounted> {
    189     public:
    190         static Ref<RGBAPixelBufferThreadSafeRefCounted> create(const IntSize& initialSize) { return adoptRef(*new RGBAPixelBufferThreadSafeRefCounted(initialSize)); }
    191         void zeroPixelData() { m_pixels.fill(0); }
    192         RGBA32* pixelAt(int x, int y) const { return const_cast<unsigned*>(&m_pixels.data()[y * m_size.width() + x]); }
    193         const RGBA32* data() const { return m_pixels.data(); }
    194         bool isValid() const { return m_isValid; }
    195     private:
    196         RGBAPixelBufferThreadSafeRefCounted(const IntSize& initialSize)
    197             : m_size(initialSize)
    198         {
    199             unsigned bufferSize = initialSize.area().unsafeGet();
    200             m_isValid = m_pixels.tryReserveCapacity(bufferSize);
    201             if (m_isValid)
    202                 m_pixels.resize(bufferSize);
    203         }
    204         IntSize m_size;
    205         Vector<RGBA32> m_pixels;
    206         bool m_isValid { false };
    207     };
    208 
    209192    ImageBackingStore(const IntSize& size, bool premultiplyAlpha = true)
    210193        : m_premultiplyAlpha(premultiplyAlpha)
     
    219202    {
    220203        ASSERT(!m_size.isEmpty() && !isOverSize(m_size));
     204        m_pixels = SharedBuffer::create(other.m_pixels->data(), other.m_pixels->size());
     205        m_pixelsPtr = reinterpret_cast<RGBA32*>(const_cast<char*>(m_pixels->data()));
    221206    }
    222207
     
    242227    }
    243228
    244     RefPtr<RGBAPixelBufferThreadSafeRefCounted> m_pixels;
    245 
     229    RefPtr<SharedBuffer> m_pixels;
     230    RGBA32* m_pixelsPtr { nullptr };
    246231    IntSize m_size;
    247232    IntRect m_frameRect; // This will always just be the entire buffer except for GIF and PNG frames
  • trunk/Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp

    r251651 r251654  
    3535    m_pixels->ref();
    3636    RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(
    37         reinterpret_cast<unsigned char*>(const_cast<uint32_t*>(m_pixels->data())),
     37        reinterpret_cast<unsigned char*>(const_cast<uint32_t*>(m_pixelsPtr)),
    3838        CAIRO_FORMAT_ARGB32, size().width(), size().height(), size().width() * sizeof(uint32_t)));
    3939    static cairo_user_data_key_t s_surfaceDataKey;
    40     cairo_surface_set_user_data(surface.get(), &s_surfaceDataKey, m_pixels.get(), [](void* data) { static_cast<RGBAPixelBufferThreadSafeRefCounted*>(data)->deref(); });
     40    cairo_surface_set_user_data(surface.get(), &s_surfaceDataKey, m_pixels.get(), [](void* data) { static_cast<SharedBuffer*>(data)->deref(); });
    4141
    4242    return surface;
Note: See TracChangeset for help on using the changeset viewer.