Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit c1eeced

Browse files
committed
Make DesktopFactoryOzone pick the proper DesktopFactoryOzone{Platform} on the fly
Patch does two main things: 1) Replaces 0002-Remove-usage-of-DesktopFactory.patch by 0002-Adapt-DesktopFactoryOzone-to-respect-ozone-platform-.patch in patches/. This way ozone/wayland continues to make use of the DesktopFactoryOzone abstraction, and tweaks ::GetInstance to create the proper DesktopFactoryOzone{Platform} instance on the fly. 2) Adds some GYP hooks that actually allows DesktopFactoryOzone::GetInstance to instantiate the proper DesktopFactoryOzone{Platform} object on demand, according to either --ozone-platform, or to a default value. TEST=regular GYP build GYP_DEFINES="component=static_library clang=0 use_sysroot=0 linux_use_bundled_gold=0 use_ozone=1 ozone_auto_platforms=0 ozone_platform_wayland=1 use_xkbcommon=1"
1 parent 68fc666 commit c1eeced

11 files changed

+233
-206
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Alexis Menard <[email protected]>
22
Andriy Prystupa <[email protected]>
3+
Antonio Gomes <[email protected]>
34
Carlos Alberto Lopez Perez <[email protected]>
45
Changbin Shao <[email protected]>
56
Daniel Narvaez <[email protected]>

ozone_impl.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'dependencies': [
1515
'<(DEPTH)/skia/skia.gyp:skia',
1616
'<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
17+
'<(DEPTH)/ui/events/ozone/events_ozone.gyp:events_ozone_evdev',
1718
'<(DEPTH)/ui/gfx/ipc/gfx_ipc.gyp:gfx_ipc',
1819
'wayland/wayland.gyp:wayland_toolkit'
1920
],
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
From dba08e4e0dee6dfbb30ed30ffcf36f12646dfa4e Mon Sep 17 00:00:00 2001
2+
From: Antonio Gomes <[email protected]>
3+
Date: Sat, 11 Jun 2016 10:30:30 -0400
4+
Subject: [PATCH] Adapt DesktopFactoryOzone to respect --ozone-platform
5+
parameter.
6+
7+
Patch removes SetInstance method from DesktopFactoryOzone and
8+
as well as ::GetNativeTheme implementation.
9+
10+
The former is not necessary given that DesktopFactoryOzone::GetInstance
11+
instantiate the proper DesktopFactoryOzone now, either according
12+
to --ozone-platform={platform_name} or to a default platform name.
13+
---
14+
.../widget/desktop_aura/desktop_factory_ozone.cc | 20 ++++++++++++++------
15+
ui/views/widget/desktop_aura/desktop_factory_ozone.h | 3 ---
16+
.../desktop_aura/desktop_window_tree_host_ozone.cc | 5 -----
17+
3 files changed, 14 insertions(+), 14 deletions(-)
18+
19+
diff --git a/ui/views/widget/desktop_aura/desktop_factory_ozone.cc b/ui/views/widget/desktop_aura/desktop_factory_ozone.cc
20+
index e0a4489..d39aecd 100644
21+
--- a/ui/views/widget/desktop_aura/desktop_factory_ozone.cc
22+
+++ b/ui/views/widget/desktop_aura/desktop_factory_ozone.cc
23+
@@ -5,25 +5,33 @@
24+
#include "ui/views/widget/desktop_aura/desktop_factory_ozone.h"
25+
26+
#include "base/logging.h"
27+
+#include "ui/ozone/platform_object.h"
28+
29+
namespace views {
30+
31+
// static
32+
-DesktopFactoryOzone* DesktopFactoryOzone::impl_ = NULL;
33+
+DesktopFactoryOzone* DesktopFactoryOzone::impl_ = nullptr;
34+
35+
DesktopFactoryOzone::DesktopFactoryOzone() {
36+
+ DCHECK(!impl_) << "There should only be a single DesktopFactoryOzone.";
37+
+ impl_ = this;
38+
}
39+
40+
DesktopFactoryOzone::~DesktopFactoryOzone() {
41+
+ DCHECK_EQ(impl_, this);
42+
+ impl_ = nullptr;
43+
}
44+
45+
DesktopFactoryOzone* DesktopFactoryOzone::GetInstance() {
46+
- CHECK(impl_) << "DesktopFactoryOzone accessed before constructed";
47+
+ if (!impl_) {
48+
+ scoped_ptr<DesktopFactoryOzone> factory =
49+
+ ui::PlatformObject<DesktopFactoryOzone>::Create();
50+
+
51+
+ // TODO(tonikitoo): Currently need to leak this object.
52+
+ DesktopFactoryOzone* leaky = factory.release();
53+
+ DCHECK_EQ(impl_, leaky);
54+
+ }
55+
return impl_;
56+
}
57+
58+
-void DesktopFactoryOzone::SetInstance(DesktopFactoryOzone* impl) {
59+
- impl_ = impl;
60+
-}
61+
-
62+
} // namespace views
63+
diff --git a/ui/views/widget/desktop_aura/desktop_factory_ozone.h b/ui/views/widget/desktop_aura/desktop_factory_ozone.h
64+
index 2af191b..8e45864 100644
65+
--- a/ui/views/widget/desktop_aura/desktop_factory_ozone.h
66+
+++ b/ui/views/widget/desktop_aura/desktop_factory_ozone.h
67+
@@ -28,9 +28,6 @@ class VIEWS_EXPORT DesktopFactoryOzone {
68+
// Returns the instance.
69+
static DesktopFactoryOzone* GetInstance();
70+
71+
- // Sets the implementation delegate. Ownership is retained by the caller.
72+
- static void SetInstance(DesktopFactoryOzone* impl);
73+
-
74+
// Delegates implementation of DesktopWindowTreeHost::Create externally to
75+
// Ozone implementation.
76+
virtual DesktopWindowTreeHost* CreateWindowTreeHost(
77+
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_ozone.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_ozone.cc
78+
index e67af41..a83f53d 100644
79+
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_ozone.cc
80+
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_ozone.cc
81+
@@ -18,9 +18,4 @@ DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
82+
desktop_native_widget_aura);
83+
}
84+
85+
-// static
86+
-ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) {
87+
- return ui::NativeThemeAura::instance();
88+
-}
89+
-
90+
} // namespace views
91+
--
92+
2.7.4
93+

