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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename methods and vars to make image_scale more clear Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/tabs/tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 destroyed_ = NULL; 387 destroyed_ = NULL;
388 SetState(views::CustomButton::STATE_NORMAL); 388 SetState(views::CustomButton::STATE_NORMAL);
389 return; 389 return;
390 } 390 }
391 views::ImageButton::OnMouseReleased(event); 391 views::ImageButton::OnMouseReleased(event);
392 } 392 }
393 #endif 393 #endif
394 394
395 void NewTabButton::OnPaint(gfx::Canvas* canvas) { 395 void NewTabButton::OnPaint(gfx::Canvas* canvas) {
396 gfx::ImageSkia image = GetImageForScale(canvas->scale_factor()); 396 gfx::ImageSkia image =
397 GetImageForScale(ui::GetSupportedScaleFactor(canvas->image_scale()));
397 canvas->DrawImageInt(image, 0, height() - image.height()); 398 canvas->DrawImageInt(image, 0, height() - image.height());
398 } 399 }
399 400
400 void NewTabButton::OnGestureEvent(ui::GestureEvent* event) { 401 void NewTabButton::OnGestureEvent(ui::GestureEvent* event) {
401 // Consume all gesture events here so that the parent (Tab) does not 402 // Consume all gesture events here so that the parent (Tab) does not
402 // start consuming gestures. 403 // start consuming gestures.
403 views::ImageButton::OnGestureEvent(event); 404 views::ImageButton::OnGestureEvent(event);
404 event->SetHandled(); 405 event->SetHandled();
405 } 406 }
406 407
(...skipping 29 matching lines...) Expand all
436 break; 437 break;
437 default: 438 default:
438 NOTREACHED(); 439 NOTREACHED();
439 break; 440 break;
440 } 441 }
441 442
442 gfx::ImageSkia* mask = 443 gfx::ImageSkia* mask =
443 GetThemeProvider()->GetImageSkiaNamed(IDR_NEWTAB_BUTTON_MASK); 444 GetThemeProvider()->GetImageSkiaNamed(IDR_NEWTAB_BUTTON_MASK);
444 int height = mask->height(); 445 int height = mask->height();
445 int width = mask->width(); 446 int width = mask->width();
446 447 float scale = ui::GetImageScale(scale_factor);
447 // The canvas and mask has to use the same scale factor. 448 // The canvas and mask has to use the same scale factor.
448 if (!mask->HasRepresentation(scale_factor)) 449 if (!mask->HasRepresentation(scale))
449 scale_factor = ui::SCALE_FACTOR_100P; 450 scale_factor = ui::SCALE_FACTOR_100P;
450 451
451 gfx::Canvas canvas(gfx::Size(width, height), scale_factor, false); 452 gfx::Canvas canvas(gfx::Size(width, height), scale, false);
452 453
453 // For custom images the background starts at the top of the tab strip. 454 // For custom images the background starts at the top of the tab strip.
454 // Otherwise the background starts at the top of the frame. 455 // Otherwise the background starts at the top of the frame.
455 gfx::ImageSkia* background = 456 gfx::ImageSkia* background =
456 GetThemeProvider()->GetImageSkiaNamed(background_id); 457 GetThemeProvider()->GetImageSkiaNamed(background_id);
457 int offset_y = GetThemeProvider()->HasCustomImage(background_id) ? 458 int offset_y = GetThemeProvider()->HasCustomImage(background_id) ?
458 0 : background_offset_.y(); 459 0 : background_offset_.y();
459 460
460 // The new tab background is mirrored in RTL mode, but the theme background 461 // The new tab background is mirrored in RTL mode, but the theme background
461 // should never be mirrored. Mirror it here to compensate. 462 // should never be mirrored. Mirror it here to compensate.
(...skipping 25 matching lines...) Expand all
487 } 488 }
488 489
489 gfx::ImageSkia NewTabButton::GetImageForState( 490 gfx::ImageSkia NewTabButton::GetImageForState(
490 views::CustomButton::ButtonState state, 491 views::CustomButton::ButtonState state,
491 ui::ScaleFactor scale_factor) const { 492 ui::ScaleFactor scale_factor) const {
492 const int overlay_id = state == views::CustomButton::STATE_PRESSED ? 493 const int overlay_id = state == views::CustomButton::STATE_PRESSED ?
493 IDR_NEWTAB_BUTTON_P : IDR_NEWTAB_BUTTON; 494 IDR_NEWTAB_BUTTON_P : IDR_NEWTAB_BUTTON;
494 gfx::ImageSkia* overlay = GetThemeProvider()->GetImageSkiaNamed(overlay_id); 495 gfx::ImageSkia* overlay = GetThemeProvider()->GetImageSkiaNamed(overlay_id);
495 496
496 gfx::Canvas canvas( 497 gfx::Canvas canvas(
497 gfx::Size(overlay->width(), overlay->height()), scale_factor, false); 498 gfx::Size(overlay->width(), overlay->height()),
499 ui::GetImageScale(scale_factor),
500 false);
498 canvas.DrawImageInt(GetBackgroundImage(state, scale_factor), 0, 0); 501 canvas.DrawImageInt(GetBackgroundImage(state, scale_factor), 0, 0);
499 502
500 // Draw the button border with a slight alpha. 503 // Draw the button border with a slight alpha.
501 const int kNativeFrameOverlayAlpha = 178; 504 const int kNativeFrameOverlayAlpha = 178;
502 const int kOpaqueFrameOverlayAlpha = 230; 505 const int kOpaqueFrameOverlayAlpha = 230;
503 uint8 alpha = ShouldUseNativeFrame() ? 506 uint8 alpha = ShouldUseNativeFrame() ?
504 kNativeFrameOverlayAlpha : kOpaqueFrameOverlayAlpha; 507 kNativeFrameOverlayAlpha : kOpaqueFrameOverlayAlpha;
505 canvas.DrawImageInt(*overlay, 0, 0, alpha); 508 canvas.DrawImageInt(*overlay, 0, 0, alpha);
506 509
507 return gfx::ImageSkia(canvas.ExtractImageRep()); 510 return gfx::ImageSkia(canvas.ExtractImageRep());
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 if (!adjust_layout_) 2715 if (!adjust_layout_)
2713 return false; 2716 return false;
2714 2717
2715 #if !defined(OS_CHROMEOS) 2718 #if !defined(OS_CHROMEOS)
2716 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) 2719 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH)
2717 return false; 2720 return false;
2718 #endif 2721 #endif
2719 2722
2720 return true; 2723 return true;
2721 } 2724 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698