Flutter Engine
The Flutter Engine
Functions
GrContextOOM.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorType.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrContextOptions.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/ContextType.h"

Go to the source code of this file.

Functions

 DEF_GANESH_TEST (GrContext_oomed, reporter, originalOptions, CtsEnforcement::kApiLevel_T)
 

Function Documentation

◆ DEF_GANESH_TEST()

DEF_GANESH_TEST ( GrContext_oomed  ,
reporter  ,
originalOptions  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 26 of file GrContextOOM.cpp.

26 {
27 GrContextOptions options = originalOptions;
28 options.fRandomGLOOM = true;
29 options.fSkipGLErrorChecks = GrContextOptions::Enable::kNo;
31 for (int ct = 0; ct < skgpu::kContextTypeCount; ++ct) {
32 auto contextType = static_cast<skgpu::ContextType>(ct);
33 auto context = factory.get(contextType);
34 if (!context) {
35 continue;
36 }
37 if (context->backend() != GrBackendApi::kOpenGL) {
38 continue;
39 }
41 for (int run = 0; run < 20; ++run) {
42 bool oomed = false;
43 for (int i = 0; i < 500; ++i) {
44 // Make sure we're actually making a significant number of GL calls and not just
45 // issuing a small number calls by reusing scratch resources created in a previous
46 // iteration.
47 context->freeGpuResources();
48 auto surf =
51 surf->getCanvas()->drawRect(SkRect::MakeLTRB(100, 100, 2000, 2000), paint);
52 context->flushAndSubmit(surf.get(), GrSyncCpu::kNo);
53 if ((oomed = context->oomed())) {
54 REPORTER_ASSERT(reporter, !context->oomed(), "oomed() wasn't cleared");
55 break;
56 }
57 }
58 if (!oomed) {
59 ERRORF(reporter, "Did not OOM on %dth run.", run);
60 }
61 }
62 }
63}
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
reporter
Definition: FontMgrTest.cpp:39
@ 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
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
#define ERRORF(r,...)
Definition: Test.h:293
const Paint & paint
Definition: color_source.cc:38
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)
Definition: run.py:1
def run(cmd)
Definition: run.py:14
static const int kContextTypeCount
Definition: ContextType.h:42
ContextType
Definition: ContextType.h:19
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646