Commit 10f8dfcb authored by Maggie Chen's avatar Maggie Chen Committed by Commit Bot

Move display_link_mac.cc/.h from ui/accelerated_widget_mac to ui/display/mac

ui/display/mac is the right place for display_link_mac.cc and .h


Bug: 964095
Change-Id: I83d929d27b3884bd3a24eb621717ffea9af9c889
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1638681
Commit-Queue: Maggie Chen <magchen@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665271}
parent 1b7700e7
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include "ipc/ipc_sender.h" #include "ipc/ipc_sender.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_binding.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h" #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/accelerated_widget_mac/display_link_mac.h"
#include "ui/base/cocoa/accessibility_focus_overrider.h" #include "ui/base/cocoa/accessibility_focus_overrider.h"
#include "ui/base/cocoa/remote_layer_api.h" #include "ui/base/cocoa/remote_layer_api.h"
#include "ui/display/mac/display_link_mac.h"
#include "ui/events/gesture_detection/filtered_gesture_provider.h" #include "ui/events/gesture_detection/filtered_gesture_provider.h"
namespace remote_cocoa { namespace remote_cocoa {
......
...@@ -20,8 +20,6 @@ component("accelerated_widget_mac") { ...@@ -20,8 +20,6 @@ component("accelerated_widget_mac") {
"ca_transaction_observer.mm", "ca_transaction_observer.mm",
"display_ca_layer_tree.h", "display_ca_layer_tree.h",
"display_ca_layer_tree.mm", "display_ca_layer_tree.mm",
"display_link_mac.cc",
"display_link_mac.h",
"io_surface_context.h", "io_surface_context.h",
"io_surface_context.mm", "io_surface_context.mm",
"window_resize_helper_mac.cc", "window_resize_helper_mac.cc",
......
...@@ -29,6 +29,8 @@ jumbo_component("display") { ...@@ -29,6 +29,8 @@ jumbo_component("display") {
"display_switches.cc", "display_switches.cc",
"display_switches.h", "display_switches.h",
"ios/screen_ios.mm", "ios/screen_ios.mm",
"mac/display_link_mac.cc",
"mac/display_link_mac.h",
"mac/screen_mac.mm", "mac/screen_mac.mm",
"screen.cc", "screen.cc",
"screen.h", "screen.h",
...@@ -54,8 +56,6 @@ jumbo_component("display") { ...@@ -54,8 +56,6 @@ jumbo_component("display") {
"win/uwp_text_scale_factor.h", "win/uwp_text_scale_factor.h",
] ]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
defines = [ "DISPLAY_IMPLEMENTATION" ] defines = [ "DISPLAY_IMPLEMENTATION" ]
public_deps = [ public_deps = [
...@@ -85,6 +85,7 @@ jumbo_component("display") { ...@@ -85,6 +85,7 @@ jumbo_component("display") {
libs = [ libs = [
"AppKit.framework", "AppKit.framework",
"CoreGraphics.framework", "CoreGraphics.framework",
"QuartzCore.framework",
] ]
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/accelerated_widget_mac/display_link_mac.h" #include "ui/display/mac/display_link_mac.h"
#include <stdint.h> #include <stdint.h>
...@@ -17,15 +17,13 @@ ...@@ -17,15 +17,13 @@
namespace base { namespace base {
template<> template <>
struct ScopedTypeRefTraits<CVDisplayLinkRef> { struct ScopedTypeRefTraits<CVDisplayLinkRef> {
static CVDisplayLinkRef InvalidValue() { return nullptr; } static CVDisplayLinkRef InvalidValue() { return nullptr; }
static CVDisplayLinkRef Retain(CVDisplayLinkRef object) { static CVDisplayLinkRef Retain(CVDisplayLinkRef object) {
return CVDisplayLinkRetain(object); return CVDisplayLinkRetain(object);
} }
static void Release(CVDisplayLinkRef object) { static void Release(CVDisplayLinkRef object) { CVDisplayLinkRelease(object); }
CVDisplayLinkRelease(object);
}
}; };
} // namespace base } // namespace base
...@@ -40,6 +38,10 @@ namespace { ...@@ -40,6 +38,10 @@ namespace {
// is initialized with the very first DisplayLinkMac instance, and is never // is initialized with the very first DisplayLinkMac instance, and is never
// changed (even, e.g, in tests that re-initialize the main thread task runner). // changed (even, e.g, in tests that re-initialize the main thread task runner).
// https://885329 // https://885329
// TODO(ccameron): crbug.com/969157 - Save this ask_runner to DisaplayLinkMac.
// configs += [ "//build/config/compiler:wexit_time_destructors" ] in
// ui/display/BUILD.gn has to be removed because GetMainThreadTaskRunner()
// causes a compiler error.
scoped_refptr<base::SingleThreadTaskRunner> GetMainThreadTaskRunner() { scoped_refptr<base::SingleThreadTaskRunner> GetMainThreadTaskRunner() {
static scoped_refptr<base::SingleThreadTaskRunner> task_runner = static scoped_refptr<base::SingleThreadTaskRunner> task_runner =
base::ThreadTaskRunnerHandle::Get(); base::ThreadTaskRunnerHandle::Get();
...@@ -80,9 +82,8 @@ scoped_refptr<DisplayLinkMac> DisplayLinkMac::GetForDisplay( ...@@ -80,9 +82,8 @@ scoped_refptr<DisplayLinkMac> DisplayLinkMac::GetForDisplay(
CVReturn ret = kCVReturnSuccess; CVReturn ret = kCVReturnSuccess;
base::ScopedTypeRef<CVDisplayLinkRef> display_link; base::ScopedTypeRef<CVDisplayLinkRef> display_link;
ret = CVDisplayLinkCreateWithCGDisplay( ret = CVDisplayLinkCreateWithCGDisplay(display_id,
display_id, display_link.InitializeInto());
display_link.InitializeInto());
if (ret != kCVReturnSuccess) { if (ret != kCVReturnSuccess) {
LOG(ERROR) << "CVDisplayLinkCreateWithActiveCGDisplays failed: " << ret; LOG(ERROR) << "CVDisplayLinkCreateWithActiveCGDisplays failed: " << ret;
return nullptr; return nullptr;
...@@ -111,8 +112,7 @@ DisplayLinkMac::DisplayLinkMac( ...@@ -111,8 +112,7 @@ DisplayLinkMac::DisplayLinkMac(
CGError register_error = CGDisplayRegisterReconfigurationCallback( CGError register_error = CGDisplayRegisterReconfigurationCallback(
DisplayReconfigurationCallBack, nullptr); DisplayReconfigurationCallBack, nullptr);
DPLOG_IF(ERROR, register_error != kCGErrorSuccess) DPLOG_IF(ERROR, register_error != kCGErrorSuccess)
<< "CGDisplayRegisterReconfigurationCallback: " << "CGDisplayRegisterReconfigurationCallback: " << register_error;
<< register_error;
} }
all_display_links.insert(std::make_pair(display_id_, this)); all_display_links.insert(std::make_pair(display_id_, this));
} }
...@@ -129,13 +129,12 @@ DisplayLinkMac::~DisplayLinkMac() { ...@@ -129,13 +129,12 @@ DisplayLinkMac::~DisplayLinkMac() {
CGError remove_error = CGDisplayRemoveReconfigurationCallback( CGError remove_error = CGDisplayRemoveReconfigurationCallback(
DisplayReconfigurationCallBack, nullptr); DisplayReconfigurationCallBack, nullptr);
DPLOG_IF(ERROR, remove_error != kCGErrorSuccess) DPLOG_IF(ERROR, remove_error != kCGErrorSuccess)
<< "CGDisplayRemoveReconfigurationCallback: " << "CGDisplayRemoveReconfigurationCallback: " << remove_error;
<< remove_error;
} }
} }
bool DisplayLinkMac::GetVSyncParameters( bool DisplayLinkMac::GetVSyncParameters(base::TimeTicks* timebase,
base::TimeTicks* timebase, base::TimeDelta* interval) { base::TimeDelta* interval) {
if (!timebase_and_interval_valid_) { if (!timebase_and_interval_valid_) {
StartOrContinueDisplayLink(); StartOrContinueDisplayLink();
return false; return false;
...@@ -200,8 +199,7 @@ void DisplayLinkMac::UpdateVSyncParameters(const CVTimeStamp& cv_time) { ...@@ -200,8 +199,7 @@ void DisplayLinkMac::UpdateVSyncParameters(const CVTimeStamp& cv_time) {
timebase_and_interval_valid_ = true; timebase_and_interval_valid_ = true;
// Don't restart the display link for 10 seconds. // Don't restart the display link for 10 seconds.
recalculate_time_ = base::TimeTicks::Now() + recalculate_time_ = base::TimeTicks::Now() + base::TimeDelta::FromSeconds(10);
base::TimeDelta::FromSeconds(10);
StopDisplayLink(); StopDisplayLink();
} }
...@@ -224,13 +222,12 @@ void DisplayLinkMac::StopDisplayLink() { ...@@ -224,13 +222,12 @@ void DisplayLinkMac::StopDisplayLink() {
} }
// static // static
CVReturn DisplayLinkMac::DisplayLinkCallback( CVReturn DisplayLinkMac::DisplayLinkCallback(CVDisplayLinkRef display_link,
CVDisplayLinkRef display_link, const CVTimeStamp* now,
const CVTimeStamp* now, const CVTimeStamp* output_time,
const CVTimeStamp* output_time, CVOptionFlags flags_in,
CVOptionFlags flags_in, CVOptionFlags* flags_out,
CVOptionFlags* flags_out, void* context) {
void* context) {
TRACE_EVENT0("ui", "DisplayLinkMac::DisplayLinkCallback"); TRACE_EVENT0("ui", "DisplayLinkMac::DisplayLinkCallback");
CGDirectDisplayID display = CGDirectDisplayID display =
static_cast<CGDirectDisplayID>(reinterpret_cast<uintptr_t>(context)); static_cast<CGDirectDisplayID>(reinterpret_cast<uintptr_t>(context));
...@@ -254,4 +251,4 @@ void DisplayLinkMac::DisplayReconfigurationCallBack( ...@@ -254,4 +251,4 @@ void DisplayLinkMac::DisplayReconfigurationCallBack(
display_link_mac->timebase_and_interval_valid_ = false; display_link_mac->timebase_and_interval_valid_ = false;
} }
} // ui } // namespace ui
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_ACCELERATED_WIDGET_MAC_DISPLAY_LINK_MAC_H_ #ifndef UI_DISPLAY_MAC_DISPLAY_LINK_MAC_H_
#define UI_ACCELERATED_WIDGET_MAC_DISPLAY_LINK_MAC_H_ #define UI_DISPLAY_MAC_DISPLAY_LINK_MAC_H_
#include <QuartzCore/CVDisplayLink.h> #include <QuartzCore/CVDisplayLink.h>
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
#include "base/mac/scoped_typeref.h" #include "base/mac/scoped_typeref.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h" #include "ui/display/display_export.h"
namespace ui { namespace ui {
class ACCELERATED_WIDGET_MAC_EXPORT DisplayLinkMac class DISPLAY_EXPORT DisplayLinkMac
: public base::RefCountedThreadSafe<DisplayLinkMac> { : public base::RefCountedThreadSafe<DisplayLinkMac> {
public: public:
// This must only be called from the main thread. // This must only be called from the main thread.
...@@ -25,16 +25,13 @@ class ACCELERATED_WIDGET_MAC_EXPORT DisplayLinkMac ...@@ -25,16 +25,13 @@ class ACCELERATED_WIDGET_MAC_EXPORT DisplayLinkMac
// Get vsync scheduling parameters. Returns false if the populated parameters // Get vsync scheduling parameters. Returns false if the populated parameters
// are invalid. // are invalid.
bool GetVSyncParameters( bool GetVSyncParameters(base::TimeTicks* timebase, base::TimeDelta* interval);
base::TimeTicks* timebase,
base::TimeDelta* interval);
private: private:
friend class base::RefCountedThreadSafe<DisplayLinkMac>; friend class base::RefCountedThreadSafe<DisplayLinkMac>;
DisplayLinkMac( DisplayLinkMac(CGDirectDisplayID display_id,
CGDirectDisplayID display_id, base::ScopedTypeRef<CVDisplayLinkRef> display_link);
base::ScopedTypeRef<CVDisplayLinkRef> display_link);
virtual ~DisplayLinkMac(); virtual ~DisplayLinkMac();
void StartOrContinueDisplayLink(); void StartOrContinueDisplayLink();
...@@ -50,20 +47,18 @@ class ACCELERATED_WIDGET_MAC_EXPORT DisplayLinkMac ...@@ -50,20 +47,18 @@ class ACCELERATED_WIDGET_MAC_EXPORT DisplayLinkMac
// Called by the system on the display link thread, and posts a call to // Called by the system on the display link thread, and posts a call to
// DoUpdateVSyncParameters() to the UI thread. // DoUpdateVSyncParameters() to the UI thread.
static CVReturn DisplayLinkCallback( static CVReturn DisplayLinkCallback(CVDisplayLinkRef display_link,
CVDisplayLinkRef display_link, const CVTimeStamp* now,
const CVTimeStamp* now, const CVTimeStamp* output_time,
const CVTimeStamp* output_time, CVOptionFlags flags_in,
CVOptionFlags flags_in, CVOptionFlags* flags_out,
CVOptionFlags* flags_out, void* context);
void* context);
// This is called whenever the display is reconfigured, and marks that the // This is called whenever the display is reconfigured, and marks that the
// vsync parameters must be recalculated. // vsync parameters must be recalculated.
static void DisplayReconfigurationCallBack( static void DisplayReconfigurationCallBack(CGDirectDisplayID display,
CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags,
CGDisplayChangeSummaryFlags flags, void* user_info);
void* user_info);
// The display that this display link is attached to. // The display that this display link is attached to.
CGDirectDisplayID display_id_; CGDirectDisplayID display_id_;
...@@ -81,6 +76,6 @@ class ACCELERATED_WIDGET_MAC_EXPORT DisplayLinkMac ...@@ -81,6 +76,6 @@ class ACCELERATED_WIDGET_MAC_EXPORT DisplayLinkMac
base::TimeTicks recalculate_time_; base::TimeTicks recalculate_time_;
}; };
} // ui } // namespace ui
#endif // UI_ACCELERATED_WIDGET_MAC_DISPLAY_LINK_MAC_H_ #endif // UI_DISPLAY_MAC_DISPLAY_LINK_MAC_H_
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#include "components/remote_cocoa/common/bridged_native_widget_host.mojom.h" #include "components/remote_cocoa/common/bridged_native_widget_host.mojom.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_binding.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h" #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/accelerated_widget_mac/display_link_mac.h"
#include "ui/base/cocoa/accessibility_focus_overrider.h" #include "ui/base/cocoa/accessibility_focus_overrider.h"
#include "ui/base/ime/input_method_delegate.h" #include "ui/base/ime/input_method_delegate.h"
#include "ui/compositor/layer_owner.h" #include "ui/compositor/layer_owner.h"
#include "ui/display/mac/display_link_mac.h"
#include "ui/views/cocoa/drag_drop_client_mac.h" #include "ui/views/cocoa/drag_drop_client_mac.h"
#include "ui/views/focus/focus_manager.h" #include "ui/views/focus/focus_manager.h"
#include "ui/views/views_export.h" #include "ui/views/views_export.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment