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

Unified Diff: chrome/browser/extensions/tab_helper.cc

Issue 148723003: Make generated hosted app icons have white background. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reattempt_icon_generation
Patch Set: fix comments Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/tab_helper.cc
diff --git a/chrome/browser/extensions/tab_helper.cc b/chrome/browser/extensions/tab_helper.cc
index 6e265d500f43ffffa5382db254aa081d3de8a7c0..bc86702d8ad927f183498f0aec540f55f5f480ca 100644
--- a/chrome/browser/extensions/tab_helper.cc
+++ b/chrome/browser/extensions/tab_helper.cc
@@ -138,14 +138,16 @@ void TabHelper::GenerateContainerIcon(std::map<int, SkBitmap>* bitmaps,
--it;
// This is the biggest icon smaller than |output_size|.
const SkBitmap& base_icon = it->second;
- scoped_ptr<SkCanvas> canvas(
- skia::CreateBitmapCanvas(output_size, output_size, false));
- DCHECK(canvas);
const size_t kBorderRadius = 5;
const size_t kColorStripHeight = 3;
- const size_t kColorStripRadius = 2;
const SkColor kBorderColor = 0xFFD5D5D5;
+ const SkColor kBackgroundColor = 0xFFFFFFFF;
+
+ // Create a separate canvas for the color strip.
+ scoped_ptr<SkCanvas> color_strip_canvas(
+ skia::CreateBitmapCanvas(output_size, output_size, false));
+ DCHECK(color_strip_canvas);
// Draw a rounded rect of the |base_icon|'s dominant color.
SkPaint color_strip_paint;
@@ -155,18 +157,35 @@ void TabHelper::GenerateContainerIcon(std::map<int, SkBitmap>* bitmaps,
color_utils::CalculateKMeanColorOfPNG(
gfx::Image::CreateFrom1xBitmap(base_icon).As1xPNGBytes(),
100, 665, &sampler));
- canvas->drawRoundRect(
- SkRect::MakeXYWH(1, 0, output_size - 2, output_size - 1),
- kColorStripRadius, kColorStripRadius, color_strip_paint);
+ color_strip_canvas->drawRoundRect(
+ SkRect::MakeWH(output_size, output_size),
+ kBorderRadius, kBorderRadius, color_strip_paint);
// Erase the top of the rounded rect to leave a color strip.
SkPaint clear_paint;
clear_paint.setColor(SK_ColorTRANSPARENT);
clear_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- canvas->drawRect(
- SkRect::MakeWH(output_size, output_size - kColorStripHeight - 1),
+ color_strip_canvas->drawRect(
+ SkRect::MakeWH(output_size, output_size - kColorStripHeight),
clear_paint);
+ // Draw each element to an output canvas.
+ scoped_ptr<SkCanvas> canvas(
+ skia::CreateBitmapCanvas(output_size, output_size, false));
+ DCHECK(canvas);
+
+ // Draw the background.
+ SkPaint background_paint;
+ background_paint.setColor(kBackgroundColor);
+ background_paint.setFlags(SkPaint::kAntiAlias_Flag);
+ canvas->drawRoundRect(
+ SkRect::MakeWH(output_size, output_size),
+ kBorderRadius, kBorderRadius, background_paint);
+
+ // Draw the color strip.
+ canvas->drawBitmap(color_strip_canvas->getDevice()->accessBitmap(false),
+ 0, 0);
+
// Draw the border.
SkPaint border_paint;
border_paint.setColor(kBorderColor);
@@ -176,7 +195,7 @@ void TabHelper::GenerateContainerIcon(std::map<int, SkBitmap>* bitmaps,
SkRect::MakeWH(output_size, output_size),
kBorderRadius, kBorderRadius, border_paint);
- // Draw the centered base icon.
+ // Draw the centered base icon to the output canvas.
canvas->drawBitmap(base_icon,
(output_size - base_icon.width()) / 2,
(output_size - base_icon.height()) / 2);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698