Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
sk_gpu_test Namespace Reference

Namespaces

namespace  test_ops
 

Classes

class  ContextInfo
 
class  FenceSync
 
class  FlushFinishTracker
 
class  GLTestContext
 
class  GpuTimer
 
class  GrContextFactory
 
class  LazyYUVImage
 
class  MemoryCache
 
class  TestContext
 
class  VkTestMemoryAllocator
 

Typedefs

using Mipmapped = skgpu::Mipmapped
 
using Protected = skgpu::Protected
 
using Renderable = skgpu::Renderable
 
using PlatformFence = uint64_t
 
using PlatformTimerQuery = uint64_t
 

Enumerations

enum class  ANGLEBackend { kD3D9 , kD3D11 , kOpenGL , kMetal }
 
enum class  ANGLEContextVersion { kES2 , kES3 }
 

Functions

GLTestContextCreatePlatformGLTestContext (GrGLStandard forcedGpuAPI, GLTestContext *shareContext)
 
sk_sp< SkSurfaceMakeBackendTextureSurface (GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, const SkSurfaceProps *props)
 
sk_sp< SkSurfaceMakeBackendTextureSurface (GrDirectContext *dContext, SkISize dimensions, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, skgpu::Mipmapped mipmapped, GrProtected isProtected, const SkSurfaceProps *props)
 
sk_sp< SkSurfaceMakeBackendRenderTargetSurface (GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, GrProtected isProtected, const SkSurfaceProps *props)
 
sk_sp< SkSurfaceMakeBackendRenderTargetSurface (GrDirectContext *dContext, SkISize dimensions, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, GrProtected isProtected, const SkSurfaceProps *props)
 
GrTextureProxyGetTextureImageProxy (SkImage *image, GrRecordingContext *rContext)
 
GrSurfaceProxyView MakeTextureProxyViewFromData (GrDirectContext *dContext, GrRenderable renderable, GrSurfaceOrigin origin, GrCPixmap pixmap)
 

Variables

static constexpr PlatformFence kInvalidFence = 0
 
static constexpr PlatformTimerQuery kInvalidTimerQuery = 0
 

Typedef Documentation

◆ Mipmapped

Definition at line 32 of file BackendTextureImageFactory.h.

◆ PlatformFence

using sk_gpu_test::PlatformFence = typedef uint64_t

Definition at line 15 of file FenceSync.h.

◆ PlatformTimerQuery

using sk_gpu_test::PlatformTimerQuery = typedef uint64_t

Definition at line 17 of file GpuTimer.h.

◆ Protected

Definition at line 33 of file BackendTextureImageFactory.h.

◆ Renderable

Definition at line 34 of file BackendTextureImageFactory.h.

Enumeration Type Documentation

◆ ANGLEBackend

enum class sk_gpu_test::ANGLEBackend
strong
Enumerator
kD3D9 
kD3D11 
kOpenGL 
kMetal 

Definition at line 21 of file GLTestContext_angle.h.

21 {
22 kD3D9,
23 kD3D11,
24 kOpenGL,
25 kMetal
26};
@ kOpenGL
Definition embedder.h:80
@ kMetal
Definition embedder.h:85

◆ ANGLEContextVersion

Enumerator
kES2 
kES3 

Definition at line 28 of file GLTestContext_angle.h.

28 {
29 kES2,
30 kES3
31};

Function Documentation

◆ CreatePlatformGLTestContext()

GLTestContext * sk_gpu_test::CreatePlatformGLTestContext ( GrGLStandard  forcedGpuAPI,
GLTestContext shareContext = nullptr 
)

Creates platform-dependent GL context object. The shareContext parameter is in an optional context with which to share display lists. This should be a pointer to an GLTestContext created with SkCreatePlatformGLTestContext. NULL indicates that no sharing is to take place. Returns a valid gl context object or NULL if such can not be created.

Definition at line 340 of file gm_bindings.cpp.

341 {
342 return new WasmWebGlTestContext();
343}

◆ GetTextureImageProxy()

GrTextureProxy * sk_gpu_test::GetTextureImageProxy ( SkImage ,
GrRecordingContext  
)

Returns the proxy backing an image if it is texture backed, otherwise nullptr.

Definition at line 32 of file ProxyUtils.cpp.

