Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ink/strokes/in_progress_stroke.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,16 @@ absl::Status InProgressStroke::ValidateNewInputsAttributes(
const StrokeInput& first_new_input =
real_inputs.IsEmpty() ? predicted_inputs.First() : real_inputs.First();
ABSL_RETURN_IF_ERROR(
ValidateConsistentAttributes(last_old_real_input, first_new_input));
ValidateConsistentAttributes(last_old_real_input, first_new_input))
<< "Failed to validate new inputs against previous real inputs.";
}

// If there are both new real and predicted inputs, check that the first
// predicted input is valid against the last real input.
if (!real_inputs.IsEmpty() && !predicted_inputs.IsEmpty()) {
ABSL_RETURN_IF_ERROR(ValidateConsistentAttributes(
real_inputs.Last(), predicted_inputs.First()));
ABSL_RETURN_IF_ERROR(ValidateConsistentAttributes(real_inputs.Last(),
predicted_inputs.First()))
<< "Failed to validate predicted inputs against real inputs.";
}

return absl::OkStatus();
Expand Down
29 changes: 21 additions & 8 deletions ink/strokes/input/stroke_input_batch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ absl::Status ValidateInputSequence(absl::Span<const StrokeInput> inputs) {
ABSL_RETURN_IF_ERROR(ValidateSingleInput(inputs[0]));
for (size_t i = 1; i < inputs.size(); ++i) {
ABSL_RETURN_IF_ERROR(ValidateSingleInput(inputs[i]));
ABSL_RETURN_IF_ERROR(ValidateConsecutiveInputs(inputs[i - 1], inputs[i]));
ABSL_RETURN_IF_ERROR(ValidateConsecutiveInputs(inputs[i - 1], inputs[i]))
<< "Failed to validate input at index " << i
<< " against previous input.";
}

return absl::OkStatus();
Expand Down Expand Up @@ -213,10 +215,15 @@ absl::Status StrokeInputBatch::Set(int i, const StrokeInput& input) {
}

if (i > 0) {
ABSL_RETURN_IF_ERROR(ValidateConsecutiveInputs(Get(i - 1), input));
ABSL_RETURN_IF_ERROR(ValidateConsecutiveInputs(Get(i - 1), input))
<< "Failed to validate input being set at index " << i
<< " against previous input.";
;
}
if (i + 1 < Size()) {
ABSL_RETURN_IF_ERROR(ValidateConsecutiveInputs(input, Get(i + 1)));
ABSL_RETURN_IF_ERROR(ValidateConsecutiveInputs(input, Get(i + 1)))
<< "Failed to validate input being set at index " << i
<< " against following input.";
}

auto data =
Expand Down Expand Up @@ -263,7 +270,8 @@ absl::Status StrokeInputBatch::PrepareForAppend(

absl::Status StrokeInputBatch::Append(const StrokeInput& input) {
ABSL_RETURN_IF_ERROR(ValidateSingleInput(input));
ABSL_RETURN_IF_ERROR(PrepareForAppend(input));
ABSL_RETURN_IF_ERROR(PrepareForAppend(input))
<< "Failed to validate new single input against previous values.";
AppendInputToFloatVector(input, data_.MutableValue());
++size_;
return absl::OkStatus();
Expand All @@ -273,8 +281,10 @@ absl::Status StrokeInputBatch::Append(absl::Span<const StrokeInput> inputs) {
if (inputs.empty()) {
return absl::OkStatus();
}
ABSL_RETURN_IF_ERROR(ValidateInputSequence(inputs));
ABSL_RETURN_IF_ERROR(PrepareForAppend(inputs.front()));
ABSL_RETURN_IF_ERROR(ValidateInputSequence(inputs))
<< "Failed to validate new input span.";
ABSL_RETURN_IF_ERROR(PrepareForAppend(inputs.front()))
<< "Failed to validate new input span against previous values.";

// We don't call `vector::reserve` on purpose. Depending on the STL
// implementation, it could degrade performance given the expectation that
Expand Down Expand Up @@ -318,7 +328,8 @@ absl::Status StrokeInputBatch::Append(const StrokeInputBatch& inputs) {
return absl::OkStatus();
}

ABSL_RETURN_IF_ERROR(ValidateConsecutiveInputs(Last(), inputs.First()));
ABSL_RETURN_IF_ERROR(ValidateConsecutiveInputs(Last(), inputs.First()))
<< "Failed to validate new input batch against previous input.";

// We don't call `vector::reserve` on purpose. Depending on the STL
// implementation, it could degrade performance given the expectation that
Expand All @@ -343,7 +354,9 @@ absl::Status StrokeInputBatch::Append(const StrokeInputBatch& inputs,

if (!IsEmpty()) {
ABSL_RETURN_IF_ERROR(
ValidateConsecutiveInputs(Last(), inputs.Get(start_index)));
ValidateConsecutiveInputs(Last(), inputs.Get(start_index)))
<< "Failed to validate new input batch subsequence against previous "
"input.";
} else {
if (!data_.HasValue()) data_.Emplace();
SetInlineFormatMetadata(inputs.Get(start_index));
Expand Down
Loading