Flutter Engine
The Flutter Engine
Attribute.h
Go to the documentation of this file.
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
14
15namespace skgpu::graphite {
16
17 /** Describes a vertex or instance attribute. */
18class Attribute {
19public:
20 constexpr Attribute() = default;
21 constexpr Attribute(const char* name,
24 : fName(name), fCPUType(cpuType), fGPUType(gpuType) {
26 }
27 constexpr Attribute(const Attribute&) = default;
28
29 Attribute& operator=(const Attribute&) = default;
30
31 constexpr bool isInitialized() const { return fGPUType != SkSLType::kVoid; }
32
33 constexpr const char* name() const { return fName; }
34 constexpr VertexAttribType cpuType() const { return fCPUType; }
35 constexpr SkSLType gpuType() const { return fGPUType; }
36
37 constexpr size_t size() const { return VertexAttribTypeSize(fCPUType); }
38 constexpr size_t sizeAlign4() const { return SkAlign4(this->size()); }
39
40private:
41 const char* fName = nullptr;
43 SkSLType fGPUType = SkSLType::kVoid;
44};
45
46} // namespace skgpu::graphite
47
48#endif // skgpu_graphite_Attribute_DEFINED
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkSLType
constexpr bool isInitialized() const
Definition: Attribute.h:31
constexpr Attribute()=default
Attribute & operator=(const Attribute &)=default
constexpr size_t size() const
Definition: Attribute.h:37
constexpr Attribute(const char *name, VertexAttribType cpuType, SkSLType gpuType)
Definition: Attribute.h:21
constexpr SkSLType gpuType() const
Definition: Attribute.h:35
constexpr VertexAttribType cpuType() const
Definition: Attribute.h:34
constexpr Attribute(const Attribute &)=default
constexpr const char * name() const
Definition: Attribute.h:33
constexpr size_t sizeAlign4() const
Definition: Attribute.h:38
static constexpr size_t VertexAttribTypeSize(VertexAttribType type)
Definition: DrawTypes.h:77