Flutter Engine
The Flutter Engine
ProtectedUtils.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
15
16namespace ProtectedUtils {
17
20 bool textureable,
21 bool isProtected,
22 const SkSurfaceProps* surfaceProps) {
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}
67
68void CheckImageBEProtection(SkImage* image, bool expectingProtected) {
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}
83
87 bool isProtected) {
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}
106
107} // namespace ProtectedUtils
GrSurfaceOrigin
Definition: GrTypes.h:147
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
bool isValid() const
bool isProtected() const
void clear(SkColor color)
Definition: SkCanvas.h:1199
@ kFlushRead
back-end object is readable
T * get() const
Definition: SkRefCnt.h:303
DlColor color
VkSurfaceKHR surface
Definition: main.cc:49
GAsyncResult * result
sk_sp< SkSurface > CreateProtectedSkSurface(GrDirectContext *dContext, SkISize size, bool textureable, bool isProtected, const SkSurfaceProps *surfaceProps)
sk_sp< SkImage > CreateProtectedSkImage(GrDirectContext *dContext, SkISize size, SkColor4f color, bool isProtected)
void CheckImageBEProtection(SkImage *image, bool expectingProtected)
constexpr SkColor4f kBlue
Definition: SkColor.h:442
SK_API bool GetBackendTextureFromImage(const SkImage *img, GrBackendTexture *outTexture, bool flushPendingGrContextIO, GrSurfaceOrigin *origin=nullptr)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SK_API GrBackendTexture GetBackendTexture(SkSurface *, BackendHandleAccess)
SK_API GrBackendRenderTarget GetBackendRenderTarget(SkSurface *, BackendHandleAccess)
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
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)
Protected
Definition: GpuTypes.h:61
Definition: SkSize.h:16
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)