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

Side by Side Diff: chrome/browser/profiles/profile_avatar_icon_util.cc

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 years, 10 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/profiles/profile_avatar_icon_util.h" 5 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "cc/paint/paint_flags.h"
19 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
20 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
21 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
22 #include "chrome/grit/theme_resources.h" 23 #include "chrome/grit/theme_resources.h"
23 #include "skia/ext/image_operations.h" 24 #include "skia/ext/image_operations.h"
24 #include "third_party/skia/include/core/SkPaint.h" 25 #include "third_party/skia/include/core/SkPaint.h"
25 #include "third_party/skia/include/core/SkPath.h" 26 #include "third_party/skia/include/core/SkPath.h"
26 #include "third_party/skia/include/core/SkScalar.h" 27 #include "third_party/skia/include/core/SkScalar.h"
27 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 182
182 // Offset the rectangle by a half pixel so the border is drawn within the 183 // Offset the rectangle by a half pixel so the border is drawn within the
183 // appropriate pixels no matter the scale factor. Subtract 1 from the right 184 // appropriate pixels no matter the scale factor. Subtract 1 from the right
184 // and bottom sizes to specify the endpoints, yielding -0.5. 185 // and bottom sizes to specify the endpoints, yielding -0.5.
185 SkPath path; 186 SkPath path;
186 path.addRect(SkFloatToScalar(x + 0.5f), // left 187 path.addRect(SkFloatToScalar(x + 0.5f), // left
187 SkFloatToScalar(y + 0.5f), // top 188 SkFloatToScalar(y + 0.5f), // top
188 SkFloatToScalar(x + border_size - 0.5f), // right 189 SkFloatToScalar(x + border_size - 0.5f), // right
189 SkFloatToScalar(y + border_size - 0.5f)); // bottom 190 SkFloatToScalar(y + border_size - 0.5f)); // bottom
190 191
191 SkPaint paint; 192 cc::PaintFlags paint;
192 paint.setColor(border_color); 193 paint.setColor(border_color);
193 paint.setStyle(SkPaint::kStroke_Style); 194 paint.setStyle(cc::PaintFlags::kStroke_Style);
194 paint.setStrokeWidth(SkIntToScalar(1)); 195 paint.setStrokeWidth(SkIntToScalar(1));
195 196
196 canvas->DrawPath(path, paint); 197 canvas->DrawPath(path, paint);
197 } else if (border_ == BORDER_ETCHED) { 198 } else if (border_ == BORDER_ETCHED) {
198 // Give the avatar an etched look by drawing a highlight on the bottom and 199 // Give the avatar an etched look by drawing a highlight on the bottom and
199 // right edges. 200 // right edges.
200 SkColor shadow_color = SkColorSetARGB(83, 0, 0, 0); 201 SkColor shadow_color = SkColorSetARGB(83, 0, 0, 0);
201 SkColor highlight_color = SkColorSetARGB(96, 255, 255, 255); 202 SkColor highlight_color = SkColorSetARGB(96, 255, 255, 255);
202 203
203 SkPaint paint; 204 cc::PaintFlags paint;
204 paint.setStyle(SkPaint::kStroke_Style); 205 paint.setStyle(cc::PaintFlags::kStroke_Style);
205 paint.setStrokeWidth(SkIntToScalar(1)); 206 paint.setStrokeWidth(SkIntToScalar(1));
206 207
207 SkPath path; 208 SkPath path;
208 209
209 // Left and top shadows. To support higher scale factors than 1, position 210 // Left and top shadows. To support higher scale factors than 1, position
210 // the orthogonal dimension of each line on the half-pixel to separate the 211 // the orthogonal dimension of each line on the half-pixel to separate the
211 // pixel. For a vertical line, this means adding 0.5 to the x-value. 212 // pixel. For a vertical line, this means adding 0.5 to the x-value.
212 path.moveTo(SkFloatToScalar(x + 0.5f), SkIntToScalar(y + height_)); 213 path.moveTo(SkFloatToScalar(x + 0.5f), SkIntToScalar(y + height_));
213 214
214 // Draw up to the top-left. Stop with the y-value at a half-pixel. 215 // Draw up to the top-left. Stop with the y-value at a half-pixel.
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 avatar_info->SetString( 564 avatar_info->SetString(
564 "label", l10n_util::GetStringUTF16( 565 "label", l10n_util::GetStringUTF16(
565 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); 566 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i)));
566 567
567 avatars->Append(std::move(avatar_info)); 568 avatars->Append(std::move(avatar_info));
568 } 569 }
569 return avatars; 570 return avatars;
570 } 571 }
571 572
572 } // namespace profiles 573 } // namespace profiles
OLDNEW
« no previous file with comments | « chrome/browser/extensions/bookmark_app_helper.cc ('k') | chrome/browser/thumbnails/content_analysis_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698