diff options
Diffstat (limited to 'base/gfx/png_codec_unittest.cc')
-rw-r--r-- | base/gfx/png_codec_unittest.cc | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/base/gfx/png_codec_unittest.cc b/base/gfx/png_codec_unittest.cc index c9734a7..9184abe 100644 --- a/base/gfx/png_codec_unittest.cc +++ b/base/gfx/png_codec_unittest.cc @@ -7,7 +7,6 @@ #include "base/gfx/png_encoder.h" #include "base/gfx/png_decoder.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/skia/include/core/SkBitmap.h" static void MakeRGBImage(int w, int h, std::vector<unsigned char>* dat) { dat->resize(w * h * 3); @@ -42,25 +41,6 @@ static void MakeRGBAImage(int w, int h, bool use_transparency, } } -// Returns true if each channel of the given two colors are "close." This is -// used for comparing colors where rounding errors may cause off-by-one. -bool ColorsClose(uint32_t a, uint32_t b) { - return abs(static_cast<int>(SkColorGetB(a) - SkColorGetB(b))) < 2 && - abs(static_cast<int>(SkColorGetG(a) - SkColorGetG(b))) < 2 && - abs(static_cast<int>(SkColorGetR(a) - SkColorGetR(b))) < 2 && - abs(static_cast<int>(SkColorGetA(a) - SkColorGetA(b))) < 2; -} - -void MakeTestSkBitmap(int w, int h, SkBitmap* bmp) { - bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); - bmp->allocPixels(); - - uint32_t* src_data = bmp->getAddr32(0, 0); - for (int i = 0; i < w * h; i++) { - src_data[i] = SkPreMultiplyARGB(i % 255, i % 250, i % 245, i % 240); - } -} - TEST(PNGCodec, EncodeDecodeRGB) { const int w = 20, h = 20; @@ -220,30 +200,3 @@ TEST(PNGCodec, StripAddAlpha) { ASSERT_EQ(original_rgb.size(), decoded.size()); ASSERT_TRUE(original_rgb == decoded); } - -TEST(PNGCodec, EncodeBGRASkBitmap) { - const int w = 20, h = 20; - - SkBitmap original_bitmap; - MakeTestSkBitmap(w, h, &original_bitmap); - - // Encode the bitmap. - std::vector<unsigned char> encoded; - PNGEncoder::EncodeBGRASkBitmap(original_bitmap, false, &encoded); - - // Decode the encoded string. - SkBitmap decoded_bitmap; - EXPECT_TRUE(PNGDecoder::Decode(&encoded, &decoded_bitmap)); - - // Compare the original bitmap and the output bitmap. We use ColorsClose - // as SkBitmaps are considered to be pre-multiplied, the unpremultiplication - // (in Encode) and repremultiplication (in Decode) can be lossy. - for (int x = 0; x < w; x++) { - for (int y = 0; y < h; y++) { - uint32_t original_pixel = original_bitmap.getAddr32(0, y)[x]; - uint32_t decoded_pixel = decoded_bitmap.getAddr32(0, y)[x]; - EXPECT_TRUE(ColorsClose(original_pixel, decoded_pixel)); - } - } -} - |