Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrContextOOM.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
13#include "include/core/SkRect.h"
20#include "include/gpu/GrTypes.h"
23#include "tests/Test.h"
25
26DEF_GANESH_TEST(GrContext_oomed, reporter, originalOptions, CtsEnforcement::kApiLevel_T) {
27 GrContextOptions options = originalOptions;
28 options.fRandomGLOOM = true;
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
@ 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 DEF_GANESH_TEST(name, reporter, options, ctsEnforcement)
Definition Test.h:393
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
#define ERRORF(r,...)
Definition Test.h:293
GrDirectContext * get(ContextType type, ContextOverrides overrides=ContextOverrides::kNone)
const Paint & paint
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
static const int kContextTypeCount
Definition ContextType.h:42
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