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

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: add file ui/aura/touch_ctm.h(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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 public: 210 public:
223 virtual ~TouchscreenDelegate() {} 211 virtual ~TouchscreenDelegate() {}
224 212
225 // Searches for touchscreens among input devices, 213 // Searches for touchscreens among input devices,
226 // and tries to match them up to screens in |outputs|. 214 // and tries to match them up to screens in |outputs|.
227 // |outputs| is an array of detected screens. 215 // |outputs| is an array of detected screens.
228 // If a touchscreen with same resolution as an output's native mode 216 // If a touchscreen with same resolution as an output's native mode
229 // is detected, its id will be stored in this output. 217 // is detected, its id will be stored in this output.
230 virtual void AssociateTouchscreens( 218 virtual void AssociateTouchscreens(
231 std::vector<OutputSnapshot>* outputs) = 0; 219 std::vector<OutputSnapshot>* outputs) = 0;
232
233 // Configures XInput's Coordinate Transformation Matrix property.
234 // |touch_device_id| the ID of the touchscreen device to configure.
235 // |ctm| contains the desired transformation parameters. The offsets
236 // in it should be normalized so that 1 corresponds to the X or Y axis
237 // size for the corresponding offset.
238 virtual void ConfigureCTM(int touch_device_id,
239 const CoordinateTransformation& ctm) = 0;
240 }; 220 };
241 221
242 // Helper class used by tests. 222 // Helper class used by tests.
243 class TestApi { 223 class TestApi {
244 public: 224 public:
245 TestApi(OutputConfigurator* configurator, int xrandr_event_base) 225 TestApi(OutputConfigurator* configurator, int xrandr_event_base)
246 : configurator_(configurator), 226 : configurator_(configurator),
247 xrandr_event_base_(xrandr_event_base) {} 227 xrandr_event_base_(xrandr_event_base) {}
248 ~TestApi() {} 228 ~TestApi() {}
249 229
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // Returns the mode within |output| that matches the given size with highest 277 // Returns the mode within |output| that matches the given size with highest
298 // refresh rate. Returns None if no matching output was found. 278 // refresh rate. Returns None if no matching output was found.
299 static RRMode FindOutputModeMatchingSize(const OutputSnapshot& output, 279 static RRMode FindOutputModeMatchingSize(const OutputSnapshot& output,
300 int width, 280 int width,
301 int height); 281 int height);
302 282
303 OutputConfigurator(); 283 OutputConfigurator();
304 virtual ~OutputConfigurator(); 284 virtual ~OutputConfigurator();
305 285
306 ui::OutputState output_state() const { return output_state_; } 286 ui::OutputState output_state() const { return output_state_; }
287 // This setter is only for testing.
288 void set_output_state(ui::OutputState new_state) {
289 output_state_ = new_state;
290 }
291
307 DisplayPowerState power_state() const { return power_state_; } 292 DisplayPowerState power_state() const { return power_state_; }
308 293
309 void set_state_controller(StateController* controller) { 294 void set_state_controller(StateController* controller) {
310 state_controller_ = controller; 295 state_controller_ = controller;
311 } 296 }
312 void set_mirroring_controller(SoftwareMirroringController* controller) { 297 void set_mirroring_controller(SoftwareMirroringController* controller) {
313 mirroring_controller_ = controller; 298 mirroring_controller_ = controller;
314 } 299 }
315 300
316 // Replaces |native_display_delegate_| with |delegate| and sets 301 // Replaces |native_display_delegate_| with |delegate| and sets
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 438
454 // Switches to the state specified in |output_state| and |power_state|. 439 // Switches to the state specified in |output_state| and |power_state|.
455 // On success, updates |output_state_|, |power_state_|, and 440 // On success, updates |output_state_|, |power_state_|, and
456 // |cached_outputs_| and returns true. 441 // |cached_outputs_| and returns true.
457 bool EnterState(ui::OutputState output_state, DisplayPowerState power_state); 442 bool EnterState(ui::OutputState output_state, DisplayPowerState power_state);
458 443
459 // Returns the output state that should be used with |cached_outputs_| while 444 // Returns the output state that should be used with |cached_outputs_| while
460 // in |power_state|. 445 // in |power_state|.
461 ui::OutputState ChooseOutputState(DisplayPowerState power_state) const; 446 ui::OutputState ChooseOutputState(DisplayPowerState power_state) const;
462 447
463 // Computes the relevant transformation for mirror mode.
464 // |output| is the output on which mirror mode is being applied.
465 // Returns the transformation or identity if computations fail.
466 CoordinateTransformation GetMirrorModeCTM(
467 const OutputConfigurator::OutputSnapshot& output);
468
469 // Computes the relevant transformation for extended mode.
470 // |output| is the output on which extended mode is being applied.
471 // |width| and |height| are the width and height of the combined framebuffer.
472 // Returns the transformation or identity if computations fail.
473 CoordinateTransformation GetExtendedModeCTM(
474 const OutputConfigurator::OutputSnapshot& output,
475 int framebuffer_width,
476 int frame_buffer_height);
477
478 // Returns the ratio between mirrored mode area and native mode area: 448 // Returns the ratio between mirrored mode area and native mode area:
479 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height) 449 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height)
480 float GetMirroredDisplayAreaRatio( 450 float GetMirroredDisplayAreaRatio(
481 const OutputConfigurator::OutputSnapshot& output); 451 const OutputConfigurator::OutputSnapshot& output);
482 452
483 // Applies output protections according to requests. 453 // Applies output protections according to requests.
484 bool ApplyProtections(const DisplayProtections& requests); 454 bool ApplyProtections(const DisplayProtections& requests);
485 455
486 StateController* state_controller_; 456 StateController* state_controller_;
487 SoftwareMirroringController* mirroring_controller_; 457 SoftwareMirroringController* mirroring_controller_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 ProtectionRequests client_protection_requests_; 503 ProtectionRequests client_protection_requests_;
534 504
535 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); 505 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator);
536 }; 506 };
537 507
538 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; 508 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList;
539 509
540 } // namespace chromeos 510 } // namespace chromeos
541 511
542 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 512 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698