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

Side by Side Diff: ui/display/chromeos/display_configurator.h

Issue 280833002: Re-land "Issue 191223007: Move touch CTM from X into Chrome" (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: adding missing file again Created 6 years, 7 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 | « ui/aura/window_tree_host_x11.cc ('k') | ui/display/chromeos/display_configurator.cc » ('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 #ifndef UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ 5 #ifndef UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
6 #define UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ 6 #define UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/event_types.h" 14 #include "base/event_types.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
19 #include "ui/display/display_export.h" 19 #include "ui/display/display_export.h"
20 #include "ui/display/types/chromeos/native_display_observer.h" 20 #include "ui/display/types/chromeos/native_display_observer.h"
21 #include "ui/display/types/display_constants.h" 21 #include "ui/display/types/display_constants.h"
22 #include "ui/gfx/geometry/size.h"
22 23
23 namespace gfx { 24 namespace gfx {
24 class Point; 25 class Point;
25 class Size; 26 class Size;
26 } 27 }
27 28
28 namespace ui { 29 namespace ui {
29 class DisplayMode; 30 class DisplayMode;
30 class DisplaySnapshot; 31 class DisplaySnapshot;
31 class NativeDisplayDelegate; 32 class NativeDisplayDelegate;
32 33
33 // This class interacts directly with the system display configurator. 34 // This class interacts directly with the system display configurator.
34 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { 35 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
35 public: 36 public:
36 typedef uint64_t ContentProtectionClientId; 37 typedef uint64_t ContentProtectionClientId;
37 static const ContentProtectionClientId kInvalidClientId = 0; 38 static const ContentProtectionClientId kInvalidClientId = 0;
38 39
39 struct CoordinateTransformation {
40 // Initialized to the identity transformation.
41 CoordinateTransformation();
42
43 float x_scale;
44 float x_offset;
45 float y_scale;
46 float y_offset;
47 };
48
49 struct DisplayState { 40 struct DisplayState {
50 DisplayState(); 41 DisplayState();
51 42
52 DisplaySnapshot* display; // Not owned. 43 DisplaySnapshot* display; // Not owned.
53 44
54 // XInput device ID or 0 if this display isn't a touchscreen. 45 // XInput device ID or 0 if this display isn't a touchscreen.
55 int touch_device_id; 46 int touch_device_id;
56 47
57 CoordinateTransformation transform;
58
59 // User-selected mode for the display. 48 // User-selected mode for the display.
60 const DisplayMode* selected_mode; 49 const DisplayMode* selected_mode;
61 50
62 // Mode used when displaying the same desktop on multiple displays. 51 // Mode used when displaying the same desktop on multiple displays.
63 const DisplayMode* mirror_mode; 52 const DisplayMode* mirror_mode;
64 }; 53 };
65 54
66 typedef std::vector<DisplayState> DisplayStateList; 55 typedef std::vector<DisplayState> DisplayStateList;
67 56
68 class Observer { 57 class Observer {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 class TouchscreenDelegate { 99 class TouchscreenDelegate {
111 public: 100 public:
112 virtual ~TouchscreenDelegate() {} 101 virtual ~TouchscreenDelegate() {}
113 102
114 // Searches for touchscreens among input devices, 103 // Searches for touchscreens among input devices,
115 // and tries to match them up to screens in |displays|. 104 // and tries to match them up to screens in |displays|.
116 // |displays| is an array of detected screens. 105 // |displays| is an array of detected screens.
117 // If a touchscreen with same resolution as a display's native mode 106 // If a touchscreen with same resolution as a display's native mode
118 // is detected, its id will be stored in this display. 107 // is detected, its id will be stored in this display.
119 virtual void AssociateTouchscreens(std::vector<DisplayState>* displays) = 0; 108 virtual void AssociateTouchscreens(std::vector<DisplayState>* displays) = 0;
120
121 // Configures XInput's Coordinate Transformation Matrix property.
122 // |touch_device_id| the ID of the touchscreen device to configure.
123 // |ctm| contains the desired transformation parameters. The offsets
124 // in it should be normalized so that 1 corresponds to the X or Y axis
125 // size for the corresponding offset.
126 virtual void ConfigureCTM(int touch_device_id,
127 const CoordinateTransformation& ctm) = 0;
128 }; 109 };
129 110
130 // Helper class used by tests. 111 // Helper class used by tests.
131 class TestApi { 112 class TestApi {
132 public: 113 public:
133 TestApi(DisplayConfigurator* configurator) : configurator_(configurator) {} 114 TestApi(DisplayConfigurator* configurator) : configurator_(configurator) {}
134 ~TestApi() {} 115 ~TestApi() {}
135 116
136 // If |configure_timer_| is started, stops the timer, runs 117 // If |configure_timer_| is started, stops the timer, runs
137 // ConfigureDisplays(), and returns true; returns false otherwise. 118 // ConfigureDisplays(), and returns true; returns false otherwise.
(...skipping 26 matching lines...) Expand all
164 // refresh rate. Returns None if no matching display was found. 145 // refresh rate. Returns None if no matching display was found.
165 static const DisplayMode* FindDisplayModeMatchingSize( 146 static const DisplayMode* FindDisplayModeMatchingSize(
166 const DisplaySnapshot& display, 147 const DisplaySnapshot& display,
167 const gfx::Size& size); 148 const gfx::Size& size);
168 149
169 DisplayConfigurator(); 150 DisplayConfigurator();
170 virtual ~DisplayConfigurator(); 151 virtual ~DisplayConfigurator();
171 152
172 MultipleDisplayState display_state() const { return display_state_; } 153 MultipleDisplayState display_state() const { return display_state_; }
173 chromeos::DisplayPowerState power_state() const { return power_state_; } 154 chromeos::DisplayPowerState power_state() const { return power_state_; }
155 const gfx::Size framebuffer_size() const { return framebuffer_size_; }
174 const std::vector<DisplayState>& cached_displays() const { 156 const std::vector<DisplayState>& cached_displays() const {
175 return cached_displays_; 157 return cached_displays_;
176 } 158 }
177 159
178 void set_state_controller(StateController* controller) { 160 void set_state_controller(StateController* controller) {
179 state_controller_ = controller; 161 state_controller_ = controller;
180 } 162 }
181 void set_mirroring_controller(SoftwareMirroringController* controller) { 163 void set_mirroring_controller(SoftwareMirroringController* controller) {
182 mirroring_controller_ = controller; 164 mirroring_controller_ = controller;
183 } 165 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // On success, updates |display_state_|, |power_state_|, and 310 // On success, updates |display_state_|, |power_state_|, and
329 // |cached_displays_| and returns true. 311 // |cached_displays_| and returns true.
330 bool EnterState(MultipleDisplayState display_state, 312 bool EnterState(MultipleDisplayState display_state,
331 chromeos::DisplayPowerState power_state); 313 chromeos::DisplayPowerState power_state);
332 314
333 // Returns the display state that should be used with |cached_displays_| while 315 // Returns the display state that should be used with |cached_displays_| while
334 // in |power_state|. 316 // in |power_state|.
335 MultipleDisplayState ChooseDisplayState( 317 MultipleDisplayState ChooseDisplayState(
336 chromeos::DisplayPowerState power_state) const; 318 chromeos::DisplayPowerState power_state) const;
337 319
338 // Computes the relevant transformation for mirror mode.
339 // |display| is the display on which mirror mode is being applied.
340 // Returns the transformation or identity if computations fail.
341 CoordinateTransformation GetMirrorModeCTM(const DisplayState& display);
342
343 // Computes the relevant transformation for extended mode. |display| is the
344 // display on which extended mode is being applied. |new_origin| is the
345 // position of the display on the framebuffer. |framebuffer_size| is the
346 // size of the combined framebuffer.
347 // Returns the transformation or identity if computations fail.
348 CoordinateTransformation GetExtendedModeCTM(
349 const DisplayState& display,
350 const gfx::Point& new_origin,
351 const gfx::Size& framebuffer_size);
352
353 // Returns the ratio between mirrored mode area and native mode area: 320 // Returns the ratio between mirrored mode area and native mode area:
354 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height) 321 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height)
355 float GetMirroredDisplayAreaRatio(const DisplayState& display); 322 float GetMirroredDisplayAreaRatio(const DisplayState& display);
356 323
357 // Applies display protections according to requests. 324 // Applies display protections according to requests.
358 bool ApplyProtections(const ContentProtections& requests); 325 bool ApplyProtections(const ContentProtections& requests);
359 326
360 StateController* state_controller_; 327 StateController* state_controller_;
361 SoftwareMirroringController* mirroring_controller_; 328 SoftwareMirroringController* mirroring_controller_;
362 scoped_ptr<NativeDisplayDelegate> native_display_delegate_; 329 scoped_ptr<NativeDisplayDelegate> native_display_delegate_;
(...skipping 13 matching lines...) Expand all
376 // This is detected by the constructor to determine whether or not we should 343 // This is detected by the constructor to determine whether or not we should
377 // be enabled. If we aren't running on ChromeOS, we can't assume that the 344 // be enabled. If we aren't running on ChromeOS, we can't assume that the
378 // Xrandr X11 extension is supported. 345 // Xrandr X11 extension is supported.
379 // If this flag is set to false, any attempts to change the display 346 // If this flag is set to false, any attempts to change the display
380 // configuration to immediately fail without changing the state. 347 // configuration to immediately fail without changing the state.
381 bool configure_display_; 348 bool configure_display_;
382 349
383 // The current display state. 350 // The current display state.
384 MultipleDisplayState display_state_; 351 MultipleDisplayState display_state_;
385 352
353 gfx::Size framebuffer_size_;
354
386 // The current power state. 355 // The current power state.
387 chromeos::DisplayPowerState power_state_; 356 chromeos::DisplayPowerState power_state_;
388 357
389 // Most-recently-used display configuration. Note that the actual 358 // Most-recently-used display configuration. Note that the actual
390 // configuration changes asynchronously. 359 // configuration changes asynchronously.
391 DisplayStateList cached_displays_; 360 DisplayStateList cached_displays_;
392 361
393 ObserverList<Observer> observers_; 362 ObserverList<Observer> observers_;
394 363
395 // The timer to delay configuring displays. See also the comments in 364 // The timer to delay configuring displays. See also the comments in
396 // Dispatch(). 365 // Dispatch().
397 scoped_ptr<base::OneShotTimer<DisplayConfigurator> > configure_timer_; 366 scoped_ptr<base::OneShotTimer<DisplayConfigurator> > configure_timer_;
398 367
399 // Id for next display protection client. 368 // Id for next display protection client.
400 ContentProtectionClientId next_display_protection_client_id_; 369 ContentProtectionClientId next_display_protection_client_id_;
401 370
402 // Display protection requests of each client. 371 // Display protection requests of each client.
403 ProtectionRequests client_protection_requests_; 372 ProtectionRequests client_protection_requests_;
404 373
405 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); 374 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator);
406 }; 375 };
407 376
408 } // namespace ui 377 } // namespace ui
409 378
410 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ 379 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host_x11.cc ('k') | ui/display/chromeos/display_configurator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698