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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2959873002: color: Add NSScreenColorSpaceDidChangeNotification observer (Closed)
Patch Set: Created 3 years, 5 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 "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 725 }
726 726
727 RenderWidgetHostDelegate* 727 RenderWidgetHostDelegate*
728 RenderWidgetHostViewMac::GetFocusedRenderWidgetHostDelegate() { 728 RenderWidgetHostViewMac::GetFocusedRenderWidgetHostDelegate() {
729 if (auto* focused_widget = GetFocusedWidget()) 729 if (auto* focused_widget = GetFocusedWidget())
730 return focused_widget->delegate(); 730 return focused_widget->delegate();
731 return render_widget_host_->delegate(); 731 return render_widget_host_->delegate();
732 } 732 }
733 733
734 void RenderWidgetHostViewMac::UpdateBackingStoreProperties() { 734 void RenderWidgetHostViewMac::UpdateBackingStoreProperties() {
735 if (!render_widget_host_) 735 UpdateScreenInfo(cocoa_view_);
736 return; 736 // Update the ui::Compositor's color space here. The other display properties
737 render_widget_host_->NotifyScreenInfoChanged(); 737 // of the ui::Compositor are updated by frame metadata.
738 if (browser_compositor_)
739 browser_compositor_->SetDisplayColorSpace(current_display_color_space_);
738 } 740 }
739 741
740 RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const { 742 RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const {
741 return render_widget_host_; 743 return render_widget_host_;
742 } 744 }
743 745
744 void RenderWidgetHostViewMac::Show() { 746 void RenderWidgetHostViewMac::Show() {
745 ScopedCAActionDisabler disabler; 747 ScopedCAActionDisabler disabler;
746 [cocoa_view_ setHidden:NO]; 748 [cocoa_view_ setHidden:NO];
747 749
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 if (display.id() != screen->GetDisplayNearestView(cocoa_view_).id()) 1735 if (display.id() != screen->GetDisplayNearestView(cocoa_view_).id())
1734 return; 1736 return;
1735 1737
1736 if (changed_metrics & DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR) { 1738 if (changed_metrics & DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR) {
1737 RenderWidgetHostImpl* host = 1739 RenderWidgetHostImpl* host =
1738 RenderWidgetHostImpl::From(GetRenderWidgetHost()); 1740 RenderWidgetHostImpl::From(GetRenderWidgetHost());
1739 if (host && host->delegate()) 1741 if (host && host->delegate())
1740 host->delegate()->UpdateDeviceScaleFactor(display.device_scale_factor()); 1742 host->delegate()->UpdateDeviceScaleFactor(display.device_scale_factor());
1741 } 1743 }
1742 1744
1743 UpdateScreenInfo(cocoa_view_); 1745 UpdateBackingStoreProperties();
1744 } 1746 }
1745 1747
1746 } // namespace content 1748 } // namespace content
1747 1749
1748 // RenderWidgetHostViewCocoa --------------------------------------------------- 1750 // RenderWidgetHostViewCocoa ---------------------------------------------------
1749 1751
1750 @implementation RenderWidgetHostViewCocoa 1752 @implementation RenderWidgetHostViewCocoa
1751 @synthesize selectedRange = selectedRange_; 1753 @synthesize selectedRange = selectedRange_;
1752 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; 1754 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_;
1753 @synthesize markedRange = markedRange_; 1755 @synthesize markedRange = markedRange_;
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 // Allocating a CGLayerRef with the current scale factor immediately from 2681 // Allocating a CGLayerRef with the current scale factor immediately from
2680 // this handler doesn't work. Schedule the backing store update on the 2682 // this handler doesn't work. Schedule the backing store update on the
2681 // next runloop cycle, then things are read for CGLayerRef allocations to 2683 // next runloop cycle, then things are read for CGLayerRef allocations to
2682 // work. 2684 // work.
2683 [self performSelector:@selector(updateScreenProperties) 2685 [self performSelector:@selector(updateScreenProperties)
2684 withObject:nil 2686 withObject:nil
2685 afterDelay:0]; 2687 afterDelay:0];
2686 } 2688 }
2687 2689
2688 - (void)windowChangedGlobalFrame:(NSNotification*)notification { 2690 - (void)windowChangedGlobalFrame:(NSNotification*)notification {
2689 renderWidgetHostView_->UpdateScreenInfo( 2691 renderWidgetHostView_->UpdateBackingStoreProperties();
2690 renderWidgetHostView_->GetNativeView());
2691 } 2692 }
2692 2693
2693 - (void)setFrameSize:(NSSize)newSize { 2694 - (void)setFrameSize:(NSSize)newSize {
2694 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::setFrameSize"); 2695 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::setFrameSize");
2695 2696
2696 // NB: -[NSView setFrame:] calls through -setFrameSize:, so overriding 2697 // NB: -[NSView setFrame:] calls through -setFrameSize:, so overriding
2697 // -setFrame: isn't neccessary. 2698 // -setFrame: isn't neccessary.
2698 [super setFrameSize:newSize]; 2699 [super setFrameSize:newSize];
2699 2700
2700 if (!renderWidgetHostView_->render_widget_host_) 2701 if (!renderWidgetHostView_->render_widget_host_)
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 if (hasOpenMouseDown_) { 3337 if (hasOpenMouseDown_) {
3337 WebMouseEvent event(WebInputEvent::kMouseUp, WebInputEvent::kNoModifiers, 3338 WebMouseEvent event(WebInputEvent::kMouseUp, WebInputEvent::kNoModifiers,
3338 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 3339 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
3339 event.button = WebMouseEvent::Button::kLeft; 3340 event.button = WebMouseEvent::Button::kLeft;
3340 renderWidgetHostView_->ForwardMouseEvent(event); 3341 renderWidgetHostView_->ForwardMouseEvent(event);
3341 3342
3342 hasOpenMouseDown_ = NO; 3343 hasOpenMouseDown_ = NO;
3343 } 3344 }
3344 } 3345 }
3345 3346
3346 - (void)viewDidChangeBackingProperties {
3347 NSScreen* screen = [[self window] screen];
3348 if (screen) {
3349 CGColorSpaceRef color_space = [[screen colorSpace] CGColorSpace];
3350 // On Sierra, we need to operate in a single screen's color space because
3351 // IOSurfaces do not opt-out of color correction.
3352 // https://crbug.com/654488
3353 if (base::mac::IsAtLeastOS10_12())
3354 color_space = base::mac::GetSystemColorSpace();
3355 gfx::ICCProfile icc_profile =
3356 gfx::ICCProfile::FromCGColorSpace(color_space);
3357 renderWidgetHostView_->browser_compositor_->SetDisplayColorSpace(
3358 icc_profile.GetColorSpace());
3359 }
3360 }
3361
3362 - (void)undo:(id)sender { 3347 - (void)undo:(id)sender {
3363 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); 3348 WebContents* web_contents = renderWidgetHostView_->GetWebContents();
3364 if (web_contents) 3349 if (web_contents)
3365 web_contents->Undo(); 3350 web_contents->Undo();
3366 } 3351 }
3367 3352
3368 - (void)redo:(id)sender { 3353 - (void)redo:(id)sender {
3369 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); 3354 WebContents* web_contents = renderWidgetHostView_->GetWebContents();
3370 if (web_contents) 3355 if (web_contents)
3371 web_contents->Redo(); 3356 web_contents->Redo();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3528 3513
3529 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3514 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3530 // regions that are not draggable. (See ControlRegionView in 3515 // regions that are not draggable. (See ControlRegionView in
3531 // native_app_window_cocoa.mm). This requires the render host view to be 3516 // native_app_window_cocoa.mm). This requires the render host view to be
3532 // draggable by default. 3517 // draggable by default.
3533 - (BOOL)mouseDownCanMoveWindow { 3518 - (BOOL)mouseDownCanMoveWindow {
3534 return YES; 3519 return YES;
3535 } 3520 }
3536 3521
3537 @end 3522 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698