[Webkit-unassigned] [Bug 157249] Deduplicated initializer lists of BitmapImage constructors.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed May 4 10:52:59 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=157249

--- Comment #11 from Said Abou-Hallawa <sabouhallawa at apple.com> ---
Another cleaner way is the following:

1. Convert all the bit-field boolean members in the BitImage class to be non bit-field so you can initialize them in the class header like that:
   << bool m_isSolidColor : 1;
   >> bool m_isSolidColor { false };

2. Move the platform-dependent constructor BitmapImage::BitmapImage() from BitmapImageCairo.cpp and BitmapImageCG.cpp to BitmapImage.cpp and have only one constructor written like that

   BitmapImage(NativeImagePtr&& image, ImageObserver* observer)
        : Image(observer)
        , m_frameCount(1)
        , m_animationFinished(true)
        ...

3. Add two new static methods in FrameData which return the size and the hasAlpha of a NativeImagePtr. And call these functions from the constructor like that:

    BitmapImage::BitmapImage(NativeImagePtr&& image, ImageObserver* observer)
        : mage(observer)
        , m_frameCount(1)
        , m_animationFinished(true)
        ...
    {
        m_size = FrameData::size(image);
        m_decodedSize = size.area() * 4;

        m_frames.grow(1);
        m_frames[0].m_haveMetadata = true;
        m_frames[0].m_hasAlpha = FrameData::hasAlpha(image;
        m_frames[0].m_image = WTFMove(image);

        checkForSolidColor();
    }

5. Have different implementations for these function in BitmapImageCairo.cpp and BitmapImageCG.cpp.

e.g. in BitmapImageCG.cpp:
    FrameData::hasAlpha(NativeImagePtr&)
    {
       return true;
    }

    FrameData::size(NativeImagePtr& image)
    {
       return IntSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get()))
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160504/35f93db1/attachment.html>


More information about the webkit-unassigned mailing list