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

Side by Side Diff: chrome/browser/extensions/display_info_provider_chromeos.cc

Issue 2638903003: Updates touch calibration API and plumbs through the native touch calibration method (Closed)
Patch Set: Resolving Comments Created 3 years, 11 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 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 #include "chrome/browser/extensions/display_info_provider_chromeos.h" 5 #include "chrome/browser/extensions/display_info_provider_chromeos.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "ash/display/display_configuration_controller.h" 9 #include "ash/display/display_configuration_controller.h"
10 #include "ash/display/resolution_notification_controller.h" 10 #include "ash/display/resolution_notification_controller.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/touch/ash_touch_transform_controller.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "chrome/browser/chromeos/display/display_preferences.h" 14 #include "chrome/browser/chromeos/display/display_preferences.h"
14 #include "chrome/browser/chromeos/display/overscan_calibrator.h" 15 #include "chrome/browser/chromeos/display/overscan_calibrator.h"
15 #include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_cont roller.h" 16 #include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_cont roller.h"
16 #include "extensions/common/api/system_display.h" 17 #include "extensions/common/api/system_display.h"
17 #include "ui/display/display.h" 18 #include "ui/display/display.h"
18 #include "ui/display/display_layout.h" 19 #include "ui/display/display_layout.h"
19 #include "ui/display/display_layout_builder.h" 20 #include "ui/display/display_layout_builder.h"
20 #include "ui/display/manager/display_manager.h" 21 #include "ui/display/manager/display_manager.h"
21 #include "ui/display/types/display_constants.h" 22 #include "ui/display/types/display_constants.h"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 const std::string& id) { 654 const std::string& id) {
654 VLOG(1) << "OverscanCalibrationComplete: " << id; 655 VLOG(1) << "OverscanCalibrationComplete: " << id;
655 chromeos::OverscanCalibrator* calibrator = GetOverscanCalibrator(id); 656 chromeos::OverscanCalibrator* calibrator = GetOverscanCalibrator(id);
656 if (!calibrator) 657 if (!calibrator)
657 return false; 658 return false;
658 calibrator->Commit(); 659 calibrator->Commit();
659 overscan_calibrators_[id].reset(); 660 overscan_calibrators_[id].reset();
660 return true; 661 return true;
661 } 662 }
662 663
663 bool DisplayInfoProviderChromeOS::TouchCalibrationSet( 664 bool DisplayInfoProviderChromeOS::ShowNativeTouchCalibration(
664 const std::string& id, 665 const std::string& id, std::string* error,
665 const api::system_display::TouchCalibrationPairQuad& pairs, 666 const DisplayInfoProvider::TouchCalibrationCallback& callback) {
666 const api::system_display::Bounds& bounds, 667 VLOG(1) << "StartNativeTouchCalibration: " << id;
667 std::string* error) { 668
668 VLOG(1) << "TouchCalibrationSet: " << id; 669 if (custom_touch_calibration_active_) {
670 *error = "Please complete the custom touch calibration that is under "
671 "progress for id - " + touch_calibration_target_id_ + " before "
672 "calling this method.";
stevenjb 2017/01/19 17:19:01 Declare string constants at top of file. Also, un
malaykeshav 2017/01/19 23:49:06 Reducing string length and moving to top of file.
673 return false;
674 }
669 675
670 const display::Display display = GetDisplay(id); 676 const display::Display display = GetDisplay(id);
671 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), 677 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(),
672 error)) { 678 error)) {
673 return false; 679 return false;
674 } 680 }
675 681
682 GetTouchCalibrator()->StartCalibration(display, callback);
683 return true;
684 }
685
686 bool DisplayInfoProviderChromeOS::StartCustomTouchCalibration(
687 const std::string& id,
688 std::string* error) {
689 VLOG(1) << "StartCustomTouchCalibration: " << id;
690 const display::Display display = GetDisplay(id);
691 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(),
692 error)) {
693 return false;
694 }
695
696 touch_calibration_target_id_ = id;
697 custom_touch_calibration_active_ = true;
698
699 // Enable un-transformed touch input.
700 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration(
701 true);
702 return true;
703 }
704
705 bool DisplayInfoProviderChromeOS::CompleteCustomTouchCalibration(
706 const api::system_display::TouchCalibrationPairQuad& pairs,
707 const api::system_display::Bounds& bounds,
708 std::string* error) {
709 VLOG(1) << "CompleteCustomTouchCalibration: " << touch_calibration_target_id_;
710
711 ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration(
712 false);
713
714 const display::Display display = GetDisplay(touch_calibration_target_id_);
715 touch_calibration_target_id_ = "";
stevenjb 2017/01/19 17:19:01 nit: touch_calibration_target_id_.clear()
malaykeshav 2017/01/19 23:49:06 Done
716
717 if (!custom_touch_calibration_active_) {
718 *error = "Please call system.display.startCustomTouchCalibration before "
719 "calling this method.";
stevenjb 2017/01/19 17:19:01 Declare string constants at top of file and sumpli
malaykeshav 2017/01/19 23:49:07 Done
720 return false;
721 }
722
723 custom_touch_calibration_active_ = false;
724
725 if (!ValidateParamsForTouchCalibration(
726 touch_calibration_target_id_, display, GetTouchCalibrator(), error)) {
727 return false;
728 }
729
676 display::TouchCalibrationData::CalibrationPointPairQuad calibration_points; 730 display::TouchCalibrationData::CalibrationPointPairQuad calibration_points;
677 calibration_points[0] = GetCalibrationPair(pairs.pair1); 731 calibration_points[0] = GetCalibrationPair(pairs.pair1);
678 calibration_points[1] = GetCalibrationPair(pairs.pair2); 732 calibration_points[1] = GetCalibrationPair(pairs.pair2);
679 calibration_points[2] = GetCalibrationPair(pairs.pair3); 733 calibration_points[2] = GetCalibrationPair(pairs.pair3);
680 calibration_points[3] = GetCalibrationPair(pairs.pair4); 734 calibration_points[3] = GetCalibrationPair(pairs.pair4);
681 735
682 // The display bounds cannot have negative values. 736 // The display bounds cannot have negative values.
683 if (bounds.width < 0 || bounds.height < 0) { 737 if (bounds.width < 0 || bounds.height < 0) {
684 *error = "Bounds cannot have negative values."; 738 *error = "Bounds cannot have negative values.";
685 return false; 739 return false;
(...skipping 17 matching lines...) Expand all
703 return false; 757 return false;
704 } 758 }
705 } 759 }
706 760
707 gfx::Size display_size(bounds.width, bounds.height); 761 gfx::Size display_size(bounds.width, bounds.height);
708 ash::Shell::GetInstance()->display_manager()->SetTouchCalibrationData( 762 ash::Shell::GetInstance()->display_manager()->SetTouchCalibrationData(
709 display.id(), calibration_points, display_size); 763 display.id(), calibration_points, display_size);
710 return true; 764 return true;
711 } 765 }
712 766
713 bool DisplayInfoProviderChromeOS::TouchCalibrationReset(const std::string& id, 767 bool DisplayInfoProviderChromeOS::ResetTouchCalibration(const std::string& id,
714 std::string* error) { 768 std::string* error) {
715 const display::Display display = GetDisplay(id); 769 const display::Display display = GetDisplay(id);
716 770
717 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), 771 if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(),
718 error)) { 772 error)) {
719 return false; 773 return false;
720 } 774 }
721 775
722 ash::Shell::GetInstance()->display_manager()->ClearTouchCalibrationData( 776 ash::Shell::GetInstance()->display_manager()->ClearTouchCalibrationData(
723 display.id()); 777 display.id());
724 return true; 778 return true;
725 } 779 }
726 780
727 bool DisplayInfoProviderChromeOS::IsTouchCalibrationActive(std::string* error) { 781 bool DisplayInfoProviderChromeOS::IsNativeTouchCalibrationActive(
782 std::string* error) {
728 if (GetTouchCalibrator()->is_calibrating()) { 783 if (GetTouchCalibrator()->is_calibrating()) {
729 *error = "Another touch calibration is already active."; 784 *error = "Another touch calibration is already active.";
730 return true; 785 return true;
731 } 786 }
732 return false; 787 return false;
733 } 788 }
734 789
735 chromeos::OverscanCalibrator* 790 chromeos::OverscanCalibrator*
736 DisplayInfoProviderChromeOS::GetOverscanCalibrator(const std::string& id) { 791 DisplayInfoProviderChromeOS::GetOverscanCalibrator(const std::string& id) {
737 auto iter = overscan_calibrators_.find(id); 792 auto iter = overscan_calibrators_.find(id);
738 if (iter == overscan_calibrators_.end()) 793 if (iter == overscan_calibrators_.end())
739 return nullptr; 794 return nullptr;
740 return iter->second.get(); 795 return iter->second.get();
741 } 796 }
742 797
743 chromeos::TouchCalibratorController* 798 chromeos::TouchCalibratorController*
744 DisplayInfoProviderChromeOS::GetTouchCalibrator() { 799 DisplayInfoProviderChromeOS::GetTouchCalibrator() {
745 if (!touch_calibrator_) 800 if (!touch_calibrator_)
746 touch_calibrator_.reset(new chromeos::TouchCalibratorController); 801 touch_calibrator_.reset(new chromeos::TouchCalibratorController);
747 return touch_calibrator_.get(); 802 return touch_calibrator_.get();
748 } 803 }
749 804
750 // static 805 // static
751 DisplayInfoProvider* DisplayInfoProvider::Create() { 806 DisplayInfoProvider* DisplayInfoProvider::Create() {
752 return new DisplayInfoProviderChromeOS(); 807 return new DisplayInfoProviderChromeOS();
753 } 808 }
754 809
755 } // namespace extensions 810 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698