Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1b1e94a

Browse files
Ink Open Sourcecopybara-github
Ink Open Source
authored andcommitted
AddChangesWithTime boolean function toInProgressStroke to indicate when timestamp-based effects are active.
PiperOrigin-RevId: 795120284
1 parent2b5a407 commit1b1e94a

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

‎ink/strokes/in_progress_stroke.cc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ bool InProgressStroke::NeedsUpdate() const {
168168
if (!queued_real_inputs_.IsEmpty() || !queued_predicted_inputs_.IsEmpty()) {
169169
returntrue;
170170
}
171+
returnChangesWithTime();
172+
}
173+
174+
boolInProgressStroke::ChangesWithTime()const {
171175
uint32_t num_coats =BrushCoatCount();
172176
for (uint32_t coat_index =0; coat_index < num_coats; ++coat_index) {
173177
if (shape_builders_[coat_index].HasUnfinishedTimeBehaviors()) {

‎ink/strokes/in_progress_stroke.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ class InProgressStroke {
159159
// call to `Start()`.
160160
boolNeedsUpdate()const;
161161

162+
// Returns true if the stroke's geometry changes with the passage of time
163+
// (denoted by new values being passed to `UpdateShape()`), even if no new
164+
// inputs are provided via `EnqueueInputs()`. This is the case if the brush
165+
// has one or more timed animation behavior that are still active (which can
166+
// be true even after inputs are finished).
167+
//
168+
// This is similar to `NeedsUpdate()`, except that it ignores whether inputs
169+
// are finished or pending.
170+
boolChangesWithTime()const;
171+
162172
// Returns a pointer to the current brush, or `nullptr` if `Start()` has not
163173
// been called.
164174
const Brush* absl_nullableGetBrush()const;

‎ink/strokes/in_progress_stroke_test.cc‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ TEST(InProgressStrokeTest, DefaultConstructed) {
215215
EXPECT_TRUE(stroke.GetUpdatedRegion().IsEmpty());
216216
EXPECT_TRUE(stroke.InputsAreFinished());
217217
EXPECT_FALSE(stroke.NeedsUpdate());
218+
EXPECT_FALSE(stroke.ChangesWithTime());
218219
}
219220

220221
TEST(InProgressStrokeTest, MoveConstructedAndAssigned) {
@@ -264,6 +265,7 @@ TEST(InProgressStrokeTest, StartAfterConstruction) {
264265
EXPECT_TRUE(stroke.GetUpdatedRegion().IsEmpty());
265266
EXPECT_FALSE(stroke.InputsAreFinished());
266267
EXPECT_FALSE(stroke.NeedsUpdate());
268+
EXPECT_FALSE(stroke.ChangesWithTime());
267269
}
268270

269271
TEST(InProgressStrokeTest, ClearAfterStart) {
@@ -278,6 +280,7 @@ TEST(InProgressStrokeTest, ClearAfterStart) {
278280
EXPECT_TRUE(stroke.GetUpdatedRegion().IsEmpty());
279281
EXPECT_TRUE(stroke.InputsAreFinished());
280282
EXPECT_FALSE(stroke.NeedsUpdate());
283+
EXPECT_FALSE(stroke.ChangesWithTime());
281284
}
282285

283286
TEST(InProgressStrokeTest, EnqueueInputsWithoutStart) {
@@ -308,6 +311,7 @@ TEST(InProgressStrokeTest, EmptyEnqueueInputsDoesNotNeedUpdate) {
308311
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs({}, {}));
309312

310313
EXPECT_FALSE(stroke.NeedsUpdate());
314+
EXPECT_FALSE(stroke.ChangesWithTime());
311315
}
312316

313317
TEST(InProgressStrokeTest, NonEmptyEnqueueInputsNeedsUpdate) {
@@ -321,6 +325,7 @@ TEST(InProgressStrokeTest, NonEmptyEnqueueInputsNeedsUpdate) {
321325
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs(*real_inputs, {}));
322326

323327
EXPECT_TRUE(stroke.NeedsUpdate());
328+
EXPECT_FALSE(stroke.ChangesWithTime());
324329
}
325330

326331
TEST(InProgressStrokeTest, EmptyEnqueueInputsAndUpdateAfterStart) {
@@ -338,6 +343,7 @@ TEST(InProgressStrokeTest, EmptyEnqueueInputsAndUpdateAfterStart) {
338343
EXPECT_THAT(stroke.GetCoatOutlines(0),IsEmpty());
339344
EXPECT_TRUE(stroke.GetUpdatedRegion().IsEmpty());
340345
EXPECT_FALSE(stroke.NeedsUpdate());
346+
EXPECT_FALSE(stroke.ChangesWithTime());
341347
}
342348

343349
TEST(InProgressStrokeTest, EnqueueInputsPredictionOnlyAndUpdate) {
@@ -351,6 +357,7 @@ TEST(InProgressStrokeTest, EnqueueInputsPredictionOnlyAndUpdate) {
351357
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs({}, *predicted_inputs));
352358

353359
EXPECT_TRUE(stroke.NeedsUpdate());
360+
EXPECT_FALSE(stroke.ChangesWithTime());
354361

355362
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Zero()));
356363

@@ -359,6 +366,7 @@ TEST(InProgressStrokeTest, EnqueueInputsPredictionOnlyAndUpdate) {
359366
EXPECT_GT(stroke.GetMesh(0).VertexCount(),0u);
360367
EXPECT_FALSE(stroke.GetUpdatedRegion().IsEmpty());
361368
EXPECT_FALSE(stroke.NeedsUpdate());
369+
EXPECT_FALSE(stroke.ChangesWithTime());
362370
}
363371

364372
TEST(InProgressStrokeTest, NonEmptyInputs) {
@@ -489,26 +497,31 @@ TEST(InProgressStrokeTest, EnqueueInputsWithDifferentToolTypes) {
489497
EXPECT_THAT(stroke.EnqueueInputs(*mouse_input, *touch_input),
490498
IsInvalidArgumentErrorThat(HasSubstr("tool_type")));
491499
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
500+
EXPECT_FALSE(stroke.ChangesWithTime());
492501

493502
// We *can* predict touch inputs (with no real inputs so far)...
494503
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs({}, *touch_input));
495504
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
505+
EXPECT_FALSE(stroke.ChangesWithTime());
496506
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Zero()));
497507
// ...and then actually end up with real mouse inputs (which replace the
498508
// predicted touch inputs).
499509
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs(*mouse_input, {}));
500510
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
511+
EXPECT_FALSE(stroke.ChangesWithTime());
501512
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Zero()));
502513

503514
// But now that we have real mouse inputs, we can't predict further touch
504515
// inputs...
505516
EXPECT_THAT(stroke.EnqueueInputs({}, *touch_input),
506517
IsInvalidArgumentErrorThat(HasSubstr("tool_type")));
507518
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
519+
EXPECT_FALSE(stroke.ChangesWithTime());
508520
// ...nor can we add real touch inputs.
509521
EXPECT_THAT(stroke.EnqueueInputs(*touch_input, {}),
510522
IsInvalidArgumentErrorThat(HasSubstr("tool_type")));
511523
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
524+
EXPECT_FALSE(stroke.ChangesWithTime());
512525
}
513526

514527
TEST(InProgressStrokeTest, EnqueueInputsDuplicatePositionAndTime) {
@@ -523,22 +536,27 @@ TEST(InProgressStrokeTest, EnqueueInputsDuplicatePositionAndTime) {
523536
EXPECT_THAT(stroke.EnqueueInputs(*input, *input),
524537
IsInvalidArgumentErrorThat(HasSubstr("duplicate")));
525538
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
539+
EXPECT_FALSE(stroke.ChangesWithTime());
526540

527541
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs({}, *input));
528542
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
543+
EXPECT_FALSE(stroke.ChangesWithTime());
529544
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Seconds(1)));
530545

