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

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
« no previous file with comments | « ash/frame/default_header_painter.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 #include "ui/base/page_transition_types.h" 76 #include "ui/base/page_transition_types.h"
77 #include "ui/base/resource/material_design/material_design_controller.h" 77 #include "ui/base/resource/material_design/material_design_controller.h"
78 #include "ui/base/resource/resource_bundle.h" 78 #include "ui/base/resource/resource_bundle.h"
79 #include "ui/base/theme_provider.h" 79 #include "ui/base/theme_provider.h"
80 #include "ui/base/window_open_disposition.h" 80 #include "ui/base/window_open_disposition.h"
81 #include "ui/compositor/paint_recorder.h" 81 #include "ui/compositor/paint_recorder.h"
82 #include "ui/gfx/animation/slide_animation.h" 82 #include "ui/gfx/animation/slide_animation.h"
83 #include "ui/gfx/canvas.h" 83 #include "ui/gfx/canvas.h"
84 #include "ui/gfx/favicon_size.h" 84 #include "ui/gfx/favicon_size.h"
85 #include "ui/gfx/paint_vector_icon.h" 85 #include "ui/gfx/paint_vector_icon.h"
86 #include "ui/gfx/scoped_canvas.h"
86 #include "ui/gfx/text_constants.h" 87 #include "ui/gfx/text_constants.h"
87 #include "ui/gfx/text_elider.h" 88 #include "ui/gfx/text_elider.h"
88 #include "ui/gfx/vector_icons_public.h" 89 #include "ui/gfx/vector_icons_public.h"
89 #include "ui/resources/grit/ui_resources.h" 90 #include "ui/resources/grit/ui_resources.h"
90 #include "ui/views/button_drag_utils.h" 91 #include "ui/views/button_drag_utils.h"
91 #include "ui/views/controls/button/label_button.h" 92 #include "ui/views/controls/button/label_button.h"
92 #include "ui/views/controls/button/label_button_border.h" 93 #include "ui/views/controls/button/label_button_border.h"
93 #include "ui/views/controls/button/menu_button.h" 94 #include "ui/views/controls/button/menu_button.h"
94 #include "ui/views/controls/label.h" 95 #include "ui/views/controls/label.h"
95 #include "ui/views/drag_utils.h" 96 #include "ui/views/drag_utils.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 canvas->sk_canvas()->drawRect(rc_down, paint_down); 471 canvas->sk_canvas()->drawRect(rc_down, paint_down);
471 } 472 }
472 473
473 class BookmarkBarView::ButtonSeparatorView : public views::View { 474 class BookmarkBarView::ButtonSeparatorView : public views::View {
474 public: 475 public:
475 ButtonSeparatorView() {} 476 ButtonSeparatorView() {}
476 ~ButtonSeparatorView() override {} 477 ~ButtonSeparatorView() override {}
477 478
478 void OnPaint(gfx::Canvas* canvas) override { 479 void OnPaint(gfx::Canvas* canvas) override {
479 if (ui::MaterialDesignController::IsModeMaterial()) { 480 if (ui::MaterialDesignController::IsModeMaterial()) {
481 gfx::ScopedCanvas scoped_canvas(canvas);
480 // 1px wide at all scale factors. If there is an uneven amount of padding 482 // 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 483 // left over, place the extra pixel on the outside, i.e. away from the
482 // "Other bookmarks" folder. 484 // "Other bookmarks" folder.
483 const float scale = canvas->SaveAndUnscale(); 485 const float scale = canvas->UndoDeviceScaleFactor();
484 const gfx::RectF scaled_bounds = 486 const gfx::RectF scaled_bounds =
485 gfx::ScaleRect(gfx::RectF(bounds()), scale); 487 gfx::ScaleRect(gfx::RectF(bounds()), scale);
486 488
487 const int kLineThickness = 1; 489 const int kLineThickness = 1;
488 const float fractional_x = (scaled_bounds.width() - kLineThickness) / 2.f; 490 const float fractional_x = (scaled_bounds.width() - kLineThickness) / 2.f;
489 const int x = base::i18n::IsRTL() ? std::floor(fractional_x) 491 const int x = base::i18n::IsRTL() ? std::floor(fractional_x)
490 : std::ceil(fractional_x); 492 : std::ceil(fractional_x);
491 493
492 const int height = gfx::kFaviconSize * scale; 494 const int height = gfx::kFaviconSize * scale;
493 const int top_y = (scaled_bounds.height() - height) / 2; 495 const int top_y = (scaled_bounds.height() - height) / 2;
494 canvas->DrawLine( 496 canvas->DrawLine(
495 gfx::Point(x, top_y), gfx::Point(x, top_y + height), 497 gfx::Point(x, top_y), gfx::Point(x, top_y + height),
496 SkColorSetA(GetThemeProvider()->GetColor( 498 SkColorSetA(GetThemeProvider()->GetColor(
497 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON), 499 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON),
498 0x4D)); 500 0x4D));
499 canvas->Restore();
500 } else { 501 } else {
501 PaintVerticalDivider( 502 PaintVerticalDivider(
502 canvas, kSeparatorStartX, height(), 1, kEdgeDividerColor, 503 canvas, kSeparatorStartX, height(), 1, kEdgeDividerColor,
503 kMiddleDividerColor, 504 kMiddleDividerColor,
504 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR)); 505 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR));
505 } 506 }
506 } 507 }
507 508
508 gfx::Size GetPreferredSize() const override { 509 gfx::Size GetPreferredSize() const override {
509 // We get the full height of the bookmark bar, so that the height returned 510 // 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; 2090 return;
2090 apps_page_shortcut_->SetVisible(visible); 2091 apps_page_shortcut_->SetVisible(visible);
2091 UpdateBookmarksSeparatorVisibility(); 2092 UpdateBookmarksSeparatorVisibility();
2092 LayoutAndPaint(); 2093 LayoutAndPaint();
2093 } 2094 }
2094 2095
2095 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2096 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2096 if (UpdateOtherAndManagedButtonsVisibility()) 2097 if (UpdateOtherAndManagedButtonsVisibility())
2097 LayoutAndPaint(); 2098 LayoutAndPaint();
2098 } 2099 }
OLDNEW
« no previous file with comments | « ash/frame/default_header_painter.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698