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

Side by Side Diff: chromeos/display/output_configurator.h

Issue 191223007: Move touch CTM from X into Chrome (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: move CTM update code into a separate file ash/touch/touch_ctm_controller.cc Created 6 years, 9 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 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 5 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 ModeInfo(int width, int height, bool interlaced, float refresh_rate); 43 ModeInfo(int width, int height, bool interlaced, float refresh_rate);
44 44
45 int width; 45 int width;
46 int height; 46 int height;
47 bool interlaced; 47 bool interlaced;
48 float refresh_rate; 48 float refresh_rate;
49 }; 49 };
50 50
51 typedef std::map<RRMode, ModeInfo> ModeInfoMap; 51 typedef std::map<RRMode, ModeInfo> ModeInfoMap;
52 52
53 struct CoordinateTransformation {
54 // Initialized to the identity transformation.
55 CoordinateTransformation();
56
57 float x_scale;
58 float x_offset;
59 float y_scale;
60 float y_offset;
61 };
62
63 // Information about an output's current state. 53 // Information about an output's current state.
64 struct OutputSnapshot { 54 struct OutputSnapshot {
65 OutputSnapshot(); 55 OutputSnapshot();
66 ~OutputSnapshot(); 56 ~OutputSnapshot();
67 57
68 RROutput output; 58 RROutput output;
69 59
70 // CRTC that should be used for this output. Not necessarily the CRTC 60 // CRTC that should be used for this output. Not necessarily the CRTC
71 // that XRandR reports is currently being used. 61 // that XRandR reports is currently being used.
72 RRCrtc crtc; 62 RRCrtc crtc;
(...skipping 22 matching lines...) Expand all
95 85
96 // The type of output. 86 // The type of output.
97 ui::OutputType type; 87 ui::OutputType type;
98 88
99 // Map from mode IDs to details about the corresponding modes. 89 // Map from mode IDs to details about the corresponding modes.
100 ModeInfoMap mode_infos; 90 ModeInfoMap mode_infos;
101 91
102 // XInput device ID or 0 if this output isn't a touchscreen. 92 // XInput device ID or 0 if this output isn't a touchscreen.
103 int touch_device_id; 93 int touch_device_id;
104 94
105 CoordinateTransformation transform;
106
107 // Display id for this output. 95 // Display id for this output.
108 int64 display_id; 96 int64 display_id;
109 97
110 bool has_display_id; 98 bool has_display_id;
111 99
112 // This output's index in the array returned by XRandR. Stable even as 100 // This output's index in the array returned by XRandR. Stable even as
113 // outputs are connected or disconnected. 101 // outputs are connected or disconnected.
114 int index; 102 int index;
115 }; 103 };
116 104
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 public: 148 public:
161 virtual ~TouchscreenDelegate() {} 149 virtual ~TouchscreenDelegate() {}
162 150
163 // Searches for touchscreens among input devices, 151 // Searches for touchscreens among input devices,
164 // and tries to match them up to screens in |outputs|. 152 // and tries to match them up to screens in |outputs|.
165 // |outputs| is an array of detected screens. 153 // |outputs| is an array of detected screens.
166 // If a touchscreen with same resolution as an output's native mode 154 // If a touchscreen with same resolution as an output's native mode
167 // is detected, its id will be stored in this output. 155 // is detected, its id will be stored in this output.
168 virtual void AssociateTouchscreens( 156 virtual void AssociateTouchscreens(
169 std::vector<OutputSnapshot>* outputs) = 0; 157 std::vector<OutputSnapshot>* outputs) = 0;
170
171 // Configures XInput's Coordinate Transformation Matrix property.
172 // |touch_device_id| the ID of the touchscreen device to configure.
173 // |ctm| contains the desired transformation parameters. The offsets
174 // in it should be normalized so that 1 corresponds to the X or Y axis
175 // size for the corresponding offset.
176 virtual void ConfigureCTM(int touch_device_id,
177 const CoordinateTransformation& ctm) = 0;
178 }; 158 };
179 159
180 // Helper class used by tests. 160 // Helper class used by tests.
181 class TestApi { 161 class TestApi {
182 public: 162 public:
183 TestApi(OutputConfigurator* configurator) 163 TestApi(OutputConfigurator* configurator)
184 : configurator_(configurator) {} 164 : configurator_(configurator) {}
185 ~TestApi() {} 165 ~TestApi() {}
186 166
187 // If |configure_timer_| is started, stops the timer, runs 167 // If |configure_timer_| is started, stops the timer, runs
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Returns the mode within |output| that matches the given size with highest 199 // Returns the mode within |output| that matches the given size with highest
220 // refresh rate. Returns None if no matching output was found. 200 // refresh rate. Returns None if no matching output was found.
221 static RRMode FindOutputModeMatchingSize(const OutputSnapshot& output, 201 static RRMode FindOutputModeMatchingSize(const OutputSnapshot& output,
222 int width, 202 int width,
223 int height); 203 int height);
224 204
225 OutputConfigurator(); 205 OutputConfigurator();
226 virtual ~OutputConfigurator(); 206 virtual ~OutputConfigurator();
227 207
228 ui::OutputState output_state() const { return output_state_; } 208 ui::OutputState output_state() const { return output_state_; }
209 // This setter is only for testing.
210 void set_output_state(ui::OutputState new_state) {
211 output_state_ = new_state;
212 }
213
229 DisplayPowerState power_state() const { return power_state_; } 214 DisplayPowerState power_state() const { return power_state_; }
230 const std::vector<OutputSnapshot>& cached_outputs() const { 215 const std::vector<OutputSnapshot>& cached_outputs() const {
231 return cached_outputs_; 216 return cached_outputs_;
232 } 217 }
233 218
234 void set_state_controller(StateController* controller) { 219 void set_state_controller(StateController* controller) {
235 state_controller_ = controller; 220 state_controller_ = controller;
236 } 221 }
237 void set_mirroring_controller(SoftwareMirroringController* controller) { 222 void set_mirroring_controller(SoftwareMirroringController* controller) {
238 mirroring_controller_ = controller; 223 mirroring_controller_ = controller;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 350
366 // Switches to the state specified in |output_state| and |power_state|. 351 // Switches to the state specified in |output_state| and |power_state|.
367 // On success, updates |output_state_|, |power_state_|, and 352 // On success, updates |output_state_|, |power_state_|, and
368 // |cached_outputs_| and returns true. 353 // |cached_outputs_| and returns true.
369 bool EnterState(ui::OutputState output_state, DisplayPowerState power_state); 354 bool EnterState(ui::OutputState output_state, DisplayPowerState power_state);
370 355
371 // Returns the output state that should be used with |cached_outputs_| while 356 // Returns the output state that should be used with |cached_outputs_| while
372 // in |power_state|. 357 // in |power_state|.
373 ui::OutputState ChooseOutputState(DisplayPowerState power_state) const; 358 ui::OutputState ChooseOutputState(DisplayPowerState power_state) const;
374 359
375 // Computes the relevant transformation for mirror mode.
376 // |output| is the output on which mirror mode is being applied.
377 // Returns the transformation or identity if computations fail.
378 CoordinateTransformation GetMirrorModeCTM(
379 const OutputConfigurator::OutputSnapshot& output);
380
381 // Computes the relevant transformation for extended mode.
382 // |output| is the output on which extended mode is being applied.
383 // |width| and |height| are the width and height of the combined framebuffer.
384 // Returns the transformation or identity if computations fail.
385 CoordinateTransformation GetExtendedModeCTM(
386 const OutputConfigurator::OutputSnapshot& output,
387 int framebuffer_width,
388 int frame_buffer_height);
389
390 // Returns the ratio between mirrored mode area and native mode area: 360 // Returns the ratio between mirrored mode area and native mode area:
391 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height) 361 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height)
392 float GetMirroredDisplayAreaRatio( 362 float GetMirroredDisplayAreaRatio(
393 const OutputConfigurator::OutputSnapshot& output); 363 const OutputConfigurator::OutputSnapshot& output);
394 364
395 // Applies output protections according to requests. 365 // Applies output protections according to requests.
396 bool ApplyProtections(const DisplayProtections& requests); 366 bool ApplyProtections(const DisplayProtections& requests);
397 367
398 StateController* state_controller_; 368 StateController* state_controller_;
399 SoftwareMirroringController* mirroring_controller_; 369 SoftwareMirroringController* mirroring_controller_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 ProtectionRequests client_protection_requests_; 411 ProtectionRequests client_protection_requests_;
442 412
443 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); 413 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator);
444 }; 414 };
445 415
446 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; 416 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList;
447 417
448 } // namespace chromeos 418 } // namespace chromeos
449 419
450 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 420 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698