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

Side by Side Diff: chrome/browser/ui/views/frame/glass_browser_frame_view.cc

Issue 2717943002: Fix cc/paint skia type mismatches (Closed)
Patch Set: Rebase Created 3 years, 9 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
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/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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 ViewID button_type) { 565 ViewID button_type) {
566 Windows10CaptionButton* button = 566 Windows10CaptionButton* button =
567 new Windows10CaptionButton(this, button_type); 567 new Windows10CaptionButton(this, button_type);
568 AddChildView(button); 568 AddChildView(button);
569 return button; 569 return button;
570 } 570 }
571 571
572 void GlassBrowserFrameView::PaintTitlebar(gfx::Canvas* canvas) const { 572 void GlassBrowserFrameView::PaintTitlebar(gfx::Canvas* canvas) const {
573 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip()); 573 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view()->tabstrip());
574 574
575 SkPaint paint; 575 cc::PaintFlags flags;
576 gfx::ScopedCanvas scoped_canvas(canvas); 576 gfx::ScopedCanvas scoped_canvas(canvas);
577 float scale = canvas->UndoDeviceScaleFactor(); 577 float scale = canvas->UndoDeviceScaleFactor();
578 // This is the pixel-accurate version of WindowTopY(). Scaling the DIP values 578 // This is the pixel-accurate version of WindowTopY(). Scaling the DIP values
579 // here compounds precision error, which exposes unpainted client area. When 579 // here compounds precision error, which exposes unpainted client area. When
580 // restored it uses the system dsf instead of the per-monitor dsf to match 580 // restored it uses the system dsf instead of the per-monitor dsf to match
581 // Windows' behavior. 581 // Windows' behavior.
582 const int y = IsMaximized() ? FrameTopBorderThicknessPx(false) 582 const int y = IsMaximized() ? FrameTopBorderThicknessPx(false)
583 : std::floor(display::win::GetDPIScale()); 583 : std::floor(display::win::GetDPIScale());
584 584
585 // Draw the top of the accent border. 585 // Draw the top of the accent border.
586 // 586 //
587 // We let the DWM do this for the other sides of the window by insetting the 587 // We let the DWM do this for the other sides of the window by insetting the
588 // client area to leave nonclient area available. However, along the top 588 // client area to leave nonclient area available. However, along the top
589 // window edge, we have to have zero nonclient area or the DWM will draw a 589 // window edge, we have to have zero nonclient area or the DWM will draw a
590 // full native titlebar outside our client area. See 590 // full native titlebar outside our client area. See
591 // BrowserDesktopWindowTreeHostWin::GetClientAreaInsets(). 591 // BrowserDesktopWindowTreeHostWin::GetClientAreaInsets().
592 // 592 //
593 // We could ask the DWM to draw the top accent border in the client area (by 593 // We could ask the DWM to draw the top accent border in the client area (by
594 // calling DwmExtendFrameIntoClientArea() in 594 // calling DwmExtendFrameIntoClientArea() in
595 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()), but this requires 595 // BrowserDesktopWindowTreeHostWin::UpdateDWMFrame()), but this requires
596 // that we leave part of the client surface transparent. If we draw this 596 // that we leave part of the client surface transparent. If we draw this
597 // ourselves, we can make the client surface fully opaque and avoid the 597 // ourselves, we can make the client surface fully opaque and avoid the
598 // power consumption needed for DWM to blend the window contents. 598 // power consumption needed for DWM to blend the window contents.
599 // 599 //
600 // So the accent border also has to be opaque, but native inactive borders 600 // So the accent border also has to be opaque, but native inactive borders
601 // are #565656 with 80% alpha. We copy Edge (which also custom-draws its top 601 // are #565656 with 80% alpha. We copy Edge (which also custom-draws its top
602 // border) and use #A2A2A2 instead. 602 // border) and use #A2A2A2 instead.
603 constexpr SkColor inactive_border_color = 0xFFA2A2A2; 603 constexpr SkColor inactive_border_color = 0xFFA2A2A2;
604 paint.setColor( 604 flags.setColor(
605 ShouldPaintAsActive() 605 ShouldPaintAsActive()
606 ? GetThemeProvider()->GetColor(ThemeProperties::COLOR_ACCENT_BORDER) 606 ? GetThemeProvider()->GetColor(ThemeProperties::COLOR_ACCENT_BORDER)
607 : inactive_border_color); 607 : inactive_border_color);
608 canvas->DrawRect(gfx::RectF(0, 0, width() * scale, y), paint); 608 canvas->DrawRect(gfx::RectF(0, 0, width() * scale, y), flags);
609 609
610 const gfx::Rect titlebar_rect = gfx::ToEnclosingRect( 610 const gfx::Rect titlebar_rect = gfx::ToEnclosingRect(
611 gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y)); 611 gfx::RectF(0, y, width() * scale, tabstrip_bounds.bottom() * scale - y));
612 // Paint the titlebar first so we have a background if an area isn't covered 612 // Paint the titlebar first so we have a background if an area isn't covered
613 // by the theme image. 613 // by the theme image.
614 paint.setColor(GetTitlebarColor()); 614 flags.setColor(GetTitlebarColor());
615 canvas->DrawRect(titlebar_rect, paint); 615 canvas->DrawRect(titlebar_rect, flags);
616 const gfx::ImageSkia frame_image = GetFrameImage(); 616 const gfx::ImageSkia frame_image = GetFrameImage();
617 if (!frame_image.isNull()) { 617 if (!frame_image.isNull()) {
618 canvas->TileImageInt(frame_image, 0, 0, scale, scale, titlebar_rect.x(), 618 canvas->TileImageInt(frame_image, 0, 0, scale, scale, titlebar_rect.x(),
619 titlebar_rect.y(), titlebar_rect.width(), 619 titlebar_rect.y(), titlebar_rect.width(),
620 titlebar_rect.height()); 620 titlebar_rect.height());
621 } 621 }
622 const gfx::ImageSkia frame_overlay_image = GetFrameOverlayImage(); 622 const gfx::ImageSkia frame_overlay_image = GetFrameOverlayImage();
623 if (!frame_overlay_image.isNull()) { 623 if (!frame_overlay_image.isNull()) {
624 canvas->DrawImageInt(frame_overlay_image, 0, 0, frame_overlay_image.width(), 624 canvas->DrawImageInt(frame_overlay_image, 0, 0, frame_overlay_image.width(),
625 frame_overlay_image.height(), titlebar_rect.x(), 625 frame_overlay_image.height(), titlebar_rect.x(),
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 static bool initialized = false; 915 static bool initialized = false;
916 if (!initialized) { 916 if (!initialized) {
917 for (int i = 0; i < kThrobberIconCount; ++i) { 917 for (int i = 0; i < kThrobberIconCount; ++i) {
918 throbber_icons_[i] = 918 throbber_icons_[i] =
919 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 919 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
920 DCHECK(throbber_icons_[i]); 920 DCHECK(throbber_icons_[i]);
921 } 921 }
922 initialized = true; 922 initialized = true;
923 } 923 }
924 } 924 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698