Flutter Engine
The Flutter Engine
Functions
GrSubmittedFlushTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorType.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/gpu/FenceSync.h"

Go to the source code of this file.

Functions

static void testing_submitted_proc (void *ctx, bool success)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (FlushSubmittedProcTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( FlushSubmittedProcTest  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 41 of file GrSubmittedFlushTest.cpp.

44 {
45 auto ctx = ctxInfo.directContext();
46
49 SkCanvas* canvas = surface->getCanvas();
50
51 canvas->clear(SK_ColorGREEN);
52
53 int submittedCount = 0;
54 bool submittedSuccess = false;
55 SubmittedInfo submittedInfo = { &submittedCount, &submittedSuccess };
56
57 GrFlushInfo flushInfo;
59 flushInfo.fSubmittedContext = &submittedInfo;
60
61 ctx->flush(flushInfo);
62 REPORTER_ASSERT(reporter, submittedCount == 0);
63
64 ctx->submit();
65 REPORTER_ASSERT(reporter, submittedCount == 1);
66 REPORTER_ASSERT(reporter, submittedSuccess);
67
68 // There should be no work so if we flush again the submittedProc should be called immediately
69 ctx->flush(surface.get(), SkSurfaces::BackendSurfaceAccess::kNoAccess, flushInfo);
70 REPORTER_ASSERT(reporter, submittedCount == 2);
71 REPORTER_ASSERT(reporter, submittedSuccess);
72
73 // However, flushing the context we don't do any checks of work so we still require submit to be
74 // called in order for the callback to trigger.
75 ctx->flush(flushInfo);
76 REPORTER_ASSERT(reporter, submittedCount == 2);
77
78 ctx->submit();
79 REPORTER_ASSERT(reporter, submittedCount == 3);
80 REPORTER_ASSERT(reporter, submittedSuccess);
81
82 // Testing that doing multiple flushes before a submit triggers both submittedProcs to be called
83 canvas->clear(SK_ColorBLUE);
84 ctx->flush(surface.get(), SkSurfaces::BackendSurfaceAccess::kNoAccess, flushInfo);
85 REPORTER_ASSERT(reporter, submittedCount == 3);
86 canvas->clear(SK_ColorRED);
87 ctx->flush(surface.get(), SkSurfaces::BackendSurfaceAccess::kNoAccess, flushInfo);
88 REPORTER_ASSERT(reporter, submittedCount == 3);
89 ctx->submit();
90
91 REPORTER_ASSERT(reporter, submittedCount == 5);
92 REPORTER_ASSERT(reporter, submittedSuccess);
93
94 // Test an abandoned context to get a failed submit immediately when flush is called
95 canvas->clear(SK_ColorCYAN);
96 ctx->abandonContext();
97 ctx->flush(surface.get(), SkSurfaces::BackendSurfaceAccess::kNoAccess, flushInfo);
98 REPORTER_ASSERT(reporter, submittedCount == 6);
99 REPORTER_ASSERT(reporter, !submittedSuccess);
100 ctx->flush(flushInfo);
101 REPORTER_ASSERT(reporter, submittedCount == 7);
102 REPORTER_ASSERT(reporter, !submittedSuccess);
103}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
reporter
Definition: FontMgrTest.cpp:39
static void testing_submitted_proc(void *ctx, bool success)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
void clear(SkColor color)
Definition: SkCanvas.h:1199
VkSurfaceKHR surface
Definition: main.cc:49
@ kNoAccess
back-end surface will not be used by client
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
GrGpuSubmittedContext fSubmittedContext
Definition: GrTypes.h:222
GrGpuSubmittedProc fSubmittedProc
Definition: GrTypes.h:221
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ testing_submitted_proc()

static void testing_submitted_proc ( void *  ctx,
bool  success 
)
static

Definition at line 35 of file GrSubmittedFlushTest.cpp.

35 {
36 SubmittedInfo* info = (SubmittedInfo*)ctx;
37 *info->fCount += 1;
38 *info->fSuccess = success;
39}