@@ -115,6 +115,14 @@ absl::Status InProgressStroke::EnqueueInputs(
115115 return absl::OkStatus ();
116116}
117117
118+ bool InProgressStroke::HasQueuedInputs () const {
119+ return !queued_real_inputs_.IsEmpty () ||
120+ !queued_predicted_inputs_.IsEmpty () ||
121+ // The only thing queued was empty, but a previous prediction was
122+ // cleared as a result.
123+ (queued_inputs_since_last_update_shape_ && PredictedInputCount () > 0 );
124+ }
125+
118126absl::Status InProgressStroke::UpdateShape (Duration32 current_elapsed_time) {
119127 if (!brush_.has_value ()) {
120128 return absl::FailedPreconditionError (
@@ -126,11 +134,14 @@ absl::Status InProgressStroke::UpdateShape(Duration32 current_elapsed_time) {
126134 !status.ok ()) {
127135 return status;
128136 }
129- if (inputs_are_finished_ || !queued_real_inputs_. IsEmpty () ||
130- !queued_predicted_inputs_. IsEmpty () ||
131- (queued_inputs_since_last_update_shape_ && PredictedInputCount () > 0 )) {
137+ current_elapsed_time_ = current_elapsed_time;
138+
139+ if ( HasQueuedInputs ( )) {
132140 // Erase any old predicted inputs.
133141 processed_inputs_.Erase (real_input_count_);
142+ } else if (!ChangesWithTime ()) {
143+ // Exit early if no change is needed.
144+ return absl::OkStatus ();
134145 }
135146
136147 if (absl::Status status = processed_inputs_.Append (queued_real_inputs_);
@@ -152,8 +163,6 @@ absl::Status InProgressStroke::UpdateShape(Duration32 current_elapsed_time) {
152163 return status;
153164 }
154165
155- current_elapsed_time_ = current_elapsed_time;
156-
157166 input_modeler_.ExtendStroke (queued_real_inputs_, queued_predicted_inputs_,
158167 current_elapsed_time);
159168 uint32_t num_coats = BrushCoatCount ();
@@ -172,12 +181,7 @@ absl::Status InProgressStroke::UpdateShape(Duration32 current_elapsed_time) {
172181}
173182
174183bool InProgressStroke::NeedsUpdate () const {
175- if (!queued_real_inputs_.IsEmpty () || !queued_predicted_inputs_.IsEmpty () ||
176- // There are processed predicted inputs to be cleared.
177- (queued_inputs_since_last_update_shape_ && PredictedInputCount () > 0 )) {
178- return true ;
179- }
180- return ChangesWithTime ();
184+ return HasQueuedInputs () || ChangesWithTime ();
181185}
182186
183187bool InProgressStroke::ChangesWithTime () const {
0 commit comments