[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
jianli at chromium.org
jianli at chromium.org
Wed Dec 22 17:56:57 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 64e5878bdf87ffe53ac9d25d91df2367dd588d11
Author: jianli at chromium.org <jianli at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 3 04:35:13 2010 +0000
[chromium] Remove dead code from PNG encoder
https://bugs.webkit.org/show_bug.cgi?id=50377
Patch by Noel Gordon <noel.gordon at gmail.com> on 2010-12-02
Reviewed by David Levin.
Also webkit style the PNG encoder files.
No change in behaviour, so no new tests.
* platform/image-encoders/skia/PNGImageEncoder.cpp:
(WebCore::encodeImpl):
(WebCore::PNGImageEncoder::encode):
* platform/image-encoders/skia/PNGImageEncoder.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73233 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8ec5437..d2b1af0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2010-12-02 Noel Gordon <noel.gordon at gmail.com>
+
+ Reviewed by David Levin.
+ [chromium] Remove dead code from PNG encoder
+ https://bugs.webkit.org/show_bug.cgi?id=50377
+
+ Also webkit style the PNG encoder files.
+
+ No change in behaviour, so no new tests.
+
+ * platform/image-encoders/skia/PNGImageEncoder.cpp:
+ (WebCore::encodeImpl):
+ (WebCore::PNGImageEncoder::encode):
+ * platform/image-encoders/skia/PNGImageEncoder.h:
+
2010-12-02 Yuta Kitamura <yutak at chromium.org>
Reviewed by Alexey Proskuryakov.
diff --git a/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp b/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
index a2e8760..dc7d067 100644
--- a/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
+++ b/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright (c) 2006-2009, Google Inc. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -14,7 +14,7 @@
* * 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
@@ -29,35 +29,19 @@
*/
#include "config.h"
+#include "PNGImageEncoder.h"
#include "IntSize.h"
#include "OwnArrayPtr.h"
-#include "PNGImageEncoder.h"
#include "Vector.h"
-
#include "SkBitmap.h"
#include "SkUnPreMultiply.h"
-
extern "C" {
#include "png.h"
}
namespace WebCore {
-// Converts BGRA->RGBA and RGBA->BGRA.
-static void convertBetweenBGRAandRGBA(const unsigned char* input, int numberOfPixels,
- unsigned char* output)
-{
- for (int x = 0; x < numberOfPixels; x++) {
- const unsigned char* pixelIn = &input[x * 4];
- unsigned char* pixelOut = &output[x * 4];
- pixelOut[0] = pixelIn[2];
- pixelOut[1] = pixelIn[1];
- pixelOut[2] = pixelIn[0];
- pixelOut[3] = pixelIn[3];
- }
-}
-
// Converts BGRA->RGBA and RGBA->BGRA and undoes alpha premultiplication.
static void preMultipliedBGRAtoRGBA(const unsigned char* input, int numberOfPixels,
unsigned char* output)
@@ -76,7 +60,6 @@ static void preMultipliedBGRAtoRGBA(const unsigned char* input, int numberOfPixe
}
}
-
// Encoder --------------------------------------------------------------------
//
// This section of the code is based on nsPNGEncoder.cpp in Mozilla
@@ -121,9 +104,7 @@ private:
static bool encodeImpl(const unsigned char* input,
const IntSize& size,
int bytesPerRow,
- Vector<unsigned char>* output,
- void (*conversionFunc)(const unsigned char*, int, unsigned char*)
- )
+ Vector<unsigned char>* output)
{
int inputColorComponents = 4;
int outputColorComponents = 4;
@@ -165,8 +146,8 @@ static bool encodeImpl(const unsigned char* input,
png_write_info(pngPtr, infoPtr);
OwnArrayPtr<unsigned char> rowPixels(new unsigned char[imageSize.width() * outputColorComponents]);
- for (int y = 0; y < imageSize.height(); y ++) {
- conversionFunc(&input[y * bytesPerRow], imageSize.width(), rowPixels.get());
+ for (int y = 0; y < imageSize.height(); ++y) {
+ preMultipliedBGRAtoRGBA(&input[y * bytesPerRow], imageSize.width(), rowPixels.get());
png_write_row(pngPtr, rowPixels.get());
}
@@ -174,27 +155,16 @@ static bool encodeImpl(const unsigned char* input,
return true;
}
-
// static
bool PNGImageEncoder::encode(const SkBitmap& image, Vector<unsigned char>* output)
{
if (image.config() != SkBitmap::kARGB_8888_Config)
- return false; // Only support ARGB at 8 bpp now.
+ return false; // Only support ARGB 32 bpp skia bitmaps.
image.lockPixels();
- bool result = encodeImpl(static_cast<unsigned char*>(
- image.getPixels()), IntSize(image.width(), image.height()),
- image.rowBytes(), output, preMultipliedBGRAtoRGBA);
+ bool result = encodeImpl(static_cast<unsigned char*>(image.getPixels()), IntSize(image.width(), image.height()), image.rowBytes(), output);
image.unlockPixels();
return result;
}
-// static
-bool PNGImageEncoder::encode(const unsigned char* input, const IntSize& size,
- int bytesPerRow,
- Vector<unsigned char>* output)
-{
- return encodeImpl(input, size, bytesPerRow, output, convertBetweenBGRAandRGBA);
-}
-
-} // namespace WebCore
+} // namespace WebCore
diff --git a/WebCore/platform/image-encoders/skia/PNGImageEncoder.h b/WebCore/platform/image-encoders/skia/PNGImageEncoder.h
index b5865d2..b8dfec3 100644
--- a/WebCore/platform/image-encoders/skia/PNGImageEncoder.h
+++ b/WebCore/platform/image-encoders/skia/PNGImageEncoder.h
@@ -1,10 +1,10 @@
/*
- * Copyright (c) 2006-2009, Google Inc. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -14,7 +14,7 @@
* * 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
@@ -33,23 +33,16 @@
#include "Vector.h"
-class IntSize;
class SkBitmap;
namespace WebCore {
- // Interface for encoding PNG data. This is a wrapper around libpng.
- class PNGImageEncoder {
- public:
- // Encodes the specific SkBitmap into the supplied vector.
- static bool encode(const SkBitmap&, WTF::Vector<unsigned char>* output);
-
- // Encodes the specified image data into the supplied vector.
- // w, h give the size of the image and bytes_per_row gives the bytes
- // per row.
- static bool encode(const unsigned char* input, const IntSize& size, int bytesPerRow, WTF::Vector<unsigned char>* output);
- };
+// Interface for encoding PNG data. This is a wrapper around libpng.
+class PNGImageEncoder {
+public:
+ static bool encode(const SkBitmap&, Vector<unsigned char>* output);
+};
-} // namespace WebCore
+} // namespace WebCore
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list