531546
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs(*input, {}));
532547
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
548+
EXPECT_FALSE(stroke.ChangesWithTime());
533549
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Seconds(1)));
534550

535551
EXPECT_THAT(stroke.EnqueueInputs({}, *input),
536552
IsInvalidArgumentErrorThat(HasSubstr("duplicate")));
537553
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
554+
EXPECT_FALSE(stroke.ChangesWithTime());
538555

539556
EXPECT_THAT(stroke.EnqueueInputs(*input, {}),
540557
IsInvalidArgumentErrorThat(HasSubstr("duplicate")));
541558
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
559+
EXPECT_FALSE(stroke.ChangesWithTime());
542560
}
543561

544562
TEST(InProgressStrokeTest,
@@ -555,10 +573,12 @@ TEST(InProgressStrokeTest,
555573

556574
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs(*first, {}));
557575
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
576+
EXPECT_FALSE(stroke.ChangesWithTime());
558577
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Seconds(1)));
559578

560579
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs(*second, {}));
561580
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
581+
EXPECT_FALSE(stroke.ChangesWithTime());
562582
// But not actually doing an update yet. We reject updates that would
563583
// duplicate against the last real input, which is currently queued.
564584
EXPECT_THAT(stroke.EnqueueInputs(*second, {}),
@@ -591,25 +611,30 @@ TEST(InProgressStrokeTest, EnqueueInputsWithDecreasingElapsedTime) {
591611
EXPECT_THAT(stroke.EnqueueInputs(*first_inputs, *second_inputs),
592612
IsInvalidArgumentErrorThat(HasSubstr("non-decreasing")));
593613
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
614+
EXPECT_FALSE(stroke.ChangesWithTime());
594615

595616
// We *can* enqueue just the prediction...
596617
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs({}, *second_inputs));
597618
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
619+
EXPECT_FALSE(stroke.ChangesWithTime());
598620
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Seconds(3)));
599621
// ...and then later replace it with the real inputs.
600622
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs(*first_inputs, {}));
601623
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
624+
EXPECT_FALSE(stroke.ChangesWithTime());
602625
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Seconds(4)));
603626

