Title: [124688] trunk/Source
- Revision
- 124688
- Author
- [email protected]
- Date
- 2012-08-03 20:25:21 -0700 (Fri, 03 Aug 2012)
Log Message
[chromium] Add API to make it possible to request all variants of a WebImage
https://bugs.webkit.org/show_bug.cgi?id=92933
Reviewed by Adam Barth.
Part of http://crbug.com/138550
Source/Platform:
* chromium/public/WebImage.h:
(WebImage):
Source/WebKit/chromium:
* src/WebImageSkia.cpp:
(WebKit::WebImage::framesFromData):
(WebKit):
Modified Paths
Diff
Modified: trunk/Source/Platform/ChangeLog (124687 => 124688)
--- trunk/Source/Platform/ChangeLog 2012-08-04 03:13:38 UTC (rev 124687)
+++ trunk/Source/Platform/ChangeLog 2012-08-04 03:25:21 UTC (rev 124688)
@@ -1,3 +1,15 @@
+2012-08-03 Nico Weber <[email protected]>
+
+ [chromium] Add API to make it possible to request all variants of a WebImage
+ https://bugs.webkit.org/show_bug.cgi?id=92933
+
+ Reviewed by Adam Barth.
+
+ Part of http://crbug.com/138550
+
+ * chromium/public/WebImage.h:
+ (WebImage):
+
2012-08-03 Alexandre Elias <[email protected]>
[chromium] Move ubercomp quads back into CC
Modified: trunk/Source/Platform/chromium/public/WebImage.h (124687 => 124688)
--- trunk/Source/Platform/chromium/public/WebImage.h 2012-08-04 03:13:38 UTC (rev 124687)
+++ trunk/Source/Platform/chromium/public/WebImage.h 2012-08-04 03:25:21 UTC (rev 124688)
@@ -32,6 +32,7 @@
#define WebImage_h
#include "WebCommon.h"
+#include "WebVector.h"
#include <SkBitmap.h>
@@ -68,6 +69,10 @@
// the first frame is returned.
WEBKIT_EXPORT static WebImage fromData(const WebData&, const WebSize& desiredSize);
+ // Returns a list of all frames in the image. Only the first frame at each pixel
+ // size will be returned.
+ WEBKIT_EXPORT static WebVector<WebImage> framesFromData(const WebData&);
+
WEBKIT_EXPORT void reset();
WEBKIT_EXPORT void assign(const WebImage&);
Modified: trunk/Source/WebKit/chromium/ChangeLog (124687 => 124688)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-08-04 03:13:38 UTC (rev 124687)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-08-04 03:25:21 UTC (rev 124688)
@@ -1,3 +1,16 @@
+2012-08-03 Nico Weber <[email protected]>
+
+ [chromium] Add API to make it possible to request all variants of a WebImage
+ https://bugs.webkit.org/show_bug.cgi?id=92933
+
+ Reviewed by Adam Barth.
+
+ Part of http://crbug.com/138550
+
+ * src/WebImageSkia.cpp:
+ (WebKit::WebImage::framesFromData):
+ (WebKit):
+
2012-08-03 Yaron Friedman <[email protected]>
[Chrome-Android] - Prepare apk tests for switch to checked in SDK.
Modified: trunk/Source/WebKit/chromium/src/WebImageSkia.cpp (124687 => 124688)
--- trunk/Source/WebKit/chromium/src/WebImageSkia.cpp 2012-08-04 03:13:38 UTC (rev 124687)
+++ trunk/Source/WebKit/chromium/src/WebImageSkia.cpp 2012-08-04 03:25:21 UTC (rev 124688)
@@ -38,10 +38,12 @@
#include "platform/WebData.h"
#include "platform/WebSize.h"
+#include <algorithm>
#include <public/WebImage.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
+#include <wtf/Vector.h>
using namespace WebCore;
@@ -84,6 +86,36 @@
return WebImage(frame->bitmap());
}
+WebVector<WebImage> WebImage::framesFromData(const WebData& data)
+{
+ // This is to protect from malicious images. It should be big enough that it's never hit in pracice.
+ const size_t maxFrameCount = 8;
+
+ ImageSource source;
+ source.setData(PassRefPtr<SharedBuffer>(data).get(), true);
+ if (!source.isSizeAvailable())
+ return WebVector<WebImage>();
+
+ // Frames are arranged by decreasing size, then decreasing bit depth.
+ // Keep the first frame at every size, has the highest bit depth.
+ const size_t frameCount = source.frameCount();
+ IntSize lastSize;
+
+ Vector<WebImage> frames;
+ for (size_t i = 0; i < std::min(frameCount, maxFrameCount); ++i) {
+ const IntSize frameSize = source.frameSizeAtIndex(i);
+ if (frameSize == lastSize)
+ continue;
+ lastSize = frameSize;
+
+ OwnPtr<NativeImageSkia> frame = adoptPtr(source.createFrameAtIndex(i));
+ if (frame)
+ frames.append(WebImage(frame->bitmap()));
+ }
+
+ return frames;
+}
+
void WebImage::reset()
{
m_bitmap.reset();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes