Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (128941 => 128942)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-09-18 22:43:35 UTC (rev 128941)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-09-18 23:19:42 UTC (rev 128942)
@@ -1,5 +1,21 @@
2012-09-18 Alpha Lam <[email protected]>
+ Unreviewed, rolling out r128939.
+ http://trac.webkit.org/changeset/128939
+ https://bugs.webkit.org/show_bug.cgi?id=96135
+
+ Failing test_shell_tests.
+
+ * WebKit.gypi:
+ * src/WebImageSkia.cpp:
+ (WebKit::WebImage::fromData):
+ (WebKit::WebImage::framesFromData):
+ * tests/WebImageTest.cpp: Removed.
+ * tests/data/black-and-white.ico: Removed.
+ * tests/data/white-1x1.png: Removed.
+
+2012-09-18 Alpha Lam <[email protected]>
+
[chromium] WebImage should use ImageDecoder directly
https://bugs.webkit.org/show_bug.cgi?id=96135
Modified: trunk/Source/WebKit/chromium/WebKit.gypi (128941 => 128942)
--- trunk/Source/WebKit/chromium/WebKit.gypi 2012-09-18 22:43:35 UTC (rev 128941)
+++ trunk/Source/WebKit/chromium/WebKit.gypi 2012-09-18 23:19:42 UTC (rev 128942)
@@ -103,7 +103,6 @@
'tests/WebCompositorInputHandlerImplTest.cpp',
'tests/WebFrameTest.cpp',
'tests/WebInputEventConversionTest.cpp',
- 'tests/WebImageTest.cpp',
'tests/WebMediaPlayerClientImplTest.cpp',
'tests/WebPageNewSerializerTest.cpp',
'tests/WebPageSerializerTest.cpp',
Modified: trunk/Source/WebKit/chromium/src/WebImageSkia.cpp (128941 => 128942)
--- trunk/Source/WebKit/chromium/src/WebImageSkia.cpp 2012-09-18 22:43:35 UTC (rev 128941)
+++ trunk/Source/WebKit/chromium/src/WebImageSkia.cpp 2012-09-18 23:19:42 UTC (rev 128942)
@@ -31,7 +31,7 @@
#include "config.h"
#include "Image.h"
-#include "ImageDecoder.h"
+#include "ImageSource.h"
#include "NativeImageSkia.h"
#include "SharedBuffer.h"
@@ -51,20 +51,19 @@
WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize)
{
- RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data);
- OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(*buffer.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied)));
- decoder->setData(buffer.get(), true);
- if (!decoder->isSizeAvailable())
+ ImageSource source;
+ source.setData(PassRefPtr<SharedBuffer>(data).get(), true);
+ if (!source.isSizeAvailable())
return WebImage();
// Frames are arranged by decreasing size, then decreasing bit depth.
// Pick the frame closest to |desiredSize|'s area without being smaller,
// which has the highest bit depth.
- const size_t frameCount = decoder->frameCount();
+ const size_t frameCount = source.frameCount();
size_t index = 0; // Default to first frame if none are large enough.
int frameAreaAtIndex = 0;
for (size_t i = 0; i < frameCount; ++i) {
- const IntSize frameSize = decoder->frameSizeAtIndex(i);
+ const IntSize frameSize = source.frameSizeAtIndex(i);
if (WebSize(frameSize) == desiredSize) {
index = i;
break; // Perfect match.
@@ -80,15 +79,11 @@
}
}
- ImageFrame* frame = decoder->frameBufferAtIndex(index);
+ OwnPtr<NativeImageSkia> frame = adoptPtr(source.createFrameAtIndex(index));
if (!frame)
return WebImage();
- OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage());
- if (!image)
- return WebImage();
-
- return WebImage(image->bitmap());
+ return WebImage(frame->bitmap());
}
WebVector<WebImage> WebImage::framesFromData(const WebData& data)
@@ -96,31 +91,26 @@
// This is to protect from malicious images. It should be big enough that it's never hit in pracice.
const size_t maxFrameCount = 8;
- RefPtr<SharedBuffer> buffer = PassRefPtr<SharedBuffer>(data);
- OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(*buffer.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied)));
- decoder->setData(buffer.get(), true);
- if (!decoder->isSizeAvailable())
+ 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 = decoder->frameCount();
+ 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 = decoder->frameSizeAtIndex(i);
+ const IntSize frameSize = source.frameSizeAtIndex(i);
if (frameSize == lastSize)
continue;
lastSize = frameSize;
- ImageFrame* frame = decoder->frameBufferAtIndex(i);
- if (!frame)
- continue;
-
- OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage());
- if (image.get())
- frames.append(WebImage(image->bitmap()));
+ OwnPtr<NativeImageSkia> frame = adoptPtr(source.createFrameAtIndex(i));
+ if (frame)
+ frames.append(WebImage(frame->bitmap()));
}
return frames;
Deleted: trunk/Source/WebKit/chromium/tests/WebImageTest.cpp (128941 => 128942)
--- trunk/Source/WebKit/chromium/tests/WebImageTest.cpp 2012-09-18 22:43:35 UTC (rev 128941)
+++ trunk/Source/WebKit/chromium/tests/WebImageTest.cpp 2012-09-18 23:19:42 UTC (rev 128942)
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <public/WebImage.h>
-
-#include "FileSystem.h"
-#include "SharedBuffer.h"
-#include <gtest/gtest.h>
-#include <public/WebData.h>
-#include <public/WebSize.h>
-#include <webkit/support/webkit_support.h>
-
-using namespace WebCore;
-using namespace WebKit;
-
-namespace {
-
-static PassRefPtr<SharedBuffer> readFile(const char* fileName)
-{
- String filePath = webkit_support::GetWebKitRootDir();
- filePath.append("/Source/WebKit/chromium/tests/data/");
- filePath.append(fileName);
-
- long long fileSize;
- if (!getFileSize(filePath, fileSize))
- return 0;
-
- PlatformFileHandle handle = openFile(filePath, OpenForRead);
- int fileLength = static_cast<int>(fileSize);
- Vector<char> buffer(fileLength);
- readFromFile(handle, buffer.data(), fileLength);
- closeFile(handle);
- return SharedBuffer::adoptVector(buffer);
-}
-
-TEST(WebImageTest, PNGImage)
-{
- RefPtr<SharedBuffer> data = ""
- ASSERT_TRUE(data.get());
-
- WebImage image = WebImage::fromData(WebData(data), WebSize());
- EXPECT_TRUE(image.size() == WebSize(1, 1));
- SkAutoLockPixels autoLock(image.getSkBitmap());
- EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), image.getSkBitmap().getColor(0, 0));
-}
-
-TEST(WebImageTest, ICOImage)
-{
- RefPtr<SharedBuffer> data = ""
- ASSERT_TRUE(data.get());
-
- WebVector<WebImage> images = WebImage::framesFromData(WebData(data));
- ASSERT_EQ(2u, images.size());
- EXPECT_TRUE(images[0].size() == WebSize(2, 2));
- EXPECT_TRUE(images[1].size() == WebSize(1, 1));
- SkAutoLockPixels autoLock1(images[0].getSkBitmap());
- EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), images[0].getSkBitmap().getColor(0, 0));
- SkAutoLockPixels autoLock2(images[1].getSkBitmap());
- EXPECT_EQ(SkColorSetARGB(255, 0, 0, 0), images[1].getSkBitmap().getColor(0, 0));
-}
-
-} // namespace
Deleted: trunk/Source/WebKit/chromium/tests/data/black-and-white.ico (128941 => 128942)
--- trunk/Source/WebKit/chromium/tests/data/black-and-white.ico 2012-09-18 22:43:35 UTC (rev 128941)
+++ trunk/Source/WebKit/chromium/tests/data/black-and-white.ico 2012-09-18 23:19:42 UTC (rev 128942)
@@ -1 +0,0 @@
- 8 &