Coverage Report

Created: 2024-05-20 07:14

/src/skia/src/gpu/graphite/Attribute.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2021 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
#ifndef skgpu_graphite_Attribute_DEFINED
9
#define skgpu_graphite_Attribute_DEFINED
10
11
#include "include/private/base/SkAlign.h"
12
#include "src/core/SkSLTypeShared.h"
13
#include "src/gpu/graphite/DrawTypes.h"
14
15
namespace skgpu::graphite {
16
17
 /** Describes a vertex or instance attribute. */
18
class Attribute {
19
public:
20
    constexpr Attribute() = default;
21
    constexpr Attribute(const char* name,
22
                        VertexAttribType cpuType,
23
                        SkSLType gpuType)
24
0
            : fName(name), fCPUType(cpuType), fGPUType(gpuType) {
25
0
        SkASSERT(name && gpuType != SkSLType::kVoid);
26
0
    }
Unexecuted instantiation: skgpu::graphite::Attribute::Attribute(char const*, skgpu::graphite::VertexAttribType, SkSLType)
Unexecuted instantiation: skgpu::graphite::Attribute::Attribute(char const*, skgpu::graphite::VertexAttribType, SkSLType)
27
    constexpr Attribute(const Attribute&) = default;
28
29
    Attribute& operator=(const Attribute&) = default;
30
31
0
    constexpr bool isInitialized() const { return fGPUType != SkSLType::kVoid; }
32
33
0
    constexpr const char*      name()    const { return fName; }
34
0
    constexpr VertexAttribType cpuType() const { return fCPUType; }
35
0
    constexpr SkSLType         gpuType() const { return fGPUType; }
36
37
0
    constexpr size_t size()       const { return VertexAttribTypeSize(fCPUType); }
38
0
    constexpr size_t sizeAlign4() const { return SkAlign4(this->size()); }
39
40
private:
41
    const char* fName = nullptr;
42
    VertexAttribType fCPUType = VertexAttribType::kFloat;
43
    SkSLType fGPUType = SkSLType::kVoid;
44
};
45
46
} // namespace skgpu::graphite
47
48
#endif // skgpu_graphite_Attribute_DEFINED