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

Unified Diff: ui/views/controls/button/image_button.cc

Issue 12257016: (Not ready for review!) Toolbar and views high dpi support. Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Cleaned up more useless diffs. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/skbitmap_operations.cc ('k') | ui/views/controls/native/native_view_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/image_button.cc
diff --git a/ui/views/controls/button/image_button.cc b/ui/views/controls/button/image_button.cc
index a93a1dc59338c50ddfefa7b03b82f33a6bf2895d..de5c12c2f9eeb7b01b5076490dbf4d2388235838 100644
--- a/ui/views/controls/button/image_button.cc
+++ b/ui/views/controls/button/image_button.cc
@@ -74,6 +74,15 @@ gfx::Size ImageButton::GetPreferredSize() {
}
return preferred_size_;
}
+static float GetScaleFactor() {
+ switch (ui::GetMaxScaleFactor()) {
+ case ui::SCALE_FACTOR_140P:
+ return 1.4f;
+ case ui::SCALE_FACTOR_180P:
+ return 1.8f;
+ }
+ return 1.0f;
+}
void ImageButton::OnPaint(gfx::Canvas* canvas) {
// Call the base class first to paint any background/borders.
@@ -83,13 +92,18 @@ void ImageButton::OnPaint(gfx::Canvas* canvas) {
if (!img.isNull()) {
gfx::Point position = ComputeImagePaintPosition(img);
+ static float scale = GetScaleFactor();
+ scale = 1;
+ // TODO: store and reset the transform.... this implementation will accumulate errors.
+ canvas->Scale( scale, scale);
if (!background_image_.isNull())
canvas->DrawImageInt(background_image_, position.x(), position.y());
- canvas->DrawImageInt(img, position.x(), position.y());
+ canvas->DrawImageInt(img, 0, 0);//position.x(), position.y());
if (!overlay_image_.isNull())
canvas->DrawImageInt(overlay_image_, position.x(), position.y());
+ canvas->Scale( 1/scale, 1/scale);
}
OnPaintFocusBorder(canvas);
}
« no previous file with comments | « ui/gfx/skbitmap_operations.cc ('k') | ui/views/controls/native/native_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698