Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
ProtectedUtils Namespace Reference

Functions

sk_sp< SkSurfaceCreateProtectedSkSurface (GrDirectContext *dContext, SkISize size, bool textureable, bool isProtected, const SkSurfaceProps *surfaceProps)
 
void CheckImageBEProtection (SkImage *image, bool expectingProtected)
 
sk_sp< SkImageCreateProtectedSkImage (GrDirectContext *dContext, SkISize size, SkColor4f color, bool isProtected)
 
sk_sp< SkSurfaceCreateProtectedSkSurface (Recorder *recorder, SkISize size, Protected isProtected)
 
sk_sp< SkImageCreateProtectedSkImage (Recorder *recorder, SkISize size, SkColor4f color, Protected isProtected)
 

Function Documentation

◆ CheckImageBEProtection()

void ProtectedUtils::CheckImageBEProtection ( SkImage image,
bool  expectingProtected 
)

Definition at line 68 of file ProtectedUtils.cpp.

68 {
69 GrBackendTexture beTex;
70 GrSurfaceOrigin origin;
72 &beTex,
73 /* flushPendingGrContextIO= */ true,
74 &origin);
75 if (!result) {
76 SK_ABORT("GetBackendTextureFromImage failed");
77 return;
78 }
79
80 SkASSERT(beTex.isValid());
81 SkASSERT(beTex.isProtected() == expectingProtected);
82}
GrSurfaceOrigin
Definition GrTypes.h:147
#define SK_ABORT(message,...)
Definition SkAssert.h:70
#define SkASSERT(cond)
Definition SkAssert.h:116
sk_sp< SkImage > image
Definition examples.cpp:29
GAsyncResult * result
SK_API bool GetBackendTextureFromImage(const SkImage *img, GrBackendTexture *outTexture, bool flushPendingGrContextIO, GrSurfaceOrigin *origin=nullptr)

◆ CreateProtectedSkImage() [1/2]

sk_sp< SkImage > ProtectedUtils::CreateProtectedSkImage ( GrDirectContext dContext,
SkISize  size,
SkColor4f  color,
bool  isProtected 
)

Definition at line 84 of file ProtectedUtils.cpp.

87 {
89
90 sk_sp<SkImage> image = sk_gpu_test::MakeBackendTextureImage(dContext,
91 ii,
92 color,
93 skgpu::Mipmapped::kNo,
94 GrRenderable::kNo,
96 skgpu::Protected(isProtected));
97 if (!image) {
98 SK_ABORT("Could not create %s image.", isProtected ? "protected" : "unprotected");
99 return nullptr;
100 }
101
102 CheckImageBEProtection(image.get(), isProtected);
103
104 return image;
105}
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
SkColor4f color
@ 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
T * get() const
Definition SkRefCnt.h:303
Protected
Definition GpuTypes.h:61
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ CreateProtectedSkImage() [2/2]

sk_sp< SkImage > ProtectedUtils::CreateProtectedSkImage ( Recorder recorder,
SkISize  size,
SkColor4f  color,
Protected  isProtected 
)

Definition at line 44 of file ProtectedUtils_Graphite.cpp.

47 {
49
50 sk_sp<SkImage> image = sk_gpu_test::MakeBackendTextureImage(recorder,
51 ii,
52 color,
53 Mipmapped::kNo,
54 Renderable::kNo,
55 Origin::kTopLeft,
56 isProtected);
57 if (!image) {
58 SK_ABORT("Could not create %s image.",
59 isProtected == Protected::kYes ? "protected" : "unprotected");
60 return nullptr;
61 }
62
63 return image;
64}

◆ CreateProtectedSkSurface() [1/2]

sk_sp< SkSurface > ProtectedUtils::CreateProtectedSkSurface ( GrDirectContext dContext,
SkISize  size,
bool  textureable,
bool  isProtected,
const SkSurfaceProps surfaceProps 
)

Definition at line 18 of file ProtectedUtils.cpp.

22 {
24 if (textureable) {
26 size,
28 1,
30 /* colorSpace= */ nullptr,
31 skgpu::Mipmapped::kNo,
32 skgpu::Protected(isProtected),
33 surfaceProps);
34 } else {
36 size,
38 1,
40 /* colorSpace= */ nullptr,
41 skgpu::Protected(isProtected),
42 surfaceProps);
43 }
44 if (!surface) {
45 SK_ABORT("Could not create %s surface.", isProtected ? "protected" : "unprotected");
46 return nullptr;
47 }
48
49 SkCanvas* canvas = surface->getCanvas();
50
51 canvas->clear(SkColors::kBlue);
52
53 if (textureable) {
55 surface.get(), SkSurfaces::BackendHandleAccess::kFlushRead);
56 SkASSERT(backendTex.isValid());
57 SkASSERT(backendTex.isProtected() == isProtected);
58 } else {
60 surface.get(), SkSurfaces::BackendHandleAccess::kFlushRead);
61 SkASSERT(backendRT.isValid());
62 SkASSERT(backendRT.isProtected() == isProtected);
63 }
64
65 return surface;
66}
void clear(SkColor color)
Definition SkCanvas.h:1199
VkSurfaceKHR surface
Definition main.cc:49
constexpr SkColor4f kBlue
Definition SkColor.h:442
SK_API GrBackendTexture GetBackendTexture(SkSurface *, BackendHandleAccess)
SK_API GrBackendRenderTarget GetBackendRenderTarget(SkSurface *, BackendHandleAccess)
sk_sp< SkSurface > MakeBackendRenderTargetSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, GrProtected isProtected, const SkSurfaceProps *props)
sk_sp< SkSurface > MakeBackendTextureSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, const SkSurfaceProps *props)

◆ CreateProtectedSkSurface() [2/2]

sk_sp< SkSurface > ProtectedUtils::CreateProtectedSkSurface ( Recorder recorder,
SkISize  size,
Protected  isProtected 
)

Definition at line 21 of file ProtectedUtils_Graphite.cpp.

23 {
25
27 ii,
28 Mipmapped::kNo,
29 isProtected,
30 /* surfaceProps= */ nullptr);
31 if (!surface) {
32 SK_ABORT("Could not create %s surface.",
33 isProtected == Protected::kYes ? "protected" : "unprotected");
34 return nullptr;
35 }
36
37 SkCanvas* canvas = surface->getCanvas();
38
39 canvas->clear(SkColors::kBlue);
40
41 return surface;
42}