1 // Copyright 2017 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 #ifndef CC_LAYERS_TOUCH_ACTION_REGION_H_ 6 #define CC_LAYERS_TOUCH_ACTION_REGION_H_ 7 8 #include "base/containers/flat_map.h" 9 #include "cc/base/region.h" 10 #include "cc/cc_export.h" 11 #include "cc/input/touch_action.h" 12 13 namespace cc { 14 15 class Rect; 16 17 class CC_EXPORT TouchActionRegion { 18 public: 19 TouchActionRegion(); 20 TouchActionRegion(const TouchActionRegion& touch_action_region); 21 TouchActionRegion(TouchActionRegion&& touch_action_region); 22 ~TouchActionRegion(); 23 24 void Union(TouchAction, const gfx::Rect&); 25 // Return all regions with any touch action. 26 Region GetAllRegions() const; 27 const Region& GetRegionForTouchAction(TouchAction) const; 28 IsEmpty()29 bool IsEmpty() const { return map_.empty(); } 30 31 // Returns the touch actions that we are sure will be allowed at the point 32 // by finding the intersection of all touch actions whose regions contain the 33 // given point. If the map is empty, |TouchAction::kAuto| is returned since no 34 // touch actions have been explicitly defined and the default touch action 35 // is auto. 36 TouchAction GetAllowedTouchAction(const gfx::Point&) const; 37 TouchActionRegion& operator=(const TouchActionRegion& other); 38 TouchActionRegion& operator=(TouchActionRegion&& other); 39 bool operator==(const TouchActionRegion& other) const; 40 41 private: 42 base::flat_map<TouchAction, Region> map_; 43 }; 44 45 } // namespace cc 46 47 #endif // CC_LAYERS_TOUCH_ACTION_REGION_H_ 48