patches/0002-Remove-usage-of-DesktopFactory.patch

Lines changed: 0 additions & 195 deletions
This file was deleted.

supplement.gypi

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
{
77
'variables': {
88
'ozone_platform_wayland%': 1,
9+
'platform_list_txt_file': '<(SHARED_INTERMEDIATE_DIR)/ui/ozone/platform_list.txt',
10+
'desktop_factory_ozone_list_cc_file': '<(INTERMEDIATE_DIR)/ui/views/desktop_factory_ozone_list.cc',
911
},
1012
'conditions': [
1113
['<(ozone_platform_wayland) == 1', {
@@ -16,13 +18,18 @@
1618
'external_ozone_views_files': [
1719
'<(DEPTH)/ozone/ui/desktop_aura/desktop_drag_drop_client_wayland.cc',
1820
'<(DEPTH)/ozone/ui/desktop_aura/desktop_drag_drop_client_wayland.h',
21+
'<(DEPTH)/ozone/ui/desktop_aura/desktop_factory_ozone_stubs.cc',
22+
'<(DEPTH)/ozone/ui/desktop_aura/desktop_factory_ozone_stubs.h',
23+
'<(DEPTH)/ozone/ui/desktop_aura/desktop_factory_ozone_wayland.cc',
24+
'<(DEPTH)/ozone/ui/desktop_aura/desktop_factory_ozone_wayland.h',
1925
'<(DEPTH)/ozone/ui/desktop_aura/desktop_platform_screen.h',
2026
'<(DEPTH)/ozone/ui/desktop_aura/desktop_screen_wayland.cc',
2127
'<(DEPTH)/ozone/ui/desktop_aura/desktop_screen_wayland.h',
2228
'<(DEPTH)/ozone/ui/desktop_aura/desktop_window_tree_host_ozone.cc',
2329
'<(DEPTH)/ozone/ui/desktop_aura/desktop_window_tree_host_ozone.h',
2430
'<(DEPTH)/ozone/ui/desktop_aura/ozone_util.cc',
2531
'<(DEPTH)/ozone/ui/desktop_aura/ozone_util.h',
32+
'<(desktop_factory_ozone_list_cc_file)',
2633
],
2734
'external_ozone_platforms': [
2835
'wayland'
@@ -31,4 +38,34 @@
3138
},
3239
}],
3340
],
41+
'target_defaults': {
42+
'target_conditions': [
43+
['_target_name=="views"', {
44+
'actions': [
45+
{
46+
'action_name': 'generate_constructor_list',
47+
'variables': {
48+
'generator_path': '<(DEPTH)/ui/ozone/generate_constructor_list.py',
49+
},
50+
'inputs': [
51+
'<(generator_path)',
52+
'<(platform_list_txt_file)',
53+
],
54+
'outputs': [
55+
'<(desktop_factory_ozone_list_cc_file)',
56+
],
57+
'action': [
58+
'python',
59+
'<(generator_path)',
60+
'--platform_list=<(platform_list_txt_file)',
61+
'--output_cc=<(desktop_factory_ozone_list_cc_file)',
62+
'--namespace=views',
63+
'--typename=DesktopFactoryOzone',
64+
'--include="ui/views/widget/desktop_aura/desktop_factory_ozone.h"',
65+
],
66+
},
67+
],
68+
}],
69+
],
70+
},
3471
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "ozone/ui/desktop_aura/desktop_factory_ozone_stubs.h"
6+
7+
namespace views {
8+
9+
DesktopFactoryOzone* CreateDesktopFactoryOzoneHeadless() {
10+
return nullptr;
11+
}
12+
13+
DesktopFactoryOzone* CreateDesktopFactoryOzoneEgltest() {
14+
return nullptr;
15+
}
16+
17+
} // namespace views

0 commit comments

Comments
 (0)