touch_action_region.h 1.5 KB

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