Flutter Engine
The Flutter Engine
Functions
GraphiteYUVAPromiseImageTest.cpp File Reference
#include "include/gpu/graphite/BackendTexture.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkSurface.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Image.h"
#include "include/gpu/graphite/Recording.h"
#include "include/gpu/graphite/Surface.h"
#include "include/gpu/graphite/YUVABackendTextures.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/ContextPriv.h"
#include "src/gpu/graphite/RecordingPriv.h"
#include "tests/Test.h"
#include "tools/graphite/GraphiteTestContext.h"

Go to the source code of this file.

Functions

 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (NonVolatileGraphiteYUVAPromiseImageTest, reporter, context, testGpuContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (NonVolatileGraphiteYUVAPromiseImageFulfillFailureTest, reporter, context, testGpuContext, true, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (NonVolatileGraphiteYUVAPromiseImageCreationFailureTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (VolatileGraphiteYUVAPromiseImageTest, reporter, context, testGpuContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (VolatileGraphiteYUVAPromiseImageFulfillFailureTest, reporter, context, testGpuContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (GraphiteYUVAPromiseImageRecorderLoss, reporter, context, testGpuContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (GraphiteYUVAPromiseImageMultipleImgUses, reporter, context, testGpuContext, true, CtsEnforcement::kNextRelease)
 

Function Documentation

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [1/6]

DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( GraphiteYUVAPromiseImageMultipleImgUses  ,
reporter  ,
context  ,
testGpuContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 731 of file GraphiteYUVAPromiseImageTest.cpp.

736 {
737 constexpr SkISize kDimensions{ 16, 16 };
738
739 static constexpr int kNumRecordings = 3;
740
741 for (Volatile isVolatile : { Volatile::kNo, Volatile::kYes }) {
742 int expectedVolatile = (isVolatile == Volatile::kYes) ? 4 : 0;
743 int expectedNonVolatile = 4 - expectedVolatile;
744
745 TestCtx testContext;
746 setup_test_context(context, reporter, &testContext,
747 kDimensions, isVolatile, /* invalidBackendTex= */ false);
748
749 std::unique_ptr<Recording> recordings[kNumRecordings];
750
751 SkCanvas* canvas = testContext.fSurface->getCanvas();
752
753 for (int i = 0; i < kNumRecordings; ++i) {
754 canvas->drawImage(testContext.fImg, 0, 0);
755
756 recordings[i] = testContext.fRecorder->snap();
757
758 if (isVolatile == Volatile::kYes) {
759 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
760 testContext.fPromiseTextureCheckers,
761 /* expectedFulfillCnt= */ i);
762 } else {
763 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
764 testContext.fPromiseTextureCheckers,
765 /* expectedFulfillCnt= */ i > 0 ? 1 : 0);
766 }
767
769 recordings[i]->priv().numVolatilePromiseImages() == expectedVolatile);
771 recordings[i]->priv().numNonVolatilePromiseImages() ==
772 expectedNonVolatile);
773
774 REPORTER_ASSERT(reporter, context->insertRecording({ recordings[i].get() }));
775
776 if (isVolatile == Volatile::kYes) {
777 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
778 testContext.fPromiseTextureCheckers,
779 /* expectedFulfillCnt= */ i+1);
780 } else {
781 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
782 testContext.fPromiseTextureCheckers,
783 /* expectedFulfillCnt= */ 1);
784 }
785
786 // Non-volatiles are cleared out after a successful insertion
787 REPORTER_ASSERT(reporter, recordings[i]->priv().numNonVolatilePromiseImages() == 0);
788 }
789
790 testGpuContext->syncedSubmit(context);
791
792 testContext.fSurface.reset();
793 testContext.fImg.reset();
794 for (int i = 0; i < kNumRecordings; ++i) {
795 recordings[i].reset();
796 }
797
798 if (isVolatile == Volatile::kYes) {
799 check_all_done(reporter, testContext.fPromiseImageChecker,
800 testContext.fPromiseTextureCheckers,
801 /* expectedFulfillCnt= */ kNumRecordings);
802 } else {
803 check_all_done(reporter, testContext.fPromiseImageChecker,
804 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 1);
805 }
806 }
807}
reporter
Definition: FontMgrTest.cpp:39
static void check_all_done(skiatest::Reporter *reporter, const PromiseTextureChecker &promiseChecker, int expectedFulfillCnt=1)
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
FlPixelBufferTexturePrivate * priv
Definition: SkSize.h:16

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [2/6]

DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( GraphiteYUVAPromiseImageRecorderLoss  ,
reporter  ,
context  ,
testGpuContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 689 of file GraphiteYUVAPromiseImageTest.cpp.

694 {
695 constexpr SkISize kDimensions{ 16, 16 };
696
697 for (Volatile isVolatile : { Volatile::kNo, Volatile::kYes }) {
698 TestCtx testContext;
699 setup_test_context(context, reporter, &testContext,
700 kDimensions, isVolatile, /* invalidBackendTex= */ false);
701
702 SkCanvas* canvas = testContext.fSurface->getCanvas();
703
704 canvas->drawImage(testContext.fImg, 0, 0);
705 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
706 reporter);
707
708 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
709 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
710 reporter);
711
712 testContext.fRecorder.reset(); // Recorder drop
713
714 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
715 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
716 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 1);
717
718 testGpuContext->syncedSubmit(context);
719
720 testContext.fSurface.reset();
721 testContext.fImg.reset();
722 recording.reset();
723
724 check_all_done(reporter, testContext.fPromiseImageChecker,
725 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 1);
726 }
727}
static void check_unfulfilled(const PromiseTextureChecker &promiseChecker, skiatest::Reporter *reporter)

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [3/6]

DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( NonVolatileGraphiteYUVAPromiseImageFulfillFailureTest  ,
reporter  ,
context  ,
testGpuContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 378 of file GraphiteYUVAPromiseImageTest.cpp.

384 {
385 constexpr SkISize kDimensions { 16, 16 };
386
387 TestCtx testContext;
388 setup_test_context(context, reporter, &testContext,
389 kDimensions, Volatile::kNo, /* invalidBackendTex= */ true);
390
391 // Draw the image a few different ways.
392 {
393 SkCanvas* canvas = testContext.fSurface->getCanvas();
394
395 canvas->drawImage(testContext.fImg, 0, 0);
396 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
397 reporter);
398
399 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
400 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
401 reporter);
402
403 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
404 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
405 testContext.fPromiseTextureCheckers,
406 /* expectedFulfillCnt= */ 1);
407
408 // Test that reinserting gives uninstantiated PromiseImages a second chance
409 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
410 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
411 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 2);
412 }
413
414 {
415 SkCanvas* canvas = testContext.fSurface->getCanvas();
416
419 canvas->drawImage(testContext.fImg, 0, 0, SkSamplingOptions(), &paint);
420
421 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
422 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
423 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 2);
424
425 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
426 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
427 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 3);
428 }
429
430 {
431 SkCanvas* canvas = testContext.fSurface->getCanvas();
432
433 sk_sp<SkShader> shader = testContext.fImg->makeShader(SkSamplingOptions());
434 REPORTER_ASSERT(reporter, shader);
435
437 paint.setShader(std::move(shader));
438 canvas->drawRect(SkRect::MakeWH(1, 1), paint);
439
440 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
441 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
442 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 3);
443
444 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
445 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
446 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 4);
447 }
448
449 testContext.fSurface.reset();
450 testContext.fImg.reset();
451
452 // Despite fulfill failing 4x, the imageRelease callback still fires
453 testContext.fPromiseImageChecker.checkImageReleased(reporter, /* expectedReleaseCnt= */ 1);
454
455 testGpuContext->syncedSubmit(context);
456 // fulfill should've been called 4x while release should never have been called
457 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
458 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 4);
459}
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
static sk_sp< SkColorFilter > LinearToSRGBGamma()
const Paint & paint
Definition: color_source.cc:38
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [4/6]

DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( NonVolatileGraphiteYUVAPromiseImageTest  ,
reporter  ,
context  ,
testGpuContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 280 of file GraphiteYUVAPromiseImageTest.cpp.

285 {
286 constexpr SkISize kDimensions { 16, 16 };
287
288 TestCtx testContext;
289 setup_test_context(context, reporter, &testContext,
290 kDimensions, Volatile::kNo, /* invalidBackendTex= */ false);
291
292 {
293 SkCanvas* canvas = testContext.fSurface->getCanvas();
294
295 canvas->drawImage(testContext.fImg, 0, 0);
296 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
297 reporter);
298
299 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
300 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
301 reporter); // NVPIs not fulfilled at snap
302
303 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
304 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
305 testContext.fPromiseTextureCheckers,
306 /* expectedFulfillCnt= */ 1); // NVPIs fulfilled at insert
307 }
308
309 context->submit(SyncToCpu::kNo);
310 // testContext.fImg still has a ref so we should not have called TextureRelease.
311 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
312 testContext.fPromiseTextureCheckers,
313 /* expectedFulfillCnt= */ 1);
314
315 testGpuContext->syncedSubmit(context);
316
317 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
318 testContext.fPromiseTextureCheckers,
319 /* expectedFulfillCnt= */ 1);
320
321 // Test that more draws and insertions don't refulfill the NVPI
322 {
323 SkCanvas* canvas = testContext.fSurface->getCanvas();
324
325 canvas->drawImage(testContext.fImg, 0, 0);
326 canvas->drawImage(testContext.fImg, 0, 0);
327
328 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
329 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
330 testContext.fPromiseTextureCheckers,
331 /* expectedFulfillCnt= */ 1); // No new fulfill
332
333 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
334 // testContext.fImg should still be fulfilled from the first time we inserted a Recording.
335 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
336 testContext.fPromiseTextureCheckers,
337 /* expectedFulfillCnt= */ 1);
338 }
339
340 testGpuContext->syncedSubmit(context);
341
342 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
343 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 1);
344
345 // Test that dropping the SkImage's ref doesn't change anything
346 {
347 SkCanvas* canvas = testContext.fSurface->getCanvas();
348
349 canvas->drawImage(testContext.fImg, 0, 0);
350 testContext.fImg.reset();
351
352 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
353 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
354 testContext.fPromiseTextureCheckers,
355 /* expectedFulfillCnt= */ 1);
356
357 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
358 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
359 testContext.fPromiseTextureCheckers,
360 /* expectedFulfillCnt= */ 1);
361 }
362
363 // fImg's proxy is reffed by the recording so, despite fImg being reset earlier,
364 // the imageRelease callback doesn't occur until the recording is deleted.
365 testContext.fPromiseImageChecker.checkImageReleased(reporter, /* expectedReleaseCnt= */ 1);
366
367 // testContext.fImg no longer holds a ref but the last recording is still not submitted.
368 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
369 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 1);
370
371 testGpuContext->syncedSubmit(context);
372
373 // Now TextureRelease should definitely have been called.
374 check_all_done(reporter, testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
375 /* expectedFulfillCnt= */ 1);
376}

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [5/6]

DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( VolatileGraphiteYUVAPromiseImageFulfillFailureTest  ,
reporter  ,
context  ,
testGpuContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 603 of file GraphiteYUVAPromiseImageTest.cpp.

609 {
610 constexpr SkISize kDimensions { 16, 16 };
611
612 TestCtx testContext;
613 setup_test_context(context, reporter, &testContext,
614 kDimensions, Volatile::kYes, /* invalidBackendTex= */ true);
615
616 // Draw the image a few different ways.
617 {
618 SkCanvas* canvas = testContext.fSurface->getCanvas();
619
620 canvas->drawImage(testContext.fImg, 0, 0);
621 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
622 reporter);
623
624 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
625 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
626 reporter);
627
628 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
629 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
630 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 1);
631
632 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
633 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
634 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 2);
635 }
636
637 {
638 SkCanvas* canvas = testContext.fSurface->getCanvas();
639
642 canvas->drawImage(testContext.fImg, 0, 0, SkSamplingOptions(), &paint);
643
644 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
645 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
646 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 2);
647
648 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
649 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
650 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 3);
651
652 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
653 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
654 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 4);
655 }
656
657 {
658 SkCanvas* canvas = testContext.fSurface->getCanvas();
659
660 sk_sp<SkShader> shader = testContext.fImg->makeShader(SkSamplingOptions());
661 REPORTER_ASSERT(reporter, shader);
662
664 paint.setShader(std::move(shader));
665 canvas->drawRect(SkRect::MakeWH(1, 1), paint);
666
667 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
668 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
669 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 4);
670
671 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
672 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
673 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 5);
674
675 REPORTER_ASSERT(reporter, !context->insertRecording({ recording.get() }));
676 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
677 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 6);
678 }
679
680 testContext.fSurface.reset();
681 testContext.fImg.reset();
682
683 testGpuContext->syncedSubmit(context);
684 check_fulfills_only(reporter, testContext.fPromiseImageChecker,
685 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 6);
686}

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [6/6]

DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( VolatileGraphiteYUVAPromiseImageTest  ,
reporter  ,
context  ,
testGpuContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 482 of file GraphiteYUVAPromiseImageTest.cpp.

487 {
488 constexpr SkISize kDimensions { 16, 16 };
489
490 TestCtx testContext;
491 setup_test_context(context, reporter, &testContext,
492 kDimensions, Volatile::kYes, /* invalidBackendTex= */ false);
493
494 {
495 SkCanvas* canvas = testContext.fSurface->getCanvas();
496
497 canvas->drawImage(testContext.fImg, 0, 0);
498 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
499 reporter);
500
501 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
502 // Nothing happens at snap time for VPIs
503 check_unfulfilled(testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
504 reporter);
505
506 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
507 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
508 testContext.fPromiseTextureCheckers,
509 /* expectedFulfillCnt= */ 1); // VPIs fulfilled on insert
510
511 // Test that multiple insertions will clobber prior fulfills
512 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
513 check_fulfilled_ahead_by_two(reporter, testContext.fPromiseImageChecker,
514 testContext.fPromiseTextureCheckers,
515 /* expectedFulfillCnt= */ 2);
516 }
517
518 testGpuContext->syncedSubmit(context);
519 check_all_done(reporter, testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
520 /* expectedFulfillCnt= */ 2);
521
522 for (int i = 0; i < 4; ++i) {
524 testContext.fPromiseTextureCheckers[i].fTextureReleaseCounts[0] == 1);
526 testContext.fPromiseTextureCheckers[i].fTextureReleaseCounts[1] == 1);
527 }
528
529 {
530 SkCanvas* canvas = testContext.fSurface->getCanvas();
531
532 canvas->drawImage(testContext.fImg, 0, 0);
533 canvas->drawImage(testContext.fImg, 0, 0);
534
535 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
536 // Nothing happens at snap time for volatile images
537 check_all_done(reporter, testContext.fPromiseImageChecker,
538 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 2);
539
540 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
541 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
542 testContext.fPromiseTextureCheckers,
543 /* expectedFulfillCnt= */ 3);
544
545 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
546 check_fulfilled_ahead_by_two(reporter, testContext.fPromiseImageChecker,
547 testContext.fPromiseTextureCheckers,
548 /* expectedFulfillCnt= */ 4);
549 }
550
551 testGpuContext->syncedSubmit(context);
552 check_all_done(reporter, testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
553 /* expectedFulfillCnt= */ 4);
554
555 for (int i = 0; i < 4; ++i) {
557 testContext.fPromiseTextureCheckers[i].fTextureReleaseCounts[0] == 2);
559 testContext.fPromiseTextureCheckers[i].fTextureReleaseCounts[1] == 2);
560 }
561
562 {
563 SkCanvas* canvas = testContext.fSurface->getCanvas();
564
565 canvas->drawImage(testContext.fImg, 0, 0);
566 testContext.fImg.reset();
567
568 std::unique_ptr<Recording> recording = testContext.fRecorder->snap();
569 // Nothing happens at snap time for volatile images
570 check_all_done(reporter, testContext.fPromiseImageChecker,
571 testContext.fPromiseTextureCheckers, /* expectedFulfillCnt= */ 4);
572
573 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
574 check_fulfilled_ahead_by_one(reporter, testContext.fPromiseImageChecker,
575 testContext.fPromiseTextureCheckers,
576 /* expectedFulfillCnt= */ 5);
577
578 REPORTER_ASSERT(reporter, context->insertRecording({ recording.get() }));
579 check_fulfilled_ahead_by_two(reporter, testContext.fPromiseImageChecker,
580 testContext.fPromiseTextureCheckers,
581 /* expectedFulfillCnt= */ 6);
582 }
583
584 // testContext.fImg no longer holds a ref but the last recordings are still not submitted.
585 check_fulfilled_ahead_by_two(reporter, testContext.fPromiseImageChecker,
586 testContext.fPromiseTextureCheckers,
587 /* expectedFulfillCnt= */ 6);
588
589 testGpuContext->syncedSubmit(context);
590
591 // Now all Releases should definitely have been called.
592 check_all_done(reporter, testContext.fPromiseImageChecker, testContext.fPromiseTextureCheckers,
593 /* expectedFulfillCnt= */ 6);
594
595 for (int i = 0; i < 4; ++i) {
597 testContext.fPromiseTextureCheckers[i].fTextureReleaseCounts[0] == 3);
599 testContext.fPromiseTextureCheckers[i].fTextureReleaseCounts[1] == 3);
600 }
601}

◆ DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS()

DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( NonVolatileGraphiteYUVAPromiseImageCreationFailureTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 461 of file GraphiteYUVAPromiseImageTest.cpp.

464 {
465 // Note: these dimensions are invalid and will cause MakeGraphitePromiseTexture to fail
466 constexpr SkISize kDimensions { 0, 0 };
467
468 TestCtx testContext;
469 setup_test_context(context, reporter, &testContext,
470 kDimensions, Volatile::kNo, /* invalidBackendTex= */ true);
471
472 SkASSERT(!testContext.fImg);
473
474 // Despite MakeGraphitePromiseTexture failing, ImageRelease is called
475 REPORTER_ASSERT(reporter, testContext.fPromiseImageChecker.fImageReleaseCount == 1);
476 for (int i = 0; i < 4; ++i) {
477 REPORTER_ASSERT(reporter, testContext.fPromiseTextureCheckers[i].fFulfillCount == 0);
478 REPORTER_ASSERT(reporter, testContext.fPromiseTextureCheckers[i].totalReleaseCount() == 0);
479 }
480}
#define SkASSERT(cond)
Definition: SkAssert.h:116