Commit 1f44fb08 authored by Sebastian Krzyszkowiak's avatar Sebastian Krzyszkowiak Committed by Commit Bot

Fix system tray icons being cropped under KDE

The code that adds padding to too small icons was breaking the larger
ones by cutting the minimal size (22x22px) out of their center.

Bug: 799427
Change-Id: I7a87d0229e063420a4814256528fbd070c62e503
Reviewed-on: https://chromium-review.googlesource.com/1173235
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589638}
parent f36d978d
...@@ -760,6 +760,7 @@ Scott D Phillips <scott.d.phillips@intel.com> ...@@ -760,6 +760,7 @@ Scott D Phillips <scott.d.phillips@intel.com>
Sean Bryant <sean@cyberwang.net> Sean Bryant <sean@cyberwang.net>
Sean DuBois <seaduboi@amazon.com> Sean DuBois <seaduboi@amazon.com>
Sebastian Amend <sebastian.amend@googlemail.com> Sebastian Amend <sebastian.amend@googlemail.com>
Sebastian Krzyszkowiak <dos@dosowisko.net>
Seo Sanghyeon <sanxiyn@gmail.com> Seo Sanghyeon <sanxiyn@gmail.com>
Seokju Kwon <seokju.kwon@gmail.com> Seokju Kwon <seokju.kwon@gmail.com>
SeongTae Jeong <ferendevelop.gl@gmail.com> SeongTae Jeong <ferendevelop.gl@gmail.com>
......
...@@ -274,15 +274,16 @@ AppIndicatorIcon::WriteKDE4TempImageOnWorkerThread( ...@@ -274,15 +274,16 @@ AppIndicatorIcon::WriteKDE4TempImageOnWorkerThread(
std::string icon_name = base::StringPrintf( std::string icon_name = base::StringPrintf(
"chrome_app_indicator2_%s", base::MD5DigestToBase16(digest).c_str()); "chrome_app_indicator2_%s", base::MD5DigestToBase16(digest).c_str());
// If |bitmap| is not 22x22, KDE does some really ugly resizing. Pad |bitmap| // If |bitmap| is smaller than 22x22, KDE does some really ugly resizing.
// with transparent pixels to make it 22x22. // Pad |bitmap| with transparent pixels to make it 22x22.
const int kDesiredSize = 22; const int kMinimalSize = 22;
SkBitmap scaled_bitmap; SkBitmap scaled_bitmap;
scaled_bitmap.allocN32Pixels(kDesiredSize, kDesiredSize); scaled_bitmap.allocN32Pixels(std::max(bitmap.width(), kMinimalSize),
std::max(bitmap.height(), kMinimalSize));
scaled_bitmap.eraseARGB(0, 0, 0, 0); scaled_bitmap.eraseARGB(0, 0, 0, 0);
SkCanvas canvas(scaled_bitmap); SkCanvas canvas(scaled_bitmap);
canvas.drawBitmap(bitmap, (kDesiredSize - bitmap.width()) / 2, canvas.drawBitmap(bitmap, (scaled_bitmap.width() - bitmap.width()) / 2,
(kDesiredSize - bitmap.height()) / 2); (scaled_bitmap.height() - bitmap.height()) / 2);
base::FilePath image_path = image_dir.Append(icon_name + ".png"); base::FilePath image_path = image_dir.Append(icon_name + ".png");
if (!WriteFile(image_path, scaled_bitmap)) if (!WriteFile(image_path, scaled_bitmap))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment