Changeset 230334 in webkit


Ignore:
Timestamp:
Apr 6, 2018 9:29:52 AM (6 years ago)
Author:
Antti Koivisto
Message:

Tighten ImageSource to have BitmapImage pointer instead of Image
https://bugs.webkit.org/show_bug.cgi?id=184356

Reviewed by Said Abou-Hallawa.

ImageSource is an implementation detail of BitmapImage, not a generic type.

  • loader/ImageLoader.cpp:

(WebCore::ImageLoader::decode):

  • platform/graphics/BitmapImage.h:
  • platform/graphics/Image.h:

(WebCore::Image::decode): Deleted.
(WebCore::Image::imageFrameAvailableAtIndex): Deleted.

Also make some BitmapImage specific functions non-virtual and remove them from Image.

  • platform/graphics/ImageSource.cpp:

(WebCore::ImageSource::ImageSource):

  • platform/graphics/ImageSource.h:

(WebCore::ImageSource::create):

Make constructors private.

  • platform/graphics/cg/GraphicsContext3DCG.cpp:

(WebCore::GraphicsContext3D::ImageExtractor::extractImage):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r230331 r230334  
     12018-04-06  Antti Koivisto  <antti@apple.com>
     2
     3        Tighten ImageSource to have BitmapImage pointer instead of Image
     4        https://bugs.webkit.org/show_bug.cgi?id=184356
     5
     6        Reviewed by Said Abou-Hallawa.
     7
     8        ImageSource is an implementation detail of BitmapImage, not a generic type.
     9
     10        * loader/ImageLoader.cpp:
     11        (WebCore::ImageLoader::decode):
     12        * platform/graphics/BitmapImage.h:
     13        * platform/graphics/Image.h:
     14        (WebCore::Image::decode): Deleted.
     15        (WebCore::Image::imageFrameAvailableAtIndex): Deleted.
     16
     17        Also make some BitmapImage specific functions non-virtual and remove them from Image.
     18
     19        * platform/graphics/ImageSource.cpp:
     20        (WebCore::ImageSource::ImageSource):
     21        * platform/graphics/ImageSource.h:
     22        (WebCore::ImageSource::create):
     23
     24        Make constructors private.
     25
     26        * platform/graphics/cg/GraphicsContext3DCG.cpp:
     27        (WebCore::GraphicsContext3D::ImageExtractor::extractImage):
     28
    1292018-04-06  Brent Fulgham  <bfulgham@apple.com>
    230
  • trunk/Source/WebCore/loader/ImageLoader.cpp

    r226638 r230334  
    2323#include "ImageLoader.h"
    2424
     25#include "BitmapImage.h"
    2526#include "CachedImage.h"
    2627#include "CachedResourceLoader.h"
     
    419420
    420421    Image* image = m_image->image();
    421     if (!image->isBitmapImage()) {
     422    if (!is<BitmapImage>(image)) {
    422423        decodeError("Invalid image type.");
    423424        return;
    424425    }
    425    
    426     image->decode([promises = WTFMove(m_decodingPromises)]() mutable {
     426
     427    auto& bitmapImage = downcast<BitmapImage>(*image);
     428    bitmapImage.decode([promises = WTFMove(m_decodingPromises)]() mutable {
    427429        for (auto& promise : promises)
    428430            promise->resolve();
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r225428 r230334  
    100100    size_t currentFrame() const { return m_currentFrame; }
    101101    bool currentFrameKnownToBeOpaque() const override { return !frameHasAlphaAtIndex(currentFrame()); }
    102     ImageOrientation orientationForCurrentFrame() const override { return frameOrientationAtIndex(currentFrame()); }
     102    ImageOrientation orientationForCurrentFrame() const { return frameOrientationAtIndex(currentFrame()); }
    103103    bool canAnimate() const;
    104104
     
    136136#if USE(CG)
    137137    NativeImagePtr nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) override;
    138     Vector<NativeImagePtr> framesNativeImages() override;
    139 #endif
     138    Vector<NativeImagePtr> framesNativeImages();
     139#endif
     140
     141    void imageFrameAvailableAtIndex(size_t);
     142    void decode(Function<void()>&&);
    140143
    141144protected:
     
    198201    void setCurrentFrameDecodingStatusIfNecessary(DecodingStatus);
    199202    bool isBitmapImage() const override { return true; }
    200     void decode(WTF::Function<void()>&&) override;
    201203    void callDecodingCallbacks();
    202     void imageFrameAvailableAtIndex(size_t) override;
    203204    void dump(WTF::TextStream&) const override;
    204205
  • trunk/Source/WebCore/platform/graphics/Image.h

    r227594 r230334  
    138138    bool animationPending() const { return m_animationStartTimer.isActive(); }
    139139
    140     virtual void decode(WTF::Function<void()>&&) { }
    141     virtual void imageFrameAvailableAtIndex(size_t) { }
    142 
    143140    // Typically the CachedImage that owns us.
    144141    ImageObserver* imageObserver() const { return m_imageObserver; }
     
    153150    virtual NativeImagePtr nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) { return nullptr; }
    154151    virtual NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) { return nullptr; }
    155     virtual ImageOrientation orientationForCurrentFrame() const { return ImageOrientation(); }
    156     virtual Vector<NativeImagePtr> framesNativeImages() { return { }; }
    157152
    158153    // Accessors for native image formats.
  • trunk/Source/WebCore/platform/graphics/ImageSource.cpp

    r228974 r230334  
    2727#include "ImageSource.h"
    2828
    29 #include "Image.h"
     29#include "BitmapImage.h"
    3030#include "ImageDecoder.h"
    3131#include "ImageObserver.h"
     
    3939namespace WebCore {
    4040
    41 ImageSource::ImageSource(Image* image, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
     41ImageSource::ImageSource(BitmapImage* image, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
    4242    : m_image(image)
    4343    , m_alphaOption(alphaOption)
  • trunk/Source/WebCore/platform/graphics/ImageSource.h

    r225798 r230334  
    3636namespace WebCore {
    3737
     38class BitmapImage;
    3839class GraphicsContext;
    39 class Image;
    4040class ImageDecoder;
    4141class URL;
     
    4444    friend class BitmapImage;
    4545public:
    46     ImageSource(Image*, AlphaOption = AlphaOption::Premultiplied, GammaAndColorProfileOption = GammaAndColorProfileOption::Applied);
    47     ImageSource(NativeImagePtr&&);
    4846    ~ImageSource();
    4947
    50     static Ref<ImageSource> create(Image* image, AlphaOption alphaOption = AlphaOption::Premultiplied, GammaAndColorProfileOption gammaAndColorProfileOption = GammaAndColorProfileOption::Applied)
     48    static Ref<ImageSource> create(BitmapImage* image, AlphaOption alphaOption = AlphaOption::Premultiplied, GammaAndColorProfileOption gammaAndColorProfileOption = GammaAndColorProfileOption::Applied)
    5149    {
    5250        return adoptRef(*new ImageSource(image, alphaOption, gammaAndColorProfileOption));
     
    124122
    125123private:
     124    ImageSource(BitmapImage*, AlphaOption = AlphaOption::Premultiplied, GammaAndColorProfileOption = GammaAndColorProfileOption::Applied);
     125    ImageSource(NativeImagePtr&&);
     126
    126127    template<typename T, T (ImageDecoder::*functor)() const>
    127128    T metadata(const T& defaultValue, std::optional<T>* cachedValue = nullptr);
     
    156157    void dump(TextStream&);
    157158
    158     Image* m_image { nullptr };
     159    BitmapImage* m_image { nullptr };
    159160    RefPtr<ImageDecoder> m_decoder;
    160161    AlphaOption m_alphaOption { AlphaOption::Premultiplied };
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp

    r228091 r230334  
    4949    AlphaOption alphaOption = premultiplyAlpha ? AlphaOption::Premultiplied : AlphaOption::NotPremultiplied;
    5050    GammaAndColorProfileOption gammaAndColorProfileOption = ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied;
    51     ImageSource source(nullptr, alphaOption, gammaAndColorProfileOption);
     51    auto source = ImageSource::create(nullptr, alphaOption, gammaAndColorProfileOption);
    5252    m_alphaOp = AlphaDoNothing;
    5353
    5454    if (m_image->data()) {
    55         source.setData(m_image->data(), true);
    56         if (!source.frameCount())
     55        source->setData(m_image->data(), true);
     56        if (!source->frameCount())
    5757            return false;
    58         m_imageSurface = source.createFrameImageAtIndex(0);
     58        m_imageSurface = source->createFrameImageAtIndex(0);
    5959    } else {
    6060        m_imageSurface = m_image->nativeImageForCurrentFrame();
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp

    r229309 r230334  
    326326    bool hasAlpha = !m_image->currentFrameKnownToBeOpaque();
    327327    if ((ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAlpha)) && m_image->data()) {
    328         ImageSource source(nullptr, AlphaOption::NotPremultiplied, ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied);
    329         source.setData(m_image->data(), true);
    330         if (!source.frameCount())
     328        auto source = ImageSource::create(nullptr, AlphaOption::NotPremultiplied, ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied);
     329        source->setData(m_image->data(), true);
     330        if (!source->frameCount())
    331331            return false;
    332332
    333         m_decodedImage = source.createFrameImageAtIndex(0);
     333        m_decodedImage = source->createFrameImageAtIndex(0);
    334334        m_cgImage = m_decodedImage;
    335335    } else
  • trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm

    r216702 r230334  
    106106
    107107    m_tiffRep = data;
    108     return m_tiffRep.get();
    109 
    110    
     108    return m_tiffRep.get();   
    111109}
    112110
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r230211 r230334  
    2828#include "RenderLayerBacking.h"
    2929
     30#include "BitmapImage.h"
    3031#include "CSSAnimationController.h"
    3132#include "CanvasRenderingContext.h"
     
    21902191
    21912192        auto* image = cachedImage->imageForRenderer(&imageRenderer);
    2192         if (!image->isBitmapImage())
     2193        if (!is<BitmapImage>(image))
    21932194            return false;
    21942195
    2195         if (image->orientationForCurrentFrame() != DefaultImageOrientation)
     2196        if (downcast<BitmapImage>(*image).orientationForCurrentFrame() != DefaultImageOrientation)
    21962197            return false;
    21972198
Note: See TracChangeset for help on using the changeset viewer.