1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2019 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci// This is a Vulkan protected memory specific test.
9cb93a386Sopenharmony_ci
10cb93a386Sopenharmony_ci#include "include/core/SkTypes.h"
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_ci#if SK_SUPPORT_GPU && defined(SK_VULKAN)
13cb93a386Sopenharmony_ci
14cb93a386Sopenharmony_ci#include "include/core/SkCanvas.h"
15cb93a386Sopenharmony_ci#include "include/core/SkMaskFilter.h"
16cb93a386Sopenharmony_ci#include "include/core/SkPaint.h"
17cb93a386Sopenharmony_ci#include "include/core/SkSurface.h"
18cb93a386Sopenharmony_ci#include "include/gpu/GrBackendSurface.h"
19cb93a386Sopenharmony_ci#include "include/gpu/vk/GrVkBackendContext.h"
20cb93a386Sopenharmony_ci#include "include/gpu/vk/GrVkExtensions.h"
21cb93a386Sopenharmony_ci#include "tests/Test.h"
22cb93a386Sopenharmony_ci#include "tools/gpu/BackendSurfaceFactory.h"
23cb93a386Sopenharmony_ci#include "tools/gpu/GrContextFactory.h"
24cb93a386Sopenharmony_ci#include "tools/gpu/vk/VkTestHelper.h"
25cb93a386Sopenharmony_ci
26cb93a386Sopenharmony_cistatic sk_sp<SkSurface> create_protected_sksurface(GrDirectContext* dContext,
27cb93a386Sopenharmony_ci                                                   skiatest::Reporter* reporter,
28cb93a386Sopenharmony_ci                                                   bool textureable = true) {
29cb93a386Sopenharmony_ci    const int kW = 8;
30cb93a386Sopenharmony_ci    const int kH = 8;
31cb93a386Sopenharmony_ci    SkSurfaceProps surfaceProps = SkSurfaceProps(0, kRGB_H_SkPixelGeometry);
32cb93a386Sopenharmony_ci    sk_sp<SkSurface> surface;
33cb93a386Sopenharmony_ci    if (textureable) {
34cb93a386Sopenharmony_ci        surface = sk_gpu_test::MakeBackendTextureSurface(dContext,
35cb93a386Sopenharmony_ci                                                         {kW, kH},
36cb93a386Sopenharmony_ci                                                         kTopLeft_GrSurfaceOrigin,
37cb93a386Sopenharmony_ci                                                         1,
38cb93a386Sopenharmony_ci                                                         kRGBA_8888_SkColorType,
39cb93a386Sopenharmony_ci                                                         /* color space */ nullptr,
40cb93a386Sopenharmony_ci                                                         GrMipmapped::kNo,
41cb93a386Sopenharmony_ci                                                         GrProtected::kYes,
42cb93a386Sopenharmony_ci                                                         &surfaceProps);
43cb93a386Sopenharmony_ci    } else {
44cb93a386Sopenharmony_ci        surface = sk_gpu_test::MakeBackendRenderTargetSurface(dContext,
45cb93a386Sopenharmony_ci                                                              {kW, kH},
46cb93a386Sopenharmony_ci                                                              kTopLeft_GrSurfaceOrigin,
47cb93a386Sopenharmony_ci                                                              1,
48cb93a386Sopenharmony_ci                                                              kRGBA_8888_SkColorType,
49cb93a386Sopenharmony_ci                                                              /* color space */ nullptr,
50cb93a386Sopenharmony_ci                                                              GrProtected::kYes,
51cb93a386Sopenharmony_ci                                                              &surfaceProps);
52cb93a386Sopenharmony_ci    }
53cb93a386Sopenharmony_ci    if (!surface) {
54cb93a386Sopenharmony_ci        ERRORF(reporter, "Could not create protected surface.");
55cb93a386Sopenharmony_ci        return nullptr;
56cb93a386Sopenharmony_ci    }
57cb93a386Sopenharmony_ci    if (textureable) {
58cb93a386Sopenharmony_ci        GrBackendTexture backendTex =
59cb93a386Sopenharmony_ci                surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess);
60cb93a386Sopenharmony_ci        REPORTER_ASSERT(reporter, backendTex.isValid());
61cb93a386Sopenharmony_ci        REPORTER_ASSERT(reporter, backendTex.isProtected());
62cb93a386Sopenharmony_ci    } else {
63cb93a386Sopenharmony_ci        GrBackendRenderTarget backendRT =
64cb93a386Sopenharmony_ci                surface->getBackendRenderTarget(SkSurface::kFlushRead_BackendHandleAccess);
65cb93a386Sopenharmony_ci        REPORTER_ASSERT(reporter, backendRT.isValid());
66cb93a386Sopenharmony_ci        REPORTER_ASSERT(reporter, backendRT.isProtected());
67cb93a386Sopenharmony_ci    }
68cb93a386Sopenharmony_ci    return surface;
69cb93a386Sopenharmony_ci}
70cb93a386Sopenharmony_ci
71cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_CreateNonprotectedContext, reporter, options) {
72cb93a386Sopenharmony_ci    auto nonprotectedTestHelper = std::make_unique<VkTestHelper>(false);
73cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, nonprotectedTestHelper->init());
74cb93a386Sopenharmony_ci}
75cb93a386Sopenharmony_ci
76cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_CreateProtectedContext, reporter, options) {
77cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
78cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
79cb93a386Sopenharmony_ci        return;
80cb93a386Sopenharmony_ci    }
81cb93a386Sopenharmony_ci}
82cb93a386Sopenharmony_ci
83cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_CreateProtectedSkSurface, reporter, options) {
84cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
85cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
86cb93a386Sopenharmony_ci        return;
87cb93a386Sopenharmony_ci    }
88cb93a386Sopenharmony_ci
89cb93a386Sopenharmony_ci    auto dContext = protectedTestHelper->directContext();
90cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, dContext != nullptr);
91cb93a386Sopenharmony_ci    create_protected_sksurface(dContext, reporter, /*textureable*/ true);
92cb93a386Sopenharmony_ci    create_protected_sksurface(dContext, reporter, /*textureable*/ false);
93cb93a386Sopenharmony_ci}
94cb93a386Sopenharmony_ci
95cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_CreateNonprotectedTextureInProtectedContext, reporter, options) {
96cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
97cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
98cb93a386Sopenharmony_ci        return;
99cb93a386Sopenharmony_ci    }
100cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
101cb93a386Sopenharmony_ci
102cb93a386Sopenharmony_ci    const int kW = 8;
103cb93a386Sopenharmony_ci    const int kH = 8;
104cb93a386Sopenharmony_ci    GrBackendTexture backendTex =
105cb93a386Sopenharmony_ci        protectedTestHelper->directContext()->createBackendTexture(
106cb93a386Sopenharmony_ci            kW, kH, kRGBA_8888_SkColorType, GrMipmapped::kNo, GrRenderable::kNo,
107cb93a386Sopenharmony_ci            GrProtected::kNo);
108cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, !backendTex.isValid());
109cb93a386Sopenharmony_ci}
110cb93a386Sopenharmony_ci
111cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_CreateProtectedTextureInNonprotectedContext, reporter, options) {
112cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(false);
113cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
114cb93a386Sopenharmony_ci        return;
115cb93a386Sopenharmony_ci    }
116cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
117cb93a386Sopenharmony_ci
118cb93a386Sopenharmony_ci    const int kW = 8;
119cb93a386Sopenharmony_ci    const int kH = 8;
120cb93a386Sopenharmony_ci    GrBackendTexture backendTex =
121cb93a386Sopenharmony_ci        protectedTestHelper->directContext()->createBackendTexture(
122cb93a386Sopenharmony_ci            kW, kH, kRGBA_8888_SkColorType, GrMipmapped::kNo, GrRenderable::kNo,
123cb93a386Sopenharmony_ci            GrProtected::kYes);
124cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, !backendTex.isValid());
125cb93a386Sopenharmony_ci}
126cb93a386Sopenharmony_ci
127cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_ReadFromProtectedSurface, reporter, options) {
128cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
129cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
130cb93a386Sopenharmony_ci        return;
131cb93a386Sopenharmony_ci    }
132cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
133cb93a386Sopenharmony_ci
134cb93a386Sopenharmony_ci    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
135cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface);
136cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, !surface->readPixels(SkImageInfo(), nullptr, 8, 0, 0));
137cb93a386Sopenharmony_ci}
138cb93a386Sopenharmony_ci
139cb93a386Sopenharmony_cinamespace {
140cb93a386Sopenharmony_ci
141cb93a386Sopenharmony_cistruct AsyncContext {
142cb93a386Sopenharmony_ci    bool fCalled = false;
143cb93a386Sopenharmony_ci    std::unique_ptr<const SkSurface::AsyncReadResult> fResult;
144cb93a386Sopenharmony_ci};
145cb93a386Sopenharmony_ci
146cb93a386Sopenharmony_cistatic void async_callback(void* c, std::unique_ptr<const SkSurface::AsyncReadResult> result) {
147cb93a386Sopenharmony_ci    auto context = static_cast<AsyncContext*>(c);
148cb93a386Sopenharmony_ci    context->fResult = std::move(result);
149cb93a386Sopenharmony_ci    context->fCalled = true;
150cb93a386Sopenharmony_ci};
151cb93a386Sopenharmony_ci
152cb93a386Sopenharmony_ci}  // anonymous namespace
153cb93a386Sopenharmony_ci
154cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_AsyncReadFromProtectedSurface, reporter, options) {
155cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
156cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
157cb93a386Sopenharmony_ci        return;
158cb93a386Sopenharmony_ci    }
159cb93a386Sopenharmony_ci
160cb93a386Sopenharmony_ci    auto dContext = protectedTestHelper->directContext();
161cb93a386Sopenharmony_ci
162cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, dContext != nullptr);
163cb93a386Sopenharmony_ci
164cb93a386Sopenharmony_ci    auto surface = create_protected_sksurface(dContext, reporter);
165cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface);
166cb93a386Sopenharmony_ci    AsyncContext cbContext;
167cb93a386Sopenharmony_ci    const auto image_info = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
168cb93a386Sopenharmony_ci                                      SkColorSpace::MakeSRGB());
169cb93a386Sopenharmony_ci    surface->asyncRescaleAndReadPixelsYUV420(kIdentity_SkYUVColorSpace, SkColorSpace::MakeSRGB(),
170cb93a386Sopenharmony_ci                                             image_info.bounds(), image_info.dimensions(),
171cb93a386Sopenharmony_ci                                             SkSurface::RescaleGamma::kSrc,
172cb93a386Sopenharmony_ci                                             SkSurface::RescaleMode::kNearest,
173cb93a386Sopenharmony_ci                                             &async_callback, &cbContext);
174cb93a386Sopenharmony_ci    dContext->submit();
175cb93a386Sopenharmony_ci    while (!cbContext.fCalled) {
176cb93a386Sopenharmony_ci        dContext->checkAsyncWorkCompletion();
177cb93a386Sopenharmony_ci    }
178cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, !cbContext.fResult);
179cb93a386Sopenharmony_ci}
180cb93a386Sopenharmony_ci
181cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_DrawRectangle, reporter, options) {
182cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
183cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
184cb93a386Sopenharmony_ci        return;
185cb93a386Sopenharmony_ci    }
186cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
187cb93a386Sopenharmony_ci
188cb93a386Sopenharmony_ci    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
189cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface);
190cb93a386Sopenharmony_ci    SkCanvas* canvas = surface->getCanvas();
191cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, canvas);
192cb93a386Sopenharmony_ci    SkPaint paint;
193cb93a386Sopenharmony_ci    paint.setColor(SK_ColorBLACK);
194cb93a386Sopenharmony_ci    canvas->drawRect(SkRect::MakeWH(4, 4), paint);
195cb93a386Sopenharmony_ci}
196cb93a386Sopenharmony_ci
197cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_DrawRectangleWithAntiAlias, reporter, options) {
198cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
199cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
200cb93a386Sopenharmony_ci        return;
201cb93a386Sopenharmony_ci    }
202cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
203cb93a386Sopenharmony_ci
204cb93a386Sopenharmony_ci    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
205cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface);
206cb93a386Sopenharmony_ci    SkCanvas* canvas = surface->getCanvas();
207cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, canvas);
208cb93a386Sopenharmony_ci    SkPaint paint;
209cb93a386Sopenharmony_ci    paint.setColor(SK_ColorBLACK);
210cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
211cb93a386Sopenharmony_ci    canvas->drawRect(SkRect::MakeWH(4, 4), paint);
212cb93a386Sopenharmony_ci}
213cb93a386Sopenharmony_ci
214cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_DrawRectangleWithBlendMode, reporter, options) {
215cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
216cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
217cb93a386Sopenharmony_ci        return;
218cb93a386Sopenharmony_ci    }
219cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
220cb93a386Sopenharmony_ci
221cb93a386Sopenharmony_ci    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
222cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface);
223cb93a386Sopenharmony_ci    SkCanvas* canvas = surface->getCanvas();
224cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, canvas);
225cb93a386Sopenharmony_ci    SkPaint paint;
226cb93a386Sopenharmony_ci    paint.setColor(SK_ColorBLACK);
227cb93a386Sopenharmony_ci    paint.setBlendMode(SkBlendMode::kColorDodge);
228cb93a386Sopenharmony_ci    canvas->drawRect(SkRect::MakeWH(4, 4), paint);
229cb93a386Sopenharmony_ci}
230cb93a386Sopenharmony_ci
231cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_DrawRectangleWithFilter, reporter, options) {
232cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
233cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
234cb93a386Sopenharmony_ci        return;
235cb93a386Sopenharmony_ci    }
236cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
237cb93a386Sopenharmony_ci
238cb93a386Sopenharmony_ci    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
239cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface);
240cb93a386Sopenharmony_ci    SkCanvas* canvas = surface->getCanvas();
241cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, canvas);
242cb93a386Sopenharmony_ci    SkPaint paint;
243cb93a386Sopenharmony_ci    paint.setColor(SK_ColorBLACK);
244cb93a386Sopenharmony_ci    paint.setStyle(SkPaint::kFill_Style);
245cb93a386Sopenharmony_ci    paint.setMaskFilter(SkMaskFilter::MakeBlur(
246cb93a386Sopenharmony_ci          SkBlurStyle::kOuter_SkBlurStyle, 1.1f));
247cb93a386Sopenharmony_ci    canvas->drawRect(SkRect::MakeWH(4, 4), paint);
248cb93a386Sopenharmony_ci}
249cb93a386Sopenharmony_ci
250cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_DrawThinPath, reporter, options) {
251cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
252cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
253cb93a386Sopenharmony_ci        return;
254cb93a386Sopenharmony_ci    }
255cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
256cb93a386Sopenharmony_ci
257cb93a386Sopenharmony_ci    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
258cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface);
259cb93a386Sopenharmony_ci    SkCanvas* canvas = surface->getCanvas();
260cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, canvas);
261cb93a386Sopenharmony_ci    SkPaint paint;
262cb93a386Sopenharmony_ci    paint.setColor(SK_ColorBLACK);
263cb93a386Sopenharmony_ci    paint.setStyle(SkPaint::kStroke_Style);
264cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
265cb93a386Sopenharmony_ci    paint.setStrokeWidth(.4f);
266cb93a386Sopenharmony_ci    canvas->drawPath(SkPath().moveTo(4, 4).lineTo(6, 6), paint);
267cb93a386Sopenharmony_ci}
268cb93a386Sopenharmony_ci
269cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_SaveLayer, reporter, options) {
270cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
271cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
272cb93a386Sopenharmony_ci        return;
273cb93a386Sopenharmony_ci    }
274cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
275cb93a386Sopenharmony_ci
276cb93a386Sopenharmony_ci    auto surface = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
277cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface);
278cb93a386Sopenharmony_ci    SkCanvas* canvas = surface->getCanvas();
279cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, canvas);
280cb93a386Sopenharmony_ci    canvas->saveLayer(nullptr, nullptr);
281cb93a386Sopenharmony_ci    SkPaint paint;
282cb93a386Sopenharmony_ci    paint.setColor(SK_ColorBLACK);
283cb93a386Sopenharmony_ci    canvas->drawRect(SkRect::MakeWH(4, 4), paint);
284cb93a386Sopenharmony_ci    canvas->restore();
285cb93a386Sopenharmony_ci}
286cb93a386Sopenharmony_ci
287cb93a386Sopenharmony_ci
288cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_DrawProtectedImageOnProtectedSurface, reporter, options) {
289cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
290cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
291cb93a386Sopenharmony_ci        return;
292cb93a386Sopenharmony_ci    }
293cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
294cb93a386Sopenharmony_ci
295cb93a386Sopenharmony_ci    // Create protected image.
296cb93a386Sopenharmony_ci    auto surface1 = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
297cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface1);
298cb93a386Sopenharmony_ci    auto image = surface1->makeImageSnapshot();
299cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, image);
300cb93a386Sopenharmony_ci
301cb93a386Sopenharmony_ci    // Create protected canvas.
302cb93a386Sopenharmony_ci    auto surface2 = create_protected_sksurface(protectedTestHelper->directContext(), reporter);
303cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, surface2);
304cb93a386Sopenharmony_ci    SkCanvas* canvas = surface2->getCanvas();
305cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, canvas);
306cb93a386Sopenharmony_ci
307cb93a386Sopenharmony_ci    canvas->drawImage(image, 0, 0);
308cb93a386Sopenharmony_ci}
309cb93a386Sopenharmony_ci
310cb93a386Sopenharmony_ci//////////////////////////////////////////////////////////////////////////////////////////////////
311cb93a386Sopenharmony_ci// Test out DDLs using a protected Vulkan context
312cb93a386Sopenharmony_ci
313cb93a386Sopenharmony_civoid DDLMakeRenderTargetTestImpl(GrDirectContext*, skiatest::Reporter*);
314cb93a386Sopenharmony_ci
315cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_DDLMakeRenderTargetTest, reporter, ctxInfo) {
316cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
317cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
318cb93a386Sopenharmony_ci        return;
319cb93a386Sopenharmony_ci    }
320cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
321cb93a386Sopenharmony_ci
322cb93a386Sopenharmony_ci    DDLMakeRenderTargetTestImpl(protectedTestHelper->directContext(), reporter);
323cb93a386Sopenharmony_ci}
324cb93a386Sopenharmony_ci
325cb93a386Sopenharmony_civoid DDLSurfaceCharacterizationTestImpl(GrDirectContext*, skiatest::Reporter*);
326cb93a386Sopenharmony_ci
327cb93a386Sopenharmony_ciDEF_GPUTEST(VkProtectedContext_DDLSurfaceCharacterizationTest, reporter, ctxInfo) {
328cb93a386Sopenharmony_ci    auto protectedTestHelper = std::make_unique<VkTestHelper>(true);
329cb93a386Sopenharmony_ci    if (!protectedTestHelper->init()) {
330cb93a386Sopenharmony_ci        return;
331cb93a386Sopenharmony_ci    }
332cb93a386Sopenharmony_ci    REPORTER_ASSERT(reporter, protectedTestHelper->directContext() != nullptr);
333cb93a386Sopenharmony_ci
334cb93a386Sopenharmony_ci    DDLSurfaceCharacterizationTestImpl(protectedTestHelper->directContext(), reporter);
335cb93a386Sopenharmony_ci}
336cb93a386Sopenharmony_ci
337cb93a386Sopenharmony_ci#endif  // SK_SUPPORT_GPU && defined(SK_VULKAN)
338