Changeset 230334 in webkit
- Timestamp:
- Apr 6, 2018 9:29:52 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230331 r230334 1 2018-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 1 29 2018-04-06 Brent Fulgham <bfulgham@apple.com> 2 30 -
trunk/Source/WebCore/loader/ImageLoader.cpp
r226638 r230334 23 23 #include "ImageLoader.h" 24 24 25 #include "BitmapImage.h" 25 26 #include "CachedImage.h" 26 27 #include "CachedResourceLoader.h" … … 419 420 420 421 Image* image = m_image->image(); 421 if (!i mage->isBitmapImage()) {422 if (!is<BitmapImage>(image)) { 422 423 decodeError("Invalid image type."); 423 424 return; 424 425 } 425 426 image->decode([promises = WTFMove(m_decodingPromises)]() mutable { 426 427 auto& bitmapImage = downcast<BitmapImage>(*image); 428 bitmapImage.decode([promises = WTFMove(m_decodingPromises)]() mutable { 427 429 for (auto& promise : promises) 428 430 promise->resolve(); -
trunk/Source/WebCore/platform/graphics/BitmapImage.h
r225428 r230334 100 100 size_t currentFrame() const { return m_currentFrame; } 101 101 bool currentFrameKnownToBeOpaque() const override { return !frameHasAlphaAtIndex(currentFrame()); } 102 ImageOrientation orientationForCurrentFrame() const override{ return frameOrientationAtIndex(currentFrame()); }102 ImageOrientation orientationForCurrentFrame() const { return frameOrientationAtIndex(currentFrame()); } 103 103 bool canAnimate() const; 104 104 … … 136 136 #if USE(CG) 137 137 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()>&&); 140 143 141 144 protected: … … 198 201 void setCurrentFrameDecodingStatusIfNecessary(DecodingStatus); 199 202 bool isBitmapImage() const override { return true; } 200 void decode(WTF::Function<void()>&&) override;201 203 void callDecodingCallbacks(); 202 void imageFrameAvailableAtIndex(size_t) override;203 204 void dump(WTF::TextStream&) const override; 204 205 -
trunk/Source/WebCore/platform/graphics/Image.h
r227594 r230334 138 138 bool animationPending() const { return m_animationStartTimer.isActive(); } 139 139 140 virtual void decode(WTF::Function<void()>&&) { }141 virtual void imageFrameAvailableAtIndex(size_t) { }142 143 140 // Typically the CachedImage that owns us. 144 141 ImageObserver* imageObserver() const { return m_imageObserver; } … … 153 150 virtual NativeImagePtr nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) { return nullptr; } 154 151 virtual NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) { return nullptr; } 155 virtual ImageOrientation orientationForCurrentFrame() const { return ImageOrientation(); }156 virtual Vector<NativeImagePtr> framesNativeImages() { return { }; }157 152 158 153 // Accessors for native image formats. -
trunk/Source/WebCore/platform/graphics/ImageSource.cpp
r228974 r230334 27 27 #include "ImageSource.h" 28 28 29 #include " Image.h"29 #include "BitmapImage.h" 30 30 #include "ImageDecoder.h" 31 31 #include "ImageObserver.h" … … 39 39 namespace WebCore { 40 40 41 ImageSource::ImageSource( Image* image, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)41 ImageSource::ImageSource(BitmapImage* image, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 42 42 : m_image(image) 43 43 , m_alphaOption(alphaOption) -
trunk/Source/WebCore/platform/graphics/ImageSource.h
r225798 r230334 36 36 namespace WebCore { 37 37 38 class BitmapImage; 38 39 class GraphicsContext; 39 class Image;40 40 class ImageDecoder; 41 41 class URL; … … 44 44 friend class BitmapImage; 45 45 public: 46 ImageSource(Image*, AlphaOption = AlphaOption::Premultiplied, GammaAndColorProfileOption = GammaAndColorProfileOption::Applied);47 ImageSource(NativeImagePtr&&);48 46 ~ImageSource(); 49 47 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) 51 49 { 52 50 return adoptRef(*new ImageSource(image, alphaOption, gammaAndColorProfileOption)); … … 124 122 125 123 private: 124 ImageSource(BitmapImage*, AlphaOption = AlphaOption::Premultiplied, GammaAndColorProfileOption = GammaAndColorProfileOption::Applied); 125 ImageSource(NativeImagePtr&&); 126 126 127 template<typename T, T (ImageDecoder::*functor)() const> 127 128 T metadata(const T& defaultValue, std::optional<T>* cachedValue = nullptr); … … 156 157 void dump(TextStream&); 157 158 158 Image* m_image { nullptr };159 BitmapImage* m_image { nullptr }; 159 160 RefPtr<ImageDecoder> m_decoder; 160 161 AlphaOption m_alphaOption { AlphaOption::Premultiplied }; -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
r228091 r230334 49 49 AlphaOption alphaOption = premultiplyAlpha ? AlphaOption::Premultiplied : AlphaOption::NotPremultiplied; 50 50 GammaAndColorProfileOption gammaAndColorProfileOption = ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied; 51 ImageSource source(nullptr, alphaOption, gammaAndColorProfileOption);51 auto source = ImageSource::create(nullptr, alphaOption, gammaAndColorProfileOption); 52 52 m_alphaOp = AlphaDoNothing; 53 53 54 54 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()) 57 57 return false; 58 m_imageSurface = source .createFrameImageAtIndex(0);58 m_imageSurface = source->createFrameImageAtIndex(0); 59 59 } else { 60 60 m_imageSurface = m_image->nativeImageForCurrentFrame(); -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp
r229309 r230334 326 326 bool hasAlpha = !m_image->currentFrameKnownToBeOpaque(); 327 327 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()) 331 331 return false; 332 332 333 m_decodedImage = source .createFrameImageAtIndex(0);333 m_decodedImage = source->createFrameImageAtIndex(0); 334 334 m_cgImage = m_decodedImage; 335 335 } else -
trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm
r216702 r230334 106 106 107 107 m_tiffRep = data; 108 return m_tiffRep.get(); 109 110 108 return m_tiffRep.get(); 111 109 } 112 110 -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r230211 r230334 28 28 #include "RenderLayerBacking.h" 29 29 30 #include "BitmapImage.h" 30 31 #include "CSSAnimationController.h" 31 32 #include "CanvasRenderingContext.h" … … 2190 2191 2191 2192 auto* image = cachedImage->imageForRenderer(&imageRenderer); 2192 if (!i mage->isBitmapImage())2193 if (!is<BitmapImage>(image)) 2193 2194 return false; 2194 2195 2195 if ( image->orientationForCurrentFrame() != DefaultImageOrientation)2196 if (downcast<BitmapImage>(*image).orientationForCurrentFrame() != DefaultImageOrientation) 2196 2197 return false; 2197 2198
Note: See TracChangeset
for help on using the changeset viewer.