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 "components/wallpaper/wallpaper_manager_base.h" | 5 #include "components/wallpaper/wallpaper_manager_base.h" |
6 | 6 |
7 #include <numeric> | 7 #include <numeric> |
8 #include <vector> | 8 #include <vector> |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 } else { | 424 } else { |
425 resized_width = width; | 425 resized_width = width; |
426 resized_height = height; | 426 resized_height = height; |
427 } | 427 } |
428 | 428 |
429 gfx::ImageSkia resized_image = gfx::ImageSkiaOperations::CreateResizedImage( | 429 gfx::ImageSkia resized_image = gfx::ImageSkiaOperations::CreateResizedImage( |
430 image, skia::ImageOperations::RESIZE_LANCZOS3, | 430 image, skia::ImageOperations::RESIZE_LANCZOS3, |
431 gfx::Size(resized_width, resized_height)); | 431 gfx::Size(resized_width, resized_height)); |
432 | 432 |
433 SkBitmap bitmap = *(resized_image.bitmap()); | 433 SkBitmap bitmap = *(resized_image.bitmap()); |
434 gfx::JPEGCodec::Encode( | 434 SkPixmap pixmap; |
435 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), | 435 bool success = bitmap.peekPixels(&pixmap); |
436 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), | 436 DCHECK(success); |
437 bitmap.width() * bitmap.bytesPerPixel(), kDefaultEncodingQuality, | 437 gfx::JPEGCodec::Encode(pixmap, kDefaultEncodingQuality, &(*output)->data()); |
438 &(*output)->data()); | |
439 | 438 |
440 if (output_skia) { | 439 if (output_skia) { |
441 resized_image.MakeThreadSafe(); | 440 resized_image.MakeThreadSafe(); |
442 *output_skia = resized_image; | 441 *output_skia = resized_image; |
443 } | 442 } |
444 | 443 |
445 return true; | 444 return true; |
446 } | 445 } |
447 | 446 |
448 // static | 447 // static |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { | 1050 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { |
1052 loaded_wallpapers_for_test_++; | 1051 loaded_wallpapers_for_test_++; |
1053 SkBitmap bitmap; | 1052 SkBitmap bitmap; |
1054 bitmap.allocN32Pixels(1, 1); | 1053 bitmap.allocN32Pixels(1, 1); |
1055 bitmap.eraseColor(kDefaultWallpaperColor); | 1054 bitmap.eraseColor(kDefaultWallpaperColor); |
1056 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 1055 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
1057 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1056 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
1058 } | 1057 } |
1059 | 1058 |
1060 } // namespace wallpaper | 1059 } // namespace wallpaper |
OLD | NEW |