Index: cc/base/pyramid_sequence.h |
diff --git a/cc/base/pyramid_sequence.h b/cc/base/pyramid_sequence.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dbfb74b3519ef1091a1f731c39e99e43951a0504 |
--- /dev/null |
+++ b/cc/base/pyramid_sequence.h |
@@ -0,0 +1,60 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CC_BASE_PYRAMID_SEQUENCE_H_ |
+#define CC_BASE_PYRAMID_SEQUENCE_H_ |
+ |
+#include "base/logging.h" |
+#include "cc/base/cc_export.h" |
+ |
+namespace cc { |
+ |
+class CC_EXPORT PyramidSequence { |
vmpstr
2016/06/16 18:28:58
Can you put a comprehensive comment here explainin
|
+ public: |
+ enum class Type : uint16_t { |
+ FORWARD, |
+ BACKWARD, |
+ DIAGONAL_FORWARD, |
+ DIAGONAL_BACKWARD |
+ }; |
+ |
+ PyramidSequence(Type type, int start, int end, int levels); |
vmpstr
2016/06/16 18:28:58
This needs a comment to explain what each variable
|
+ ~PyramidSequence(); |
+ |
+ int GetCurrent(); |
vmpstr
2016/06/16 18:28:58
Name this better... GetCurrent what?
|
+ int GetCoverage(); |
+ bool within_bounds() { return within_bounds_; } |
vmpstr
2016/06/16 18:28:58
is_within_bounds
|
+ void Advance(); |
+ |
+ private: |
+ typedef void (PyramidSequence::*InflateFn)(); |
vmpstr
2016/06/16 18:28:58
using InflateFn = void (PyramidSequence::*)();
|
+ typedef bool (PyramidSequence::*IsWithinBoundsFn)(); |
+ |
+ void Init(Type type); |
+ void Reset(); |
+ |
+ void InflateForward(); |
+ bool IsWithinBoundsForward(); |
+ void InflateBackward(); |
+ bool IsWithinBoundsBackward(); |
+ void InflateDiagonalForward(); |
+ bool IsWithinBoundsDiagonalForward(); |
+ void InflateDiagonalBackward(); |
+ bool IsWithinBoundsDiagonalBackward(); |
+ |
+ int start_; |
+ int end_; |
+ int levels_; |
+ int levels_traversed_; |
+ bool within_bounds_; |
+ int current_; |
+ int step_; |
+ |
+ InflateFn inflater_; |
vmpstr
2016/06/16 18:28:58
I'd call this "inflate_" and "determine_within_bou
|
+ IsWithinBoundsFn within_bounds_checker_; |
+}; |
+ |
+} // namespace cc |
+ |
+#endif // CC_BASE_PYRAMID_SEQUENCE_H_ |