32 {
33 if (!as_IB(image)->isGaneshBacked() || as_IB(image)->isYUVA()) {
34 return nullptr;
35 }
36 if (!rContext) {
37 // If the image is backed by a recording context we'll use that.
38 GrImageContext* iContext = as_IB(image)->context();
39 SkASSERT(iContext);
40 rContext = iContext->priv().asRecordingContext();
41 if (!rContext) {
42 return nullptr;
43 }
44 }
45 auto [view, ct] = skgpu::ganesh::AsView(rContext, image, skgpu::Mipmapped::kNo);
46 if (!view) {
47 // With the above checks we expect this to succeed unless there is a context mismatch.
48 SkASSERT(!image->isValid(rContext));
49 return nullptr;
50 }
51 GrSurfaceProxy* proxy = view.proxy();
52 SkASSERT(proxy->asTextureProxy());
53 return proxy->asTextureProxy();
54}
#define SkASSERT(cond)
Definition SkAssert.h:116
static SkImage_Base * as_IB(SkImage *image)
GrRecordingContext * asRecordingContext()
GrImageContextPriv priv()
virtual GrTextureProxy * asTextureProxy()
virtual GrImageContext * context() const
virtual bool isValid(GrRecordingContext *context) const =0
sk_sp< SkImage > image
Definition examples.cpp:29
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)

◆ MakeBackendRenderTargetSurface() [1/2]

sk_sp< SkSurface > sk_gpu_test::MakeBackendRenderTargetSurface ( GrDirectContext ,
const SkImageInfo ,
GrSurfaceOrigin  ,
int  sampleCnt,
GrProtected  = GrProtected::kNo,
const SkSurfaceProps = nullptr 
)

Creates an SkSurface backed by a non-textureable render target.

Definition at line 70 of file BackendSurfaceFactory.cpp.

75 {
77 return nullptr;
78 }
79 auto ct = SkColorTypeToGrColorType(ii.colorType());
80
81 struct ReleaseContext {
83 GrBackendRenderTarget fRenderTarget;
84 };
85
86 auto bert = dContext->priv().getGpu()->createTestingOnlyBackendRenderTarget(
87 ii.dimensions(), ct, sampleCnt, isProtected);
88 auto rc = new ReleaseContext{sk_ref_sp(dContext), bert};
89 SkASSERT(!bert.isValid() || bert.sampleCnt() >= sampleCnt);
90
91 auto proc = [](void* c) {
92 const auto* rc = static_cast<ReleaseContext*>(c);
93 if (auto gpu = rc->fContext->priv().getGpu(); gpu && rc->fRenderTarget.isValid()) {
94 gpu->deleteTestingOnlyBackendRenderTarget(rc->fRenderTarget);
95 }
96 delete rc;
97 };
98
100 dContext, bert, origin, ii.colorType(), ii.refColorSpace(), props, proc, rc);
101}
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
kUnpremul_SkAlphaType
@ kUnknown_SkAlphaType
uninitialized
Definition SkAlphaType.h:27
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
const Context & fContext
GrDirectContextPriv priv()
SK_API sk_sp< SkSurface > WrapBackendRenderTarget(GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
void * ReleaseContext
sk_sp< SkColorSpace > refColorSpace() const
SkISize dimensions() const
SkAlphaType alphaType() const
SkColorType colorType() const

◆ MakeBackendRenderTargetSurface() [2/2]

sk_sp< SkSurface > sk_gpu_test::MakeBackendRenderTargetSurface ( GrDirectContext dContext,
SkISize  dimensions,
GrSurfaceOrigin  origin,
int  sampleCnt,
SkColorType  colorType,
sk_sp< SkColorSpace colorSpace,
GrProtected  isProtected,
const SkSurfaceProps props 
)

Definition at line 103 of file BackendSurfaceFactory.cpp.

110 {
111 auto ii = SkImageInfo::Make(dimensions, colorType, kPremul_SkAlphaType, std::move(colorSpace));
112 return MakeBackendRenderTargetSurface(dContext, ii, origin, sampleCnt, isProtected, props);
113}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
sk_sp< SkSurface > MakeBackendRenderTargetSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, GrProtected isProtected, const SkSurfaceProps *props)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ MakeBackendTextureSurface() [1/2]