604627
// But now that we've added the real inputs, we can't then add a prediction
605628
// whose start time takes place in the middle of those real inputs...
606629
EXPECT_THAT(stroke.EnqueueInputs({}, *second_inputs),
607630
IsInvalidArgumentErrorThat(HasSubstr("non-decreasing")));
608631
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
632+
EXPECT_FALSE(stroke.ChangesWithTime());
609633
// ...nor can we add those overlapping inputs as additional real inputs.
610634
EXPECT_THAT(stroke.EnqueueInputs(*second_inputs, {}),
611635
IsInvalidArgumentErrorThat(HasSubstr("non-decreasing")));
612636
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
637+
EXPECT_FALSE(stroke.ChangesWithTime());
613638
}
614639

615640
TEST(InProgressStrokeTest, EnqueueInputsWithDifferentOptionalPropertyFormats) {
@@ -629,21 +654,25 @@ TEST(InProgressStrokeTest, EnqueueInputsWithDifferentOptionalPropertyFormats) {
629654
EXPECT_THAT(stroke.EnqueueInputs(*pressure_input, *no_pressure_input),
630655
IsInvalidArgumentErrorThat(HasSubstr("pressure")));
631656
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
657+
EXPECT_FALSE(stroke.ChangesWithTime());
632658

633659
// Add some real inputs with pressure data.
634660
EXPECT_EQ(absl::OkStatus(), stroke.EnqueueInputs(*pressure_input, {}));
635661
EXPECT_TRUE(stroke.NeedsUpdate());// inputs were enqueued
662+
EXPECT_FALSE(stroke.ChangesWithTime());
636663
EXPECT_EQ(absl::OkStatus(), stroke.UpdateShape(Duration32::Zero()));
637664

638665
// Now that we have real inputs with pressure data, we can't predict further
639666
// inputs without pressure data...
640667
EXPECT_THAT(stroke.EnqueueInputs({}, *no_pressure_input),
641668
IsInvalidArgumentErrorThat(HasSubstr("pressure")));
642669
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
670+
EXPECT_FALSE(stroke.ChangesWithTime());
643671
// ...nor can we add further real inputs without pressure data.
644672
EXPECT_THAT(stroke.EnqueueInputs(*no_pressure_input, {}),
645673
IsInvalidArgumentErrorThat(HasSubstr("pressure")));
646674
EXPECT_FALSE(stroke.NeedsUpdate());// no inputs were enqueued
675+
EXPECT_FALSE(stroke.ChangesWithTime());
647676
}
648677

649678
TEST(InProgressStrokeTest, UpdateShapeWithNegativeCurrentElapsedTime) {

‎ink/strokes/internal/jni/in_progress_stroke_jni.cc‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ JNI_METHOD(strokes, InProgressStrokeNative, jboolean, isUpdateNeeded)
131131
returnCastToInProgressStrokeWrapper(native_pointer).Stroke().NeedsUpdate();
132132
}
133133

134+
JNI_METHOD(strokes, InProgressStrokeNative, jboolean, changesWithTime)
135+
(JNIEnv* env, jobject thiz, jlong native_pointer) {
136+
returnCastToInProgressStrokeWrapper(native_pointer)
137+
.Stroke()
138+
.ChangesWithTime();
139+
}
140+
134141
JNI_METHOD(strokes, InProgressStrokeNative, jlong, newStrokeFromCopy)
135142
(JNIEnv* env, jobject thiz, jlong native_pointer) {
136143
returnNewNativeStroke(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp