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

Side by Side Diff: ui/events/gesture_detection/bitset_32.h

Issue 586553002: Allow repeated handler removal/addition with the TouchEventQueue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ 5 #ifndef UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_
6 #define UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ 6 #define UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/logging.h"
9 10
10 namespace ui { 11 namespace ui {
11 12
12 // Port of BitSet32 from Android 13 // Port of BitSet32 from Android
13 // * platform/system/core/include/utils/BitSet.h 14 // * platform/system/core/include/utils/BitSet.h
14 // * Change-Id: I9bbf41f9d2d4a2593b0e6d7d8be7e283f985bade 15 // * Change-Id: I9bbf41f9d2d4a2593b0e6d7d8be7e283f985bade
15 // * Please update the Change-Id as upstream Android changes are pulled. 16 // * Please update the Change-Id as upstream Android changes are pulled.
16 struct BitSet32 { 17 struct BitSet32 {
17 uint32_t value; 18 uint32_t value;
18 19
19 inline BitSet32() : value(0) {} 20 inline BitSet32() : value(0) {}
20 explicit inline BitSet32(uint32_t value) : value(value) {} 21 explicit inline BitSet32(uint32_t value) : value(value) {}
21 22
22 // Gets the value associated with a particular bit index. 23 // Gets the value associated with a particular bit index.
23 static inline uint32_t value_for_bit(uint32_t n) { return 0x80000000 >> n; } 24 static inline uint32_t value_for_bit(uint32_t n) {
25 DCHECK_LE(n, 31U);
26 return 0x80000000 >> n;
27 }
24 28
25 // Clears the bit set. 29 // Clears the bit set.
26 inline void clear() { value = 0; } 30 inline void clear() { value = 0; }
27 31
28 // Returns the number of marked bits in the set. 32 // Returns the number of marked bits in the set.
29 inline uint32_t count() const { return popcnt(value); } 33 inline uint32_t count() const { return popcnt(value); }
30 34
31 // Returns true if the bit set does not contain any marked bits. 35 // Returns true if the bit set does not contain any marked bits.
32 inline bool is_empty() const { return !value; } 36 inline bool is_empty() const { return !value; }
33 37
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // Result is undefined if all bits are unmarked. 83 // Result is undefined if all bits are unmarked.
80 inline uint32_t clear_last_marked_bit() { 84 inline uint32_t clear_last_marked_bit() {
81 uint32_t n = last_marked_bit(); 85 uint32_t n = last_marked_bit();
82 clear_bit(n); 86 clear_bit(n);
83 return n; 87 return n;
84 } 88 }
85 89
86 // Gets the inde of the specified bit in the set, which is the number of 90 // Gets the inde of the specified bit in the set, which is the number of
87 // marked bits that appear before the specified bit. 91 // marked bits that appear before the specified bit.
88 inline uint32_t get_index_of_bit(uint32_t n) const { 92 inline uint32_t get_index_of_bit(uint32_t n) const {
93 DCHECK_LE(n, 31U);
89 return popcnt(value & ~(0xffffffffUL >> n)); 94 return popcnt(value & ~(0xffffffffUL >> n));
90 } 95 }
91 96
92 inline bool operator==(const BitSet32& other) const { 97 inline bool operator==(const BitSet32& other) const {
93 return value == other.value; 98 return value == other.value;
94 } 99 }
95 inline bool operator!=(const BitSet32& other) const { 100 inline bool operator!=(const BitSet32& other) const {
96 return value != other.value; 101 return value != other.value;
97 } 102 }
98 103
(...skipping 20 matching lines...) Expand all
119 } 124 }
120 static inline uint32_t ctz(uint32_t v) { 125 static inline uint32_t ctz(uint32_t v) {
121 return popcnt((v & static_cast<uint32_t>(-static_cast<int>(v))) - 1); 126 return popcnt((v & static_cast<uint32_t>(-static_cast<int>(v))) - 1);
122 } 127 }
123 #endif 128 #endif
124 }; 129 };
125 130
126 } // namespace ui 131 } // namespace ui
127 132
128 #endif // UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_ 133 #endif // UI_EVENTS_GESTURE_DETECTION_BITSET_32_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698