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

Side by Side Diff: content/browser/renderer_host/browser_compositor_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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_base.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser_compositor_view_mac.h" 5 #include "content/browser/renderer_host/browser_compositor_view_mac.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "content/browser/compositor/image_transport_factory.h" 13 #include "content/browser/compositor/image_transport_factory.h"
14 #include "content/browser/renderer_host/compositor_resize_lock.h" 14 #include "content/browser/renderer_host/compositor_resize_lock.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/context_factory.h" 16 #include "content/public/browser/context_factory.h"
17 #include "media/base/video_frame.h" 17 #include "media/base/video_frame.h"
18 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" 18 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
19 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" 19 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
20 #include "ui/base/layout.h" 20 #include "ui/base/layout.h"
21 #include "ui/display/screen.h"
21 #include "ui/gfx/geometry/dip_util.h" 22 #include "ui/gfx/geometry/dip_util.h"
22 23
23 namespace content { 24 namespace content {
24 25
25 namespace { 26 namespace {
26 27
27 // Set when no browser compositors should remain alive. 28 // Set when no browser compositors should remain alive.
28 bool g_has_shut_down = false; 29 bool g_has_shut_down = false;
29 30
30 // The number of placeholder objects allocated. If this reaches zero, then 31 // The number of placeholder objects allocated. If this reaches zero, then
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 has_transparent_background_); 350 has_transparent_background_);
350 recyclable_compositor_->accelerated_widget_mac()->SetNSView( 351 recyclable_compositor_->accelerated_widget_mac()->SetNSView(
351 accelerated_widget_mac_ns_view_); 352 accelerated_widget_mac_ns_view_);
352 state_ = HasDetachedCompositor; 353 state_ = HasDetachedCompositor;
353 } 354 }
354 355
355 // Transition HasDetachedCompositor -> HasAttachedCompositor. 356 // Transition HasDetachedCompositor -> HasAttachedCompositor.
356 if (state_ == HasDetachedCompositor && new_state == HasAttachedCompositor) { 357 if (state_ == HasDetachedCompositor && new_state == HasAttachedCompositor) {
357 NSView* ns_view = 358 NSView* ns_view =
358 accelerated_widget_mac_ns_view_->AcceleratedWidgetGetNSView(); 359 accelerated_widget_mac_ns_view_->AcceleratedWidgetGetNSView();
359 float scale_factor = ui::GetScaleFactorForNativeView(ns_view); 360 display::Display display =
ccameron 2017/06/26 22:45:02 At the moment, ui::GetScaleFactorForNativeView wra
361 display::Screen::GetScreen()->GetDisplayNearestView(ns_view);
360 NSSize dip_ns_size = [ns_view bounds].size; 362 NSSize dip_ns_size = [ns_view bounds].size;
361 gfx::Size pixel_size(dip_ns_size.width * scale_factor, 363 gfx::Size pixel_size(dip_ns_size.width * display.device_scale_factor(),
362 dip_ns_size.height * scale_factor); 364 dip_ns_size.height * display.device_scale_factor());
363 365
364 delegated_frame_host_->SetCompositor(recyclable_compositor_->compositor()); 366 delegated_frame_host_->SetCompositor(recyclable_compositor_->compositor());
365 delegated_frame_host_->WasShown(ui::LatencyInfo()); 367 delegated_frame_host_->WasShown(ui::LatencyInfo());
366 // Unsuspend the browser compositor after showing the delegated frame host. 368 // Unsuspend the browser compositor after showing the delegated frame host.
367 // If there is not a saved delegated frame, then the delegated frame host 369 // If there is not a saved delegated frame, then the delegated frame host
368 // will keep the compositor locked until a delegated frame is swapped. 370 // will keep the compositor locked until a delegated frame is swapped.
369 recyclable_compositor_->compositor()->SetScaleAndSize(scale_factor, 371 recyclable_compositor_->compositor()->SetDisplayColorSpace(
370 pixel_size); 372 display.color_space());
373 recyclable_compositor_->compositor()->SetScaleAndSize(
374 display.device_scale_factor(), pixel_size);
371 recyclable_compositor_->Unsuspend(); 375 recyclable_compositor_->Unsuspend();
372 state_ = HasAttachedCompositor; 376 state_ = HasAttachedCompositor;
373 } 377 }
374 378
375 // Transition HasAttachedCompositor -> HasDetachedCompositor. 379 // Transition HasAttachedCompositor -> HasDetachedCompositor.
376 if (state_ == HasAttachedCompositor && new_state != HasAttachedCompositor) { 380 if (state_ == HasAttachedCompositor && new_state != HasAttachedCompositor) {
377 // Ensure that any changes made to the ui::Compositor do not result in new 381 // Ensure that any changes made to the ui::Compositor do not result in new
378 // frames being produced. 382 // frames being produced.
379 recyclable_compositor_->Suspend(); 383 recyclable_compositor_->Suspend();
380 // Marking the DelegatedFrameHost as removed from the window hierarchy is 384 // Marking the DelegatedFrameHost as removed from the window hierarchy is
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 void BrowserCompositorMac::OnBeginFrame() { 443 void BrowserCompositorMac::OnBeginFrame() {
440 client_->BrowserCompositorMacOnBeginFrame(); 444 client_->BrowserCompositorMacOnBeginFrame();
441 } 445 }
442 446
443 bool BrowserCompositorMac::IsAutoResizeEnabled() const { 447 bool BrowserCompositorMac::IsAutoResizeEnabled() const {
444 NOTREACHED(); 448 NOTREACHED();
445 return false; 449 return false;
446 } 450 }
447 451
448 } // namespace content 452 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698