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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 1425163002: gfx: Rename canvas SaveAndUnscale to UnscaleTheDeviceScaleFactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ninepatchscale
Patch Set: scopedunscale: . Created 5 years, 1 month 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
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/bookmarks/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 canvas->sk_canvas()->drawRect(rc_down, paint_down); 470 canvas->sk_canvas()->drawRect(rc_down, paint_down);
471 } 471 }
472 472
473 class BookmarkBarView::ButtonSeparatorView : public views::View { 473 class BookmarkBarView::ButtonSeparatorView : public views::View {
474 public: 474 public:
475 ButtonSeparatorView() {} 475 ButtonSeparatorView() {}
476 ~ButtonSeparatorView() override {} 476 ~ButtonSeparatorView() override {}
477 477
478 void OnPaint(gfx::Canvas* canvas) override { 478 void OnPaint(gfx::Canvas* canvas) override {
479 if (ui::MaterialDesignController::IsModeMaterial()) { 479 if (ui::MaterialDesignController::IsModeMaterial()) {
480 ScopedCanvas scoped(canvas);
480 // 1px wide at all scale factors. If there is an uneven amount of padding 481 // 1px wide at all scale factors. If there is an uneven amount of padding
481 // left over, place the extra pixel on the outside, i.e. away from the 482 // left over, place the extra pixel on the outside, i.e. away from the
482 // "Other bookmarks" folder. 483 // "Other bookmarks" folder.
483 const float scale = canvas->SaveAndUnscale(); 484 const float scale = canvas->UnscaleTheDeviceScaleFactor();
484 const gfx::RectF scaled_bounds = 485 const gfx::RectF scaled_bounds =
485 gfx::ScaleRect(gfx::RectF(bounds()), scale); 486 gfx::ScaleRect(gfx::RectF(bounds()), scale);
486 487
487 const int kLineThickness = 1; 488 const int kLineThickness = 1;
488 const float fractional_x = (scaled_bounds.width() - kLineThickness) / 2.f; 489 const float fractional_x = (scaled_bounds.width() - kLineThickness) / 2.f;
489 const int x = base::i18n::IsRTL() ? std::floor(fractional_x) 490 const int x = base::i18n::IsRTL() ? std::floor(fractional_x)
490 : std::ceil(fractional_x); 491 : std::ceil(fractional_x);
491 492
492 const int height = gfx::kFaviconSize * scale; 493 const int height = gfx::kFaviconSize * scale;
493 const int top_y = (scaled_bounds.height() - height) / 2; 494 const int top_y = (scaled_bounds.height() - height) / 2;
494 canvas->DrawLine( 495 canvas->DrawLine(
495 gfx::Point(x, top_y), gfx::Point(x, top_y + height), 496 gfx::Point(x, top_y), gfx::Point(x, top_y + height),
496 SkColorSetA(GetThemeProvider()->GetColor( 497 SkColorSetA(GetThemeProvider()->GetColor(
497 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON), 498 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON),
498 0x4D)); 499 0x4D));
499 canvas->Restore();
500 } else { 500 } else {
501 PaintVerticalDivider( 501 PaintVerticalDivider(
502 canvas, kSeparatorStartX, height(), 1, kEdgeDividerColor, 502 canvas, kSeparatorStartX, height(), 1, kEdgeDividerColor,
503 kMiddleDividerColor, 503 kMiddleDividerColor,
504 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR)); 504 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR));
505 } 505 }
506 } 506 }
507 507
508 gfx::Size GetPreferredSize() const override { 508 gfx::Size GetPreferredSize() const override {
509 // We get the full height of the bookmark bar, so that the height returned 509 // We get the full height of the bookmark bar, so that the height returned
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 return; 2089 return;
2090 apps_page_shortcut_->SetVisible(visible); 2090 apps_page_shortcut_->SetVisible(visible);
2091 UpdateBookmarksSeparatorVisibility(); 2091 UpdateBookmarksSeparatorVisibility();
2092 LayoutAndPaint(); 2092 LayoutAndPaint();
2093 } 2093 }
2094 2094
2095 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2095 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2096 if (UpdateOtherAndManagedButtonsVisibility()) 2096 if (UpdateOtherAndManagedButtonsVisibility())
2097 LayoutAndPaint(); 2097 LayoutAndPaint();
2098 } 2098 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698