Changeset 129032 in webkit
- Timestamp:
- Sep 19, 2012, 12:17:47 PM (13 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r129029 r129032 1 2012-09-19 Alpha Lam <hclam@chromium.org> 2 3 [chromium] WebImage should use ImageDecoder directly 4 https://bugs.webkit.org/show_bug.cgi?id=96135 5 6 Reviewed by Adam Barth. 7 8 This patch is for preparation of deferred image decoding. 9 ImageSource will be used as a portal to access deferred image decoder 10 by BitmapImage, it should not be accessible through WebKit APIs. 11 12 WebImage now calls ImageDecoder directly which is the actual 13 implementation of an image decoder. 14 15 Tests: WebImageTest.PNGImage 16 WebImageTest.ICOImage 17 WebImageTest.BadImage 18 19 * WebKit.gypi: 20 * src/WebImageSkia.cpp: 21 (WebKit::WebImage::fromData): 22 (WebKit::WebImage::framesFromData): 23 * tests/WebImageTest.cpp: Added. 24 (WebKit): 25 (WebKit::readFile): 26 (WebKit::TEST): 27 * tests/data/black-and-white.ico: Added. 28 * tests/data/white-1x1.png: Added. 29 1 30 2012-09-19 Oli Lan <olilan@chromium.org> 2 31 -
trunk/Source/WebKit/chromium/WebKit.gypi
r128942 r129032 104 104 'tests/WebFrameTest.cpp', 105 105 'tests/WebInputEventConversionTest.cpp', 106 'tests/WebImageTest.cpp', 106 107 'tests/WebMediaPlayerClientImplTest.cpp', 107 108 'tests/WebPageNewSerializerTest.cpp', -
trunk/Source/WebKit/chromium/src/WebImageSkia.cpp
r128942 r129032 32 32 33 33 #include "Image.h" 34 #include "Image Source.h"34 #include "ImageDecoder.h" 35 35 #include "NativeImageSkia.h" 36 36 #include "SharedBuffer.h" … … 52 52 WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize) 53 53 { 54 ImageSource source; 55 source.setData(PassRefPtr<SharedBuffer>(data).get(), true); 56 if (!source.isSizeAvailable()) 54 RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data); 55 OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(*buffer.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied))); 56 if (!decoder) 57 return WebImage(); 58 59 decoder->setData(buffer.get(), true); 60 if (!decoder->isSizeAvailable()) 57 61 return WebImage(); 58 62 … … 60 64 // Pick the frame closest to |desiredSize|'s area without being smaller, 61 65 // which has the highest bit depth. 62 const size_t frameCount = source.frameCount();66 const size_t frameCount = decoder->frameCount(); 63 67 size_t index = 0; // Default to first frame if none are large enough. 64 68 int frameAreaAtIndex = 0; 65 69 for (size_t i = 0; i < frameCount; ++i) { 66 const IntSize frameSize = source.frameSizeAtIndex(i);70 const IntSize frameSize = decoder->frameSizeAtIndex(i); 67 71 if (WebSize(frameSize) == desiredSize) { 68 72 index = i; … … 80 84 } 81 85 82 OwnPtr<NativeImageSkia> frame = adoptPtr(source.createFrameAtIndex(index));86 ImageFrame* frame = decoder->frameBufferAtIndex(index); 83 87 if (!frame) 84 88 return WebImage(); 85 89 86 return WebImage(frame->bitmap()); 90 OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage()); 91 if (!image) 92 return WebImage(); 93 94 return WebImage(image->bitmap()); 87 95 } 88 96 … … 92 100 const size_t maxFrameCount = 8; 93 101 94 ImageSource source; 95 source.setData(PassRefPtr<SharedBuffer>(data).get(), true); 96 if (!source.isSizeAvailable()) 102 RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data); 103 OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(*buffer.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied))); 104 if (!decoder) 105 return WebVector<WebImage>(); 106 107 decoder->setData(buffer.get(), true); 108 if (!decoder->isSizeAvailable()) 97 109 return WebVector<WebImage>(); 98 110 99 111 // Frames are arranged by decreasing size, then decreasing bit depth. 100 112 // Keep the first frame at every size, has the highest bit depth. 101 const size_t frameCount = source.frameCount();113 const size_t frameCount = decoder->frameCount(); 102 114 IntSize lastSize; 103 115 104 116 Vector<WebImage> frames; 105 117 for (size_t i = 0; i < std::min(frameCount, maxFrameCount); ++i) { 106 const IntSize frameSize = source.frameSizeAtIndex(i);118 const IntSize frameSize = decoder->frameSizeAtIndex(i); 107 119 if (frameSize == lastSize) 108 120 continue; 109 121 lastSize = frameSize; 110 122 111 OwnPtr<NativeImageSkia> frame = adoptPtr(source.createFrameAtIndex(i)); 112 if (frame) 113 frames.append(WebImage(frame->bitmap())); 123 ImageFrame* frame = decoder->frameBufferAtIndex(i); 124 if (!frame) 125 continue; 126 127 OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage()); 128 if (image.get()) 129 frames.append(WebImage(image->bitmap())); 114 130 } 115 131
Note:
See TracChangeset
for help on using the changeset viewer.