| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 if (bitmap.isNull()) { | 96 if (bitmap.isNull()) { |
| 97 ADD_FAILURE() << "Bitmap has no pixelref."; | 97 ADD_FAILURE() << "Bitmap has no pixelref."; |
| 98 return SkColorSetARGB(0, 0, 0, 0); | 98 return SkColorSetARGB(0, 0, 0, 0); |
| 99 } | 99 } |
| 100 if (bitmap.colorType() == kUnknown_SkColorType) { | 100 if (bitmap.colorType() == kUnknown_SkColorType) { |
| 101 ADD_FAILURE() << "Bitmap has not been configured."; | 101 ADD_FAILURE() << "Bitmap has not been configured."; |
| 102 return SkColorSetARGB(0, 0, 0, 0); | 102 return SkColorSetARGB(0, 0, 0, 0); |
| 103 } | 103 } |
| 104 uint64_t a = 0, r = 0, g = 0, b = 0; | 104 uint64_t a = 0, r = 0, g = 0, b = 0; |
| 105 bitmap.lockPixels(); | |
| 106 for (int x = 0; x < bitmap.width(); ++x) { | 105 for (int x = 0; x < bitmap.width(); ++x) { |
| 107 for (int y = 0; y < bitmap.height(); ++y) { | 106 for (int y = 0; y < bitmap.height(); ++y) { |
| 108 const SkColor color = bitmap.getColor(x, y); | 107 const SkColor color = bitmap.getColor(x, y); |
| 109 a += SkColorGetA(color); | 108 a += SkColorGetA(color); |
| 110 r += SkColorGetR(color); | 109 r += SkColorGetR(color); |
| 111 g += SkColorGetG(color); | 110 g += SkColorGetG(color); |
| 112 b += SkColorGetB(color); | 111 b += SkColorGetB(color); |
| 113 } | 112 } |
| 114 } | 113 } |
| 115 bitmap.unlockPixels(); | |
| 116 uint64_t pixel_number = bitmap.width() * bitmap.height(); | 114 uint64_t pixel_number = bitmap.width() * bitmap.height(); |
| 117 return SkColorSetARGB((a + pixel_number / 2) / pixel_number, | 115 return SkColorSetARGB((a + pixel_number / 2) / pixel_number, |
| 118 (r + pixel_number / 2) / pixel_number, | 116 (r + pixel_number / 2) / pixel_number, |
| 119 (g + pixel_number / 2) / pixel_number, | 117 (g + pixel_number / 2) / pixel_number, |
| 120 (b + pixel_number / 2) / pixel_number); | 118 (b + pixel_number / 2) / pixel_number); |
| 121 } | 119 } |
| 122 | 120 |
| 123 // Obtain wallpaper image and return its average ARGB color. | 121 // Obtain wallpaper image and return its average ARGB color. |
| 124 SkColor GetAverageWallpaperColor() { | 122 SkColor GetAverageWallpaperColor() { |
| 125 const gfx::ImageSkia image = | 123 const gfx::ImageSkia image = |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 435 |
| 438 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { | 436 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { |
| 439 LoginUser(testUsers_[0].GetUserEmail()); | 437 LoginUser(testUsers_[0].GetUserEmail()); |
| 440 | 438 |
| 441 // Wait until wallpaper has been loaded. | 439 // Wait until wallpaper has been loaded. |
| 442 RunUntilWallpaperChangeCount(1); | 440 RunUntilWallpaperChangeCount(1); |
| 443 ASSERT_EQ(kRedImageColor, GetAverageWallpaperColor()); | 441 ASSERT_EQ(kRedImageColor, GetAverageWallpaperColor()); |
| 444 } | 442 } |
| 445 | 443 |
| 446 } // namespace chromeos | 444 } // namespace chromeos |
| OLD | NEW |