| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "webkit/tools/test_shell/image_decoder_unittest.h" | 7 #include "webkit/tools/test_shell/image_decoder_unittest.h" |
| 8 | 8 |
| 9 #if !defined(OS_WIN) | 9 #if !defined(OS_WIN) |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "PNGImageDecoder.h" | 13 #include "PNGImageDecoder.h" |
| 14 | 14 |
| 15 #include "app/gfx/codec/png_codec.h" |
| 15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 16 #include "base/file_util.h" | 17 #include "base/file_util.h" |
| 17 #include "base/gfx/gdi_util.h" | 18 #include "base/gfx/gdi_util.h" |
| 18 #include "base/gfx/png_encoder.h" | |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "skia/ext/vector_canvas.h" | 21 #include "skia/ext/vector_canvas.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "third_party/skia/include/effects/SkDashPathEffect.h" | 23 #include "third_party/skia/include/effects/SkDashPathEffect.h" |
| 24 | 24 |
| 25 namespace skia { | 25 namespace skia { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 SetSkBitmap(bitmap); | 109 SetSkBitmap(bitmap); |
| 110 } | 110 } |
| 111 | 111 |
| 112 int width() const { return width_; } | 112 int width() const { return width_; } |
| 113 int height() const { return height_; } | 113 int height() const { return height_; } |
| 114 int row_length() const { return row_length_; } | 114 int row_length() const { return row_length_; } |
| 115 | 115 |
| 116 // Save the image to a png file. Used to create the initial test files. | 116 // Save the image to a png file. Used to create the initial test files. |
| 117 void SaveToFile(const std::wstring& filename) { | 117 void SaveToFile(const std::wstring& filename) { |
| 118 std::vector<unsigned char> compressed; | 118 std::vector<unsigned char> compressed; |
| 119 ASSERT_TRUE(PNGEncoder::Encode(&*data_.begin(), | 119 ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(), |
| 120 PNGEncoder::FORMAT_BGRA, | 120 gfx::PNGCodec::FORMAT_BGRA, |
| 121 width_, | 121 width_, |
| 122 height_, | 122 height_, |
| 123 row_length_, | 123 row_length_, |
| 124 true, | 124 true, |
| 125 &compressed)); | 125 &compressed)); |
| 126 ASSERT_TRUE(compressed.size()); | 126 ASSERT_TRUE(compressed.size()); |
| 127 FILE* f = file_util::OpenFile(filename, "wb"); | 127 FILE* f = file_util::OpenFile(filename, "wb"); |
| 128 ASSERT_TRUE(f); | 128 ASSERT_TRUE(f); |
| 129 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), | 129 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), |
| 130 compressed.size()); | 130 compressed.size()); |
| 131 file_util::CloseFile(f); | 131 file_util::CloseFile(f); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Returns the percentage of the image that is different from the other, | 134 // Returns the percentage of the image that is different from the other, |
| 135 // between 0 and 100. | 135 // between 0 and 100. |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 { | 956 { |
| 957 vcanvas_->rotate(67); | 957 vcanvas_->rotate(67); |
| 958 pcanvas_->rotate(67); | 958 pcanvas_->rotate(67); |
| 959 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 959 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 960 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 960 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 961 EXPECT_EQ(0., ProcessImage(L"rotate")); | 961 EXPECT_EQ(0., ProcessImage(L"rotate")); |
| 962 } | 962 } |
| 963 } | 963 } |
| 964 | 964 |
| 965 } // namespace skia | 965 } // namespace skia |
| OLD | NEW |