Flutter Engine
The Flutter Engine
Functions | Variables
SurfaceDrawContextTest.cpp File Reference
#include "include/core/SkColorSpace.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrPixmap.h"
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include <memory>

Go to the source code of this file.

Functions

static std::unique_ptr< skgpu::ganesh::SurfaceDrawContextget_sdc (GrRecordingContext *rContext)
 
static void check_instantiation_status (skiatest::Reporter *reporter, skgpu::ganesh::SurfaceDrawContext *sdc, bool wrappedExpectation)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (SurfaceDrawContextTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 

Variables

static const int kSize = 64
 

Function Documentation

◆ check_instantiation_status()

static void check_instantiation_status ( skiatest::Reporter reporter,
skgpu::ganesh::SurfaceDrawContext sdc,
bool  wrappedExpectation 
)
static

Definition at line 42 of file SurfaceDrawContextTest.cpp.

44 {
45 REPORTER_ASSERT(reporter, sdc->asRenderTargetProxy()->isInstantiated() == wrappedExpectation);
46
47 GrTextureProxy* tProxy = sdc->asTextureProxy();
49
50 REPORTER_ASSERT(reporter, tProxy->isInstantiated() == wrappedExpectation);
51}
reporter
Definition: FontMgrTest.cpp:39
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
bool isInstantiated() const
GrRenderTargetProxy * asRenderTargetProxy()
GrTextureProxy * asTextureProxy()

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

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

Definition at line 53 of file SurfaceDrawContextTest.cpp.

56 {
57 auto dContext = ctxInfo.directContext();
58
59 // Calling instantiate on a SurfaceDrawContext's textureProxy also instantiates the
60 // SurfaceDrawContext
61 {
62 auto sdc = get_sdc(dContext);
63
64 check_instantiation_status(reporter, sdc.get(), false);
65
66 GrTextureProxy* tProxy = sdc->asTextureProxy();
68
69 REPORTER_ASSERT(reporter, tProxy->instantiate(dContext->priv().resourceProvider()));
70
71 check_instantiation_status(reporter, sdc.get(), true);
72 }
73
74 // readPixels switches a deferred sdCtx to wrapped
75 {
76 auto sdc = get_sdc(dContext);
77
78 check_instantiation_status(reporter, sdc.get(), false);
79
81 GrPixmap dstPM = GrPixmap::Allocate(dstInfo);
82
83 bool result = sdc->readPixels(dContext, dstPM, {0, 0});
85
86 check_instantiation_status(reporter, sdc.get(), true);
87 }
88
89 // TODO: in a future world we should be able to add a test that the majority of
90 // SurfaceDrawContext calls do not force the instantiation of a deferred
91 // SurfaceDrawContext
92}
static void check_instantiation_status(skiatest::Reporter *reporter, skgpu::ganesh::SurfaceDrawContext *sdc, bool wrappedExpectation)
static const int kSize
static std::unique_ptr< skgpu::ganesh::SurfaceDrawContext > get_sdc(GrRecordingContext *rContext)
static GrPixmap Allocate(const GrImageInfo &info)
Definition: GrPixmap.h:101
bool instantiate(GrResourceProvider *) override
GrTextureProxy * asTextureProxy() override
GAsyncResult * result
static SkImageInfo MakeN32Premul(int width, int height)

◆ get_sdc()

static std::unique_ptr< skgpu::ganesh::SurfaceDrawContext > get_sdc ( GrRecordingContext rContext)
static

Definition at line 32 of file SurfaceDrawContextTest.cpp.

32 {
35 nullptr,
37 {kSize, kSize},
39 /*label=*/{});
40}
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)

Variable Documentation

◆ kSize

const int kSize = 64
static

Definition at line 30 of file SurfaceDrawContextTest.cpp.