| Index: chrome/browser/media/desktop_media_list.cc
|
| diff --git a/chrome/browser/media/desktop_media_list.cc b/chrome/browser/media/desktop_media_list.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..075332d8fa911a5c9e543bee5a4bec89c0d8fafe
|
| --- /dev/null
|
| +++ b/chrome/browser/media/desktop_media_list.cc
|
| @@ -0,0 +1,47 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/media/desktop_media_list_ash.h"
|
| +#include "third_party/skia/include/core/SkCanvas.h"
|
| +#include "third_party/skia/include/core/SkImage.h"
|
| +
|
| +gfx::ImageSkia DesktopMediaList::CreateEnlargedFaviconImage(
|
| + gfx::Size size,
|
| + gfx::Image& favicon) {
|
| + // Create a bitmap.
|
| + SkBitmap result;
|
| + result.allocN32Pixels(size.width(), size.height(), true);
|
| + SkCanvas canvas(result);
|
| +
|
| + // Fill with white.
|
| + canvas.drawARGB(255, 255, 255, 255);
|
| +
|
| + // Draw black border.
|
| + const int thickness = result.width() / 30;
|
| + SkPaint paint;
|
| + paint.setARGB(255, 0, 0, 0);
|
| + paint.setStyle(SkPaint::kStroke_Style);
|
| + paint.setStrokeWidth(thickness);
|
| + canvas.drawRectCoords(thickness, // left
|
| + thickness, // top
|
| + result.width() - thickness, // right
|
| + result.height() - thickness, // bottom
|
| + paint);
|
| +
|
| + // Draw a scaled favicon image into the center of result image to take up to
|
| + // 3/4 of result image.
|
| + const double scale = fmin(3.0 / 4 * result.width() / favicon.Width(),
|
| + 3.0 / 4 * result.height() / favicon.Height());
|
| + SkRect dest_rect;
|
| + dest_rect.set(result.width() / 2 - favicon.Width() * scale / 2, // left
|
| + result.height() / 2 - favicon.Height() * scale / 2, // top
|
| + result.width() / 2 + favicon.Width() * scale / 2, // right
|
| + result.height() / 2 + favicon.Height() * scale / 2); // bottom
|
| + const SkImage* temp_image = SkImage::NewFromBitmap(favicon.AsBitmap());
|
| + canvas.drawImageRect(temp_image, dest_rect, nullptr);
|
| + delete temp_image;
|
| +
|
| + // Create a skia image.
|
| + return gfx::ImageSkia::CreateFrom1xBitmap(result);
|
| +}
|
|
|