|
16 | 16 | #define INK_STROKES_INPUT_STROKE_INPUT_BATCH_H_ |
17 | 17 |
|
18 | 18 | #include <cstddef> |
| 19 | +#include <cstdint> |
19 | 20 | #include <iterator> |
20 | 21 | #include <limits> |
21 | 22 | #include <optional> |
@@ -73,7 +74,7 @@ class StrokeInputBatch { |
73 | 74 |
|
74 | 75 | // Performs validation on `inputs` and returns the resulting batch or error. |
75 | 76 | static absl::StatusOr<StrokeInputBatch> Create( |
76 | | - absl::Span<const StrokeInput> inputs); |
| 77 | + absl::Span<const StrokeInput> inputs, uint32_t noise_seed = 0); |
77 | 78 |
|
78 | 79 | StrokeInputBatch() = default; |
79 | 80 | StrokeInputBatch(const StrokeInputBatch&) = default; |
@@ -111,7 +112,9 @@ class StrokeInputBatch { |
111 | 112 | // Returns an error and does not modify the batch if validation fails. |
112 | 113 | absl::Status Append(const StrokeInput& input); |
113 | 114 |
|
114 | | - // Validates and appends a sequence of `inputs`. |
| 115 | + // Validates and appends a sequence of `inputs`. This batch's per-stroke seed |
| 116 | + // value is left unchanged, even when appending another batch with a different |
| 117 | + // seed value. |
115 | 118 | // |
116 | 119 | // Returns an error and does not modify the batch if validation fails. |
117 | 120 | absl::Status Append(absl::Span<const StrokeInput> inputs); |
@@ -147,6 +150,16 @@ class StrokeInputBatch { |
147 | 150 | bool HasTilt() const; |
148 | 151 | bool HasOrientation() const; |
149 | 152 |
|
| 153 | + // Returns the seed value that should be used for seeding any noise generators |
| 154 | + // for brush behaviors when a full stroke is regenerated with this input |
| 155 | + // batch. If no seed value has yet been set for this input batch, returns the |
| 156 | + // default seed of zero. |
| 157 | + uint32_t GetNoiseSeed() const; |
| 158 | + |
| 159 | + // Sets the per-stroke seed value that should be used when regenerating a |
| 160 | + // stroke from this input batch. |
| 161 | + void SetNoiseSeed(uint32_t seed); |
| 162 | + |
150 | 163 | // Which properties of the stroke should be preserved over transforms. |
151 | 164 | enum class TransformInvariant { |
152 | 165 | kPreserveDuration = 0, |
@@ -222,6 +235,7 @@ class StrokeInputBatch { |
222 | 235 | size_t size_ = 0; |
223 | 236 | StrokeInput::ToolType tool_type_ = StrokeInput::ToolType::kUnknown; |
224 | 237 | PhysicalDistance stroke_unit_length_ = StrokeInput::kNoStrokeUnitLength; |
| 238 | + uint32_t noise_seed_ = 0; |
225 | 239 | bool has_pressure_ = false; |
226 | 240 | bool has_tilt_ = false; |
227 | 241 | bool has_orientation_ = false; |
@@ -308,6 +322,12 @@ inline std::optional<PhysicalDistance> StrokeInputBatch::GetStrokeUnitLength() |
308 | 322 | return stroke_unit_length_; |
309 | 323 | } |
310 | 324 |
|
| 325 | +inline uint32_t StrokeInputBatch::GetNoiseSeed() const { return noise_seed_; } |
| 326 | + |
| 327 | +inline void StrokeInputBatch::SetNoiseSeed(uint32_t seed) { |
| 328 | + noise_seed_ = seed; |
| 329 | +} |
| 330 | + |
311 | 331 | inline bool StrokeInputBatch::HasStrokeUnitLength() const { |
312 | 332 | return stroke_unit_length_ != StrokeInput::kNoStrokeUnitLength; |
313 | 333 | } |
|
0 commit comments