| 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 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "skia/ext/vector_canvas.h" | 16 #include "skia/ext/vector_canvas.h" |
| 17 #include "skia/ext/vector_platform_device.h" | 17 #include "skia/ext/vector_platform_device.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/skia/include/effects/SkDashPathEffect.h" | 19 #include "third_party/skia/include/effects/SkDashPathEffect.h" |
| 20 #include "ui/gfx/codec/png_codec.h" | 20 #include "ui/gfx/codec/png_codec.h" |
| 21 #include "ui/gfx/size.h" |
| 21 | 22 |
| 22 namespace skia { | 23 namespace skia { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 const char kGenerateSwitch[] = "vector-canvas-generate"; | 27 const char kGenerateSwitch[] = "vector-canvas-generate"; |
| 27 | 28 |
| 28 // Lightweight HDC management. | 29 // Lightweight HDC management. |
| 29 class Context { | 30 class Context { |
| 30 public: | 31 public: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 int width() const { return width_; } | 121 int width() const { return width_; } |
| 121 int height() const { return height_; } | 122 int height() const { return height_; } |
| 122 int row_length() const { return row_length_; } | 123 int row_length() const { return row_length_; } |
| 123 | 124 |
| 124 // Save the image to a png file. Used to create the initial test files. | 125 // Save the image to a png file. Used to create the initial test files. |
| 125 void SaveToFile(const FilePath& filename) { | 126 void SaveToFile(const FilePath& filename) { |
| 126 std::vector<unsigned char> compressed; | 127 std::vector<unsigned char> compressed; |
| 127 ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(), | 128 ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(), |
| 128 gfx::PNGCodec::FORMAT_BGRA, | 129 gfx::PNGCodec::FORMAT_BGRA, |
| 129 width_, | 130 gfx::Size(width_, height_), |
| 130 height_, | |
| 131 row_length_, | 131 row_length_, |
| 132 true, | 132 true, |
| 133 std::vector<gfx::PNGCodec::Comment>(), |
| 133 &compressed)); | 134 &compressed)); |
| 134 ASSERT_TRUE(compressed.size()); | 135 ASSERT_TRUE(compressed.size()); |
| 135 FILE* f = file_util::OpenFile(filename, "wb"); | 136 FILE* f = file_util::OpenFile(filename, "wb"); |
| 136 ASSERT_TRUE(f); | 137 ASSERT_TRUE(f); |
| 137 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), | 138 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), |
| 138 compressed.size()); | 139 compressed.size()); |
| 139 file_util::CloseFile(f); | 140 file_util::CloseFile(f); |
| 140 } | 141 } |
| 141 | 142 |
| 142 // Returns the percentage of the image that is different from the other, | 143 // Returns the percentage of the image that is different from the other, |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 { | 969 { |
| 969 vcanvas_->rotate(67); | 970 vcanvas_->rotate(67); |
| 970 pcanvas_->rotate(67); | 971 pcanvas_->rotate(67); |
| 971 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 972 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 972 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 973 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 973 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); | 974 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); |
| 974 } | 975 } |
| 975 } | 976 } |
| 976 | 977 |
| 977 } // namespace skia | 978 } // namespace skia |
| OLD | NEW |