Commit 5748b780 authored by tapted@chromium.org's avatar tapted@chromium.org

Use a correct scale factor in app_list::CachedLabel

It currently just uses 1.0. Instead, fetch it with
ui::GetScaleFactorForNativeView and invalidate it when the scale factor
changes.

This is a small fix for a simple HiDPI bug, but eventually we will be
able to scrap CachedLabel: The performance improvement it offers will be
redundant with http://crbug.com/240037.

BUG=368493

Review URL: https://codereview.chromium.org/405373002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284649 0039d316-1c4b-4281-b951-d872f2087c98
parent dc828793
......@@ -5,8 +5,10 @@
#include "ui/app_list/views/cached_label.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/views/widget/widget.h"
namespace app_list {
......@@ -19,7 +21,9 @@ void CachedLabel::PaintToBackingImage() {
return;
bool is_opaque = SkColorGetA(background_color()) == 0xFF;
gfx::Canvas canvas(size(), 1.0f, is_opaque);
float scale_factor =
ui::GetScaleFactorForNativeView(GetWidget()->GetNativeView());
gfx::Canvas canvas(size(), scale_factor, is_opaque);
// If a background is provided, it will initialize the canvas in
// View::OnPaintBackground(). Otherwise, the background must be set here.
if (!background()) {
......@@ -38,4 +42,10 @@ void CachedLabel::OnPaint(gfx::Canvas* canvas) {
}
#endif
void CachedLabel::OnDeviceScaleFactorChanged(
float device_scale_factor) {
Invalidate();
View::OnDeviceScaleFactorChanged(device_scale_factor);
}
} // namespace app_list
......@@ -27,10 +27,13 @@ class CachedLabel : public views::Label {
void PaintToBackingImage();
#if defined(OS_WIN)
// views::View overrides.
// Overridden from views::View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
#endif
// Overridden from ui::LayerDelegate:
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
private:
bool needs_repaint_;
gfx::ImageSkia image_;
......
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