Flutter Engine
The Flutter Engine
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
bool isValid() const
bool isProtected() const
GAsyncResult * result
SK_API bool GetBackendTextureFromImage(const SkImage *img, GrBackendTexture *outTexture, bool flushPendingGrContextIO, GrSurfaceOrigin *origin=nullptr)
sk_sp< const SkImage > image
Definition: SkRecords.h:269

◆ 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,
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
@ 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
DlColor color
void CheckImageBEProtection(SkImage *image, bool expectingProtected)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
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,
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,
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) {
56 SkASSERT(backendTex.isValid());
57 SkASSERT(backendTex.isProtected() == isProtected);
58 } else {
61 SkASSERT(backendRT.isValid());
62 SkASSERT(backendRT.isProtected() == isProtected);
63 }
64
65 return surface;
66}
void clear(SkColor color)
Definition: SkCanvas.h:1199
@ kFlushRead
back-end object is readable
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,
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}