Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/frame/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 | 491 |
| 492 Windows10CaptionButton* GlassBrowserFrameView::CreateCaptionButton( | 492 Windows10CaptionButton* GlassBrowserFrameView::CreateCaptionButton( |
| 493 ViewID button_type) { | 493 ViewID button_type) { |
| 494 Windows10CaptionButton* button = | 494 Windows10CaptionButton* button = |
| 495 new Windows10CaptionButton(this, button_type); | 495 new Windows10CaptionButton(this, button_type); |
| 496 AddChildView(button); | 496 AddChildView(button); |
| 497 return button; | 497 return button; |
| 498 } | 498 } |
| 499 | 499 |
| 500 void GlassBrowserFrameView::PaintTitlebar(gfx::Canvas* canvas) const { | 500 void GlassBrowserFrameView::PaintTitlebar(gfx::Canvas* canvas) const { |
| 501 // Normally the inactive accent border is semi-transparent, but we want to | |
| 502 // make it opaque so that DWM won't need to blend with windows behind | |
| 503 // Chrome. This color is the same as Edge uses and closely matches the | |
| 504 // appearance of the normal inactive accent border. | |
| 505 constexpr SkColor inactive_border_color = 0xFFA2A2A2; | |
| 501 SkColor frame_color = 0xFFCCCCCC; | 506 SkColor frame_color = 0xFFCCCCCC; |
| 502 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip()); | 507 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip()); |
|
Peter Kasting
2016/10/06 08:02:47
Nit: Let's move these constants down to just above
| |
| 503 | 508 |
| 504 gfx::ScopedCanvas scoped_canvas(canvas); | 509 gfx::ScopedCanvas scoped_canvas(canvas); |
| 505 float scale = canvas->UndoDeviceScaleFactor(); | 510 float scale = canvas->UndoDeviceScaleFactor(); |
| 506 // This is the pixel-accurate version of WindowTopY(). Scaling the DIP values | 511 // This is the pixel-accurate version of WindowTopY(). Scaling the DIP values |
| 507 // here compounds precision error, which exposes the native Windows caption | 512 // here compounds precision error, which exposes the native Windows caption |
| 508 // buttons we need to draw over. (see the comment in | 513 // buttons we need to draw over. (see the comment in |
| 509 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()). | 514 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()). |
| 510 const int y = IsMaximized() ? FrameTopBorderThicknessPx(false) : 1; | 515 const int y = IsMaximized() ? FrameTopBorderThicknessPx(false) : 1; |
| 511 SkPaint paint; | 516 SkPaint paint; |
| 517 | |
| 518 // Draw the top of the accent border. DWM does this for the other sides of | |
| 519 // the window, and Chrome uses an inset to avoid drawing over top of them. | |
| 520 // However the top of the window must have an inset of 0 or else DWM draws a | |
| 521 // full set of caption buttons outside the window. | |
| 522 // | |
| 523 // Chrome should draw this itself instead of using transparency so that | |
| 524 // alpha blending can be disabled on the window, which saves power when | |
| 525 // compositing. | |
|
Peter Kasting
2016/10/06 08:02:47
Nit: This comment partially restates info from the
Bret
2016/10/06 20:48:10
I like Peter's suggestion in general. I made some
| |
| 526 paint.setColor( | |
| 527 ShouldPaintAsActive() | |
| 528 ? GetThemeProvider()->GetColor(ThemeProperties::COLOR_ACCENT_BORDER) | |
| 529 : inactive_border_color); | |
| 530 canvas->DrawRect(gfx::RectF(0, 0, width() * scale, y), paint); | |
|
Peter Kasting
2016/10/06 08:02:47
Nit: Blank line below this, since the comment abov
| |
| 512 paint.setColor(frame_color); | 531 paint.setColor(frame_color); |
| 513 canvas->DrawRect( | 532 canvas->DrawRect( |
| 514 gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y), | 533 gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y), |
| 515 paint); | 534 paint); |
| 516 | |
| 517 // The 1 pixel line at the top is drawn by Windows when we leave that section | |
| 518 // of the window blank because we have called DwmExtendFrameIntoClientArea() | |
| 519 // inside BrowserDesktopWindowTreeHostWin::UpdateDWMFrame(). | |
| 520 } | 535 } |
| 521 | 536 |
| 522 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { | 537 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { |
| 523 // TODO(estade): can this be shared with OpaqueBrowserFrameView? | 538 // TODO(estade): can this be shared with OpaqueBrowserFrameView? |
| 524 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 539 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
| 525 if (toolbar_bounds.IsEmpty()) | 540 if (toolbar_bounds.IsEmpty()) |
| 526 return; | 541 return; |
| 527 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 542 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 528 ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 543 ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
| 529 toolbar_bounds.set_origin(toolbar_origin); | 544 toolbar_bounds.set_origin(toolbar_origin); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 static bool initialized = false; | 790 static bool initialized = false; |
| 776 if (!initialized) { | 791 if (!initialized) { |
| 777 for (int i = 0; i < kThrobberIconCount; ++i) { | 792 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 778 throbber_icons_[i] = | 793 throbber_icons_[i] = |
| 779 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 794 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
| 780 DCHECK(throbber_icons_[i]); | 795 DCHECK(throbber_icons_[i]); |
| 781 } | 796 } |
| 782 initialized = true; | 797 initialized = true; |
| 783 } | 798 } |
| 784 } | 799 } |
| OLD | NEW |