| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 DISALLOW_COPY_AND_ASSIGN(Bitmap); | 79 DISALLOW_COPY_AND_ASSIGN(Bitmap); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 // Lightweight raw-bitmap management. The image, once initialized, is immuable. | 82 // Lightweight raw-bitmap management. The image, once initialized, is immuable. |
| 83 // It is mainly used for comparison. | 83 // It is mainly used for comparison. |
| 84 class Image { | 84 class Image { |
| 85 public: | 85 public: |
| 86 // Creates the image from the given filename on disk. | 86 // Creates the image from the given filename on disk. |
| 87 explicit Image(const base::FilePath& filename) : ignore_alpha_(true) { | 87 explicit Image(const base::FilePath& filename) : ignore_alpha_(true) { |
| 88 std::string compressed; | 88 std::string compressed; |
| 89 file_util::ReadFileToString(filename, &compressed); | 89 base::ReadFileToString(filename, &compressed); |
| 90 EXPECT_TRUE(compressed.size()); | 90 EXPECT_TRUE(compressed.size()); |
| 91 | 91 |
| 92 SkBitmap bitmap; | 92 SkBitmap bitmap; |
| 93 EXPECT_TRUE(gfx::PNGCodec::Decode( | 93 EXPECT_TRUE(gfx::PNGCodec::Decode( |
| 94 reinterpret_cast<const unsigned char*>(compressed.data()), | 94 reinterpret_cast<const unsigned char*>(compressed.data()), |
| 95 compressed.size(), &bitmap)); | 95 compressed.size(), &bitmap)); |
| 96 SetSkBitmap(bitmap); | 96 SetSkBitmap(bitmap); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Loads the image from a canvas. | 99 // Loads the image from a canvas. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 (SkColorGetB(color) * 255 + alpha_offset) / alpha); | 328 (SkColorGetB(color) * 255 + alpha_offset) / alpha); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 void LoadPngFileToSkBitmap(const base::FilePath& filename, | 334 void LoadPngFileToSkBitmap(const base::FilePath& filename, |
| 335 SkBitmap* bitmap, | 335 SkBitmap* bitmap, |
| 336 bool is_opaque) { | 336 bool is_opaque) { |
| 337 std::string compressed; | 337 std::string compressed; |
| 338 file_util::ReadFileToString(base::MakeAbsoluteFilePath(filename), | 338 base::ReadFileToString(base::MakeAbsoluteFilePath(filename), &compressed); |
| 339 &compressed); | |
| 340 ASSERT_TRUE(compressed.size()); | 339 ASSERT_TRUE(compressed.size()); |
| 341 | 340 |
| 342 ASSERT_TRUE(gfx::PNGCodec::Decode( | 341 ASSERT_TRUE(gfx::PNGCodec::Decode( |
| 343 reinterpret_cast<const unsigned char*>(compressed.data()), | 342 reinterpret_cast<const unsigned char*>(compressed.data()), |
| 344 compressed.size(), bitmap)); | 343 compressed.size(), bitmap)); |
| 345 | 344 |
| 346 EXPECT_EQ(is_opaque, bitmap->isOpaque()); | 345 EXPECT_EQ(is_opaque, bitmap->isOpaque()); |
| 347 Premultiply(*bitmap); | 346 Premultiply(*bitmap); |
| 348 } | 347 } |
| 349 | 348 |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 pcanvas_->rotate(67); | 960 pcanvas_->rotate(67); |
| 962 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 961 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 963 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 962 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 964 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); | 963 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); |
| 965 } | 964 } |
| 966 } | 965 } |
| 967 | 966 |
| 968 #endif // !defined(USE_AURA) | 967 #endif // !defined(USE_AURA) |
| 969 | 968 |
| 970 } // namespace skia | 969 } // namespace skia |
| OLD | NEW |