Flutter Engine
The Flutter Engine
Functions
ProcessorTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkColorType.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/private/SkColorData.h"
#include "include/private/SkSLSampleUsage.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkTArray.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkRandom.h"
#include "src/gpu/KeyBuilder.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrAppliedClip.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/GrImageInfo.h"
#include "src/gpu/ganesh/GrPixmap.h"
#include "src/gpu/ganesh/GrProcessorAnalysis.h"
#include "src/gpu/ganesh/GrProcessorSet.h"
#include "src/gpu/ganesh/GrProcessorUnitTest.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/GrUserStencilSettings.h"
#include "src/gpu/ganesh/SkGr.h"
#include "src/gpu/ganesh/SurfaceContext.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
#include "src/gpu/ganesh/effects/GrTextureEffect.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ganesh/ops/GrMeshDrawOp.h"
#include "src/gpu/ganesh/ops/GrOp.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tests/TestHarness.h"
#include "tests/TestUtils.h"
#include "tools/EncodeUtils.h"
#include "tools/flags/CommandLineFlags.h"
#include <algorithm>
#include <atomic>
#include <cmath>
#include <cstdint>
#include <initializer_list>
#include <memory>
#include <random>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

Go to the source code of this file.

Functions

 DEF_GANESH_TEST_FOR_ALL_CONTEXTS (ProcessorRefTest, reporter, ctxInfo, CtsEnforcement::kNever)
 
static DEFINE_bool (randomProcessorTest, false, "Use non-deterministic seed for random processor tests?")
 
static DEFINE_int (processorSeed, 0, "Use specific seed for processor tests. Overridden by --randomProcessorTest.")
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_ALL_CONTEXTS()

DEF_GANESH_TEST_FOR_ALL_CONTEXTS ( ProcessorRefTest  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kNever   
)

Definition at line 201 of file ProcessorTest.cpp.

201 {
202 auto dContext = ctxInfo.directContext();
203 GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
204
205 static constexpr SkISize kDims = {10, 10};
206
207 const GrBackendFormat format =
208 dContext->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
210 skgpu::Swizzle swizzle = dContext->priv().caps()->getReadSwizzle(format,
212
213 for (bool makeClone : {false, true}) {
214 for (int parentCnt = 0; parentCnt < 2; parentCnt++) {
215 auto sdc = skgpu::ganesh::SurfaceDrawContext::Make(dContext,
217 nullptr,
219 {1, 1},
221 /*label=*/{});
222 {
224 proxyProvider->createProxy(format,
225 kDims,
227 1,
232 /*label=*/"ProcessorRefTest");
233
234 {
236 views.push_back({proxy, kTopLeft_GrSurfaceOrigin, swizzle});
237 auto fp = TestFP::Make(std::move(views));
238 for (int i = 0; i < parentCnt; ++i) {
239 fp = TestFP::Make(std::move(fp));
240 }
241 std::unique_ptr<GrFragmentProcessor> clone;
242 if (makeClone) {
243 clone = fp->clone();
244 }
245 GrOp::Owner op = TestOp::Make(dContext, std::move(fp));
246 sdc->addDrawOp(std::move(op));
247 if (clone) {
248 op = TestOp::Make(dContext, std::move(clone));
249 sdc->addDrawOp(std::move(op));
250 }
251 }
252
253 // If the fp is cloned the number of refs should increase by one (for the clone)
254 int expectedProxyRefs = makeClone ? 3 : 2;
255
256 CheckSingleThreadedProxyRefs(reporter, proxy.get(), expectedProxyRefs, -1);
257
258 dContext->flushAndSubmit();
259
260 // just one from the 'proxy' sk_sp
262 }
263 }
264 }
265}
reporter
Definition: FontMgrTest.cpp:39
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
void CheckSingleThreadedProxyRefs(skiatest::Reporter *reporter, GrSurfaceProxy *proxy, int32_t expectedProxyRefs, int32_t expectedBackingRefs)
Definition: TestUtils.cpp:231
std::unique_ptr< GrOp > Owner
Definition: GrOp.h:72
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)
T * get() const
Definition: SkRefCnt.h:303
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
uint32_t uint32_t * format
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
const uint32_t fp
Definition: SkSize.h:16

◆ DEFINE_bool()

static DEFINE_bool ( randomProcessorTest  ,
false  ,
"Use non-deterministic seed for random processor tests?"   
)
static

◆ DEFINE_int()

static DEFINE_int ( processorSeed  ,
,
"Use specific seed for processor tests. Overridden by --randomProcessorTest."   
)
static