Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
ProxyRefTest.cpp File Reference
#include "include/core/SkRefCnt.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include <initializer_list>

Go to the source code of this file.

Functions

static sk_sp< GrTextureProxymake_deferred (GrRecordingContext *rContext)
 
static sk_sp< GrTextureProxymake_wrapped (GrRecordingContext *rContext)
 
 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (ProxyRefTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 

Variables

static const int kWidthHeight = 128
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

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

Definition at line 64 of file ProxyRefTest.cpp.

67 {
68 auto dContext = ctxInfo.directContext();
69 GrResourceProvider* resourceProvider = dContext->priv().resourceProvider();
70
71 for (auto make : { make_deferred, make_wrapped }) {
72 // An extra ref
73 {
74 sk_sp<GrTextureProxy> proxy((*make)(dContext));
75 if (proxy) {
76 sk_sp<GrTextureProxy> extraRef(proxy); // NOLINT(performance-unnecessary-copy-initialization)
77
78 int backingRefs = proxy->isInstantiated() ? 1 : -1;
79
80 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 2, backingRefs);
81
82 proxy->instantiate(resourceProvider);
83
84 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 2, 1);
85 }
86 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 1, 1);
87 }
88
89 // Multiple normal refs
90 {
91 sk_sp<GrTextureProxy> proxy((*make)(dContext));
92 if (proxy) {
93 proxy->ref();
94 proxy->ref();
95
96 int backingRefs = proxy->isInstantiated() ? 1 : -1;
97
98 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 3, backingRefs);
99
100 proxy->instantiate(resourceProvider);
101
102 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 3, 1);
103
104 proxy->unref();
105 proxy->unref();
106 }
107 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 1, 1);
108 }
109
110 // Continue using (reffing) proxy after instantiation
111 {
112 sk_sp<GrTextureProxy> proxy((*make)(dContext));
113 if (proxy) {
114 sk_sp<GrTextureProxy> firstExtraRef(proxy); // NOLINT(performance-unnecessary-copy-initialization)
115
116 int backingRefs = proxy->isInstantiated() ? 1 : -1;
117
118 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 2, backingRefs);
119
120 proxy->instantiate(resourceProvider);
121
122 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 2, 1);
123
124 sk_sp<GrTextureProxy> secondExtraRef(proxy); // NOLINT(performance-unnecessary-copy-initialization)
125 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 3, 1);
126 }
127 CheckSingleThreadedProxyRefs(reporter, proxy.get(), 1, 1);
128 }
129 }
130}
reporter
static sk_sp< GrTextureProxy > make_wrapped(GrRecordingContext *rContext)
static sk_sp< GrTextureProxy > make_deferred(GrRecordingContext *rContext)
void CheckSingleThreadedProxyRefs(skiatest::Reporter *reporter, GrSurfaceProxy *proxy, int32_t expectedProxyRefs, int32_t expectedBackingRefs)
GrResourceProviderPriv priv()
static sk_sp< SkImage > make(sk_sp< SkColorSpace > cs)
Definition mipmap.cpp:65

◆ make_deferred()

static sk_sp< GrTextureProxy > make_deferred ( GrRecordingContext rContext)
static

Definition at line 35 of file ProxyRefTest.cpp.

35 {
36 GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
37 const GrCaps* caps = rContext->priv().caps();
38
40 GrRenderable::kYes);
41 return proxyProvider->createProxy(format,
43 GrRenderable::kYes,
44 1,
45 skgpu::Mipmapped::kNo,
48 GrProtected::kNo,
49 /*label=*/"ProxyRefTest");
50}
static const int kWidthHeight
const GrCaps * caps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition GrCaps.cpp:400
sk_sp< GrTextureProxy > createProxy(const GrBackendFormat &, SkISize dimensions, GrRenderable, int renderTargetSampleCnt, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, GrProtected, std::string_view label, GrInternalSurfaceFlags=GrInternalSurfaceFlags::kNone, UseAllocator useAllocator=UseAllocator::kYes)
GrProxyProvider * proxyProvider()
GrRecordingContextPriv priv()
uint32_t uint32_t * format

◆ make_wrapped()

static sk_sp< GrTextureProxy > make_wrapped ( GrRecordingContext rContext)
static

Definition at line 52 of file ProxyRefTest.cpp.

52 {
53 GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
54
55 return proxyProvider->testingOnly_createInstantiatedProxy({kWidthHeight, kWidthHeight},
57 GrRenderable::kYes,
58 1,
61 GrProtected::kNo);
62}

Variable Documentation

◆ kWidthHeight

const int kWidthHeight = 128
static

Definition at line 33 of file ProxyRefTest.cpp.