Coverage Report

Created: 2024-05-20 07:14

/src/skia/tools/graphite/ProtectedUtils_Graphite.cpp
Line
Count
Source (jump to first uncovered line)
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
8
#include "tools/gpu/ProtectedUtils.h"
9
10
#include "include/core/SkCanvas.h"
11
#include "include/core/SkSurface.h"
12
#include "include/core/SkSurfaceProps.h"
13
#include "tools/gpu/BackendSurfaceFactory.h"
14
#include "tools/gpu/BackendTextureImageFactory.h"
15
16
using namespace skgpu;
17
using namespace skgpu::graphite;
18
19
namespace ProtectedUtils {
20
21
sk_sp<SkSurface> CreateProtectedSkSurface(Recorder* recorder,
22
                                          SkISize size,
23
0
                                          Protected isProtected) {
24
0
    SkImageInfo ii = SkImageInfo::Make(size, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
25
26
0
    sk_sp<SkSurface> surface = sk_gpu_test::MakeBackendTextureSurface(recorder,
27
0
                                                                      ii,
28
0
                                                                      Mipmapped::kNo,
29
0
                                                                      isProtected,
30
0
                                                                      /* surfaceProps= */ nullptr);
31
0
    if (!surface) {
32
0
        SK_ABORT("Could not create %s surface.",
33
0
                 isProtected == Protected::kYes ? "protected" : "unprotected");
34
0
        return nullptr;
35
0
    }
36
37
0
    SkCanvas* canvas = surface->getCanvas();
38
39
0
    canvas->clear(SkColors::kBlue);
40
41
0
    return surface;
42
0
}
43
44
sk_sp<SkImage> CreateProtectedSkImage(Recorder* recorder,
45
                                      SkISize size,
46
                                      SkColor4f color,
47
0
                                      Protected isProtected) {
48
0
    SkImageInfo ii = SkImageInfo::Make(size, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
49
50
0
    sk_sp<SkImage> image = sk_gpu_test::MakeBackendTextureImage(recorder,
51
0
                                                                ii,
52
0
                                                                color,
53
0
                                                                Mipmapped::kNo,
54
0
                                                                Renderable::kNo,
55
0
                                                                Origin::kTopLeft,
56
0
                                                                isProtected);
57
0
    if (!image) {
58
0
        SK_ABORT("Could not create %s image.",
59
0
                 isProtected == Protected::kYes ? "protected" : "unprotected");
60
0
        return nullptr;
61
0
    }
62
63
0
    return image;
64
0
}
65
66
}  // namespace ProtectedUtils