Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_utils.cc

Issue 2895953003: Use SkJpegEncoder in gfx jpeg_codec (Closed)
Patch Set: Remove brackets Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u tils.h" 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u tils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const int kWallpaperSize = 2; 80 const int kWallpaperSize = 2;
81 81
82 bool CreateJPEGImage(int width, 82 bool CreateJPEGImage(int width,
83 int height, 83 int height,
84 SkColor color, 84 SkColor color,
85 std::vector<unsigned char>* output) { 85 std::vector<unsigned char>* output) {
86 SkBitmap bitmap; 86 SkBitmap bitmap;
87 bitmap.allocN32Pixels(width, height); 87 bitmap.allocN32Pixels(width, height);
88 bitmap.eraseColor(color); 88 bitmap.eraseColor(color);
89 89
90 const int kQuality = 80; 90 constexpr int kQuality = 80;
91 if (!gfx::JPEGCodec::Encode( 91 if (!gfx::JPEGCodec::Encode(bitmap, kQuality, output)) {
92 static_cast<const unsigned char*>(bitmap.getPixels()),
93 gfx::JPEGCodec::FORMAT_SkBitmap,
94 width,
95 height,
96 bitmap.rowBytes(),
97 kQuality,
98 output)) {
99 LOG(ERROR) << "Unable to encode " << width << "x" << height << " bitmap"; 92 LOG(ERROR) << "Unable to encode " << width << "x" << height << " bitmap";
100 return false; 93 return false;
101 } 94 }
102 return true; 95 return true;
103 } 96 }
104 97
105 gfx::ImageSkia CreateTestImage(int width, int height, SkColor color) { 98 gfx::ImageSkia CreateTestImage(int width, int height, SkColor color) {
106 SkBitmap bitmap; 99 SkBitmap bitmap;
107 bitmap.allocN32Pixels(width, height); 100 bitmap.allocN32Pixels(width, height);
108 bitmap.eraseColor(color); 101 bitmap.eraseColor(color);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 kWallpaperSize, 218 kWallpaperSize,
226 kLargeChildWallpaperColor)); 219 kLargeChildWallpaperColor));
227 220
228 command_line->reset(new base::CommandLine(options)); 221 command_line->reset(new base::CommandLine(options));
229 WallpaperManager::Get()->SetCommandLineForTesting(command_line->get()); 222 WallpaperManager::Get()->SetCommandLineForTesting(command_line->get());
230 } 223 }
231 224
232 } // namespace wallpaper_manager_test_utils 225 } // namespace wallpaper_manager_test_utils
233 226
234 } // namespace chromeos 227 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698