Changeset 191352 in webkit
- Timestamp:
- Oct 20, 2015, 1:38:03 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r191351 r191352 1 2015-10-20 Simon Fraser <simon.fraser@apple.com> 2 3 Add basic TextStream output for Images 4 https://bugs.webkit.org/show_bug.cgi?id=150350 5 6 Reviewed by Darin Adler. 7 8 Add a TextStream output operator for Image, and virtual dump() member functions 9 that the various image types override to dump their own data. 10 11 Add isFoo() functions for each image type (surprising that these didn't already 12 exist) so we can print the image type. 13 14 Make isAnimated() const, and isBitmapImage() private. 15 16 * platform/graphics/BitmapImage.cpp: 17 (WebCore::BitmapImage::dump): 18 * platform/graphics/BitmapImage.h: 19 * platform/graphics/CrossfadeGeneratedImage.cpp: 20 (WebCore::CrossfadeGeneratedImage::dump): 21 * platform/graphics/CrossfadeGeneratedImage.h: 22 * platform/graphics/GeneratedImage.cpp: 23 * platform/graphics/GeneratedImage.h: 24 * platform/graphics/GradientImage.cpp: 25 (WebCore::GradientImage::dump): 26 * platform/graphics/GradientImage.h: 27 * platform/graphics/Image.cpp: 28 (WebCore::Image::dump): 29 (WebCore::operator<<): 30 * platform/graphics/Image.h: 31 (WebCore::Image::isGeneratedImage): 32 (WebCore::Image::isCrossfadeGeneratedImage): 33 (WebCore::Image::isNamedImageGeneratedImage): 34 (WebCore::Image::isGradientImage): 35 (WebCore::Image::isSVGImage): 36 (WebCore::Image::isAnimated): 37 * platform/graphics/NamedImageGeneratedImage.cpp: 38 (WebCore::NamedImageGeneratedImage::dump): 39 * platform/graphics/NamedImageGeneratedImage.h: 40 * platform/graphics/cg/PDFDocumentImage.cpp: 41 (WebCore::PDFDocumentImage::dump): 42 * platform/graphics/cg/PDFDocumentImage.h: 43 * svg/graphics/SVGImage.cpp: 44 (WebCore::SVGImage::dump): 45 * svg/graphics/SVGImage.h: 46 1 47 2015-10-20 Chris Dumez <cdumez@apple.com> 2 48 -
TabularUnified trunk/Source/WebCore/platform/graphics/BitmapImage.cpp ¶
r190910 r191352 34 34 #include "IntRect.h" 35 35 #include "MIMETypeRegistry.h" 36 #include "TextStream.h" 36 37 #include "Timer.h" 37 38 #include <wtf/CurrentTime.h> … … 710 711 } 711 712 712 } 713 void BitmapImage::dump(TextStream& ts) const 714 { 715 Image::dump(ts); 716 717 ts.dumpProperty("type", m_source.filenameExtension()); 718 719 if (isAnimated()) { 720 ts.dumpProperty("frame-count", m_frameCount); 721 ts.dumpProperty("repetitions", m_repetitionCount); 722 ts.dumpProperty("current-frame", m_currentFrame); 723 } 724 725 if (allowSubsampling()) 726 ts.dumpProperty("allow-subsampling", allowSubsampling()); 727 if (m_isSolidColor) 728 ts.dumpProperty("solid-color", m_isSolidColor); 729 730 if (m_imageOrientation != OriginTopLeft) 731 ts.dumpProperty("orientation", m_imageOrientation); 732 } 733 734 } -
TabularUnified trunk/Source/WebCore/platform/graphics/BitmapImage.h ¶
r190910 r191352 122 122 virtual ~BitmapImage(); 123 123 124 virtual bool isBitmapImage() const override { return true; }125 126 124 virtual bool hasSingleSecurityOrigin() const override; 127 125 … … 180 178 virtual bool currentFrameKnownToBeOpaque() override; 181 179 182 virtual bool isAnimated() override { return m_frameCount > 1; }180 virtual bool isAnimated() const override { return m_frameCount > 1; } 183 181 184 182 bool canAnimate(); … … 188 186 189 187 private: 188 virtual bool isBitmapImage() const override { return true; } 189 190 190 void updateSize(ImageOrientationDescription = ImageOrientationDescription()) const; 191 191 void determineMinimumSubsamplingLevel() const; … … 292 292 void startTimer(double delay); 293 293 294 virtual void dump(TextStream&) const override; 295 294 296 ImageSource m_source; 295 297 mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image). -
TabularUnified trunk/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp ¶
r191049 r191352 30 30 #include "GraphicsContext.h" 31 31 #include "ImageBuffer.h" 32 #include "TextStream.h" 32 33 33 34 namespace WebCore { … … 110 111 } 111 112 113 void CrossfadeGeneratedImage::dump(TextStream& ts) const 114 { 115 GeneratedImage::dump(ts); 116 ts.dumpProperty("from-image", m_fromImage.get()); 117 ts.dumpProperty("to-image", m_toImage.get()); 118 ts.dumpProperty("percentage", m_percentage); 112 119 } 120 121 } -
TabularUnified trunk/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h ¶
r191049 r191352 56 56 57 57 private: 58 virtual bool isCrossfadeGeneratedImage() const override { return true; } 59 virtual void dump(TextStream&) const override; 60 58 61 void drawCrossfade(GraphicsContext&); 59 62 -
TabularUnified trunk/Source/WebCore/platform/graphics/GeneratedImage.cpp ¶
r148921 r191352 34 34 #include "FloatSize.h" 35 35 36 37 36 namespace WebCore { 38 37 -
TabularUnified trunk/Source/WebCore/platform/graphics/GeneratedImage.h ¶
r190910 r191352 60 60 61 61 private: 62 virtual bool isGeneratedImage() const override { return true; } 63 62 64 FloatSize m_size; 63 65 }; -
TabularUnified trunk/Source/WebCore/platform/graphics/GradientImage.cpp ¶
r191049 r191352 31 31 #include "ImageBuffer.h" 32 32 #include "Length.h" 33 #include "TextStream.h" 33 34 34 35 namespace WebCore { … … 95 96 } 96 97 98 void GradientImage::dump(TextStream& ts) const 99 { 100 GeneratedImage::dump(ts); 101 // FIXME: dump the gradient. 97 102 } 103 104 } -
TabularUnified trunk/Source/WebCore/platform/graphics/GradientImage.h ¶
r190910 r191352 54 54 55 55 private: 56 virtual bool isGradientImage() const override { return true; } 57 virtual void dump(TextStream&) const override; 58 56 59 RefPtr<Gradient> m_gradient; 57 60 std::unique_ptr<ImageBuffer> m_cachedImageBuffer; -
TabularUnified trunk/Source/WebCore/platform/graphics/Image.cpp ¶
r190910 r191352 35 35 #include "MIMETypeRegistry.h" 36 36 #include "SharedBuffer.h" 37 #include "TextStream.h" 37 38 #include <math.h> 38 39 #include <wtf/MainThread.h> … … 271 272 } 272 273 273 } 274 void Image::dump(TextStream& ts) const 275 { 276 if (isAnimated()) 277 ts.dumpProperty("animated", isAnimated()); 278 279 if (isNull()) 280 ts.dumpProperty("is-null-image", true); 281 282 ts.dumpProperty("size", size()); 283 } 284 285 TextStream& operator<<(TextStream& ts, const Image& image) 286 { 287 TextStream::GroupScope scope(ts); 288 289 if (image.isBitmapImage()) 290 ts << "bitmap image"; 291 else if (image.isCrossfadeGeneratedImage()) 292 ts << "crossfade image"; 293 else if (image.isNamedImageGeneratedImage()) 294 ts << "named image"; 295 else if (image.isGradientImage()) 296 ts << "gradient image"; 297 else if (image.isSVGImage()) 298 ts << "svg image"; 299 else if (image.isPDFDocumentImage()) 300 ts << "pdf image"; 301 302 image.dump(ts); 303 return ts; 304 } 305 306 } -
TabularUnified trunk/Source/WebCore/platform/graphics/Image.h ¶
r191326 r191352 81 81 WEBCORE_EXPORT static bool supportsType(const String&); 82 82 83 virtual bool isBitmapImage() const { return false; } 84 virtual bool isGeneratedImage() const { return false; } 85 virtual bool isCrossfadeGeneratedImage() const { return false; } 86 virtual bool isNamedImageGeneratedImage() const { return false; } 87 virtual bool isGradientImage() const { return false; } 83 88 virtual bool isSVGImage() const { return false; } 84 virtual bool isBitmapImage() const { return false; }85 89 virtual bool isPDFDocumentImage() const { return false; } 90 86 91 virtual bool currentFrameKnownToBeOpaque() = 0; 87 88 virtual bool isAnimated() { return false; } 92 virtual bool isAnimated() const { return false; } 89 93 90 94 // Derived classes should override this if they can assure that … … 178 182 #endif 179 183 184 virtual void dump(TextStream&) const; 185 180 186 protected: 181 187 Image(ImageObserver* = nullptr); … … 201 207 }; 202 208 209 TextStream& operator<<(TextStream&, const Image&); 210 203 211 } // namespace WebCore 204 212 -
TabularUnified trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.cpp ¶
r190911 r191352 30 30 #include "GraphicsContext.h" 31 31 #include "ImageBuffer.h" 32 #include "TextStream.h" 32 33 #include "Theme.h" 33 34 … … 86 87 } 87 88 89 void NamedImageGeneratedImage::dump(TextStream& ts) const 90 { 91 GeneratedImage::dump(ts); 92 ts.dumpProperty("name", m_name); 88 93 } 94 95 } -
TabularUnified trunk/Source/WebCore/platform/graphics/NamedImageGeneratedImage.h ¶
r190910 r191352 48 48 49 49 private: 50 virtual bool isNamedImageGeneratedImage() const override { return true; } 51 virtual void dump(TextStream&) const override; 52 50 53 String m_name; 51 54 }; -
TabularUnified trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp ¶
r191049 r191352 41 41 #include "Length.h" 42 42 #include "SharedBuffer.h" 43 #include "TextStream.h" 43 44 #include <CoreGraphics/CGContext.h> 44 45 #include <CoreGraphics/CGPDFDocument.h> … … 265 266 #endif // !USE(PDFKIT_FOR_PDFDOCUMENTIMAGE) 266 267 268 void PDFDocumentImage::dump(TextStream& ts) const 269 { 270 Image::dump(ts); 271 ts.dumpProperty("page-count", pageCount()); 272 ts.dumpProperty("crop-box", m_cropBox); 273 if (m_rotationDegrees) 274 ts.dumpProperty("rotation", m_rotationDegrees); 275 } 276 267 277 } 268 278 -
TabularUnified trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h ¶
r189144 r191352 75 75 virtual bool currentFrameKnownToBeOpaque() override { return false; } 76 76 77 virtual void dump(TextStream&) const override; 78 77 79 void createPDFDocument(); 78 80 void computeBoundsForCurrentPage(); -
TabularUnified trunk/Source/WebCore/svg/graphics/SVGImage.cpp ¶
r190910 r191352 46 46 #include "SVGSVGElement.h" 47 47 #include "Settings.h" 48 #include "TextStream.h" 48 49 49 50 namespace WebCore { … … 401 402 } 402 403 403 } 404 void SVGImage::dump(TextStream& ts) const 405 { 406 Image::dump(ts); 407 ts.dumpProperty("url", m_url.string()); 408 } 409 410 411 } -
TabularUnified trunk/Source/WebCore/svg/graphics/SVGImage.h ¶
r190910 r191352 91 91 virtual bool currentFrameKnownToBeOpaque() override { return false; } 92 92 93 virtual void dump(TextStream&) const override; 94 93 95 SVGImage(ImageObserver&, const URL&); 94 96 virtual void draw(GraphicsContext&, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode, ImageOrientationDescription) override;
Note:
See TracChangeset
for help on using the changeset viewer.