sk_sp< SkSurface > sk_gpu_test::MakeBackendTextureSurface ( GrDirectContext dContext,
const SkImageInfo ii,
GrSurfaceOrigin  origin,
int  sampleCnt,
skgpu::Mipmapped  mipmapped,
GrProtected  isProtected,
const SkSurfaceProps props 
)

Definition at line 26 of file BackendSurfaceFactory.cpp.

32 {
33 if (ii.alphaType() == kUnpremul_SkAlphaType) {
34 return nullptr;
35 }
36 auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
37 ii.width(),
38 ii.height(),
39 ii.colorType(),
40 mipmapped,
41 GrRenderable::kYes,
42 isProtected);
43 if (!mbet) {
44 return nullptr;
45 }
46 return SkSurfaces::WrapBackendTexture(dContext,
47 mbet->texture(),
48 origin,
49 sampleCnt,
50 ii.colorType(),
51 ii.refColorSpace(),
52 props,
53 ManagedBackendTexture::ReleaseProc,
54 mbet->releaseContext());
55}
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
int width() const
int height() const

◆ MakeBackendTextureSurface() [2/2]

sk_sp< SkSurface > sk_gpu_test::MakeBackendTextureSurface ( GrDirectContext dContext,
SkISize  dimensions,
GrSurfaceOrigin  origin,
int  sampleCnt,
SkColorType  colorType,
sk_sp< SkColorSpace colorSpace,
skgpu::Mipmapped  mipmapped,
GrProtected  isProtected,
const SkSurfaceProps props 
)

Definition at line 57 of file BackendSurfaceFactory.cpp.

65 {
66 auto ii = SkImageInfo::Make(dimensions, colorType, kPremul_SkAlphaType, std::move(colorSpace));
68 dContext, ii, origin, sampleCnt, mipmapped, isProtected, props);
69}
sk_sp< SkSurface > MakeBackendTextureSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, const SkSurfaceProps *props)

◆ MakeTextureProxyViewFromData()

GrSurfaceProxyView sk_gpu_test::MakeTextureProxyViewFromData ( GrDirectContext ,
GrRenderable  ,
GrSurfaceOrigin  ,
GrCPixmap  pixmap 
)

Makes a texture proxy containing the passed in color data.

Definition at line 56 of file ProxyUtils.cpp.

59 {
60 if (dContext->abandoned()) {
61 return {};
62 }
63
64 const GrCaps* caps = dContext->priv().caps();
65
66 const GrBackendFormat format = caps->getDefaultBackendFormat(pixmap.colorType(), renderable);
67 if (!format.isValid()) {
68 return {};
69 }
70 skgpu::Swizzle swizzle = caps->getReadSwizzle(format, pixmap.colorType());
71
73 proxy = dContext->priv().proxyProvider()->createProxy(format,
74 pixmap.dimensions(),
75 renderable,
76 /*sample count*/ 1,
77 skgpu::Mipmapped::kNo,
80 GrProtected::kNo,
81 /*label=*/"TextureProxyViewFromData");
82 if (!proxy) {
83 return {};
84 }
85 GrSurfaceProxyView view(proxy, origin, swizzle);
86 auto sContext = dContext->priv().makeSC(std::move(view), pixmap.colorInfo());
87 if (!sContext) {
88 return {};
89 }
90 if (!sContext->writePixels(dContext, pixmap, {0, 0})) {
91 return {};
92 }
93 return sContext->readSurfaceView();
94}
const GrCaps * caps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition GrCaps.cpp:400
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
Definition GrCaps.cpp:443
bool abandoned() override
const GrColorInfo & colorInfo() const
Definition GrPixmap.h:18
SkISize dimensions() const
Definition GrPixmap.h:29
GrColorType colorType() const
Definition GrPixmap.h:30
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()
std::unique_ptr< skgpu::ganesh::SurfaceContext > makeSC(GrSurfaceProxyView readView, const GrColorInfo &)
uint32_t uint32_t * format

Variable Documentation

◆ kInvalidFence

constexpr PlatformFence sk_gpu_test::kInvalidFence = 0
staticconstexpr

Definition at line 16 of file FenceSync.h.

◆ kInvalidTimerQuery

constexpr PlatformTimerQuery sk_gpu_test::kInvalidTimerQuery = 0
staticconstexpr

Definition at line 18 of file GpuTimer.h.