13static_assert(
sizeof(int32_t) == 4);
14static_assert(
sizeof(
float) == 4);
15static_assert(
sizeof(
SkHalf) == 2);
29 SkASSERT(1 <= dimension && dimension <= 4);
33 const bool isArray =
count > Uniform::kNonArray;
41 const int align =
SkNextPow2(dimension) * primitiveSize;
42 const int alignedOffset =
SkAlignTo(fOffset, align);
43 fOffset = alignedOffset + dimension * primitiveSize * std::max(
count, 1);
44 fReqAlignment = std::max(fReqAlignment, align);
53 size_t paddingSize =
size - fStorage.
size();
54 if (paddingSize > 0) {
55 char* padding = fStorage.
append(paddingSize);
56 memset(padding, 0, paddingSize);
65 fWrotePaintColor =
false;
69 fExpectedUniforms = {};
70 fExpectedUniformIndex = 0;
100 if (
count == Uniform::kNonArray) {
103 case 1: this->
write<1,
false>(data,
type);
break;
104 case 2: this->
write<2,
false>(data,
type);
break;
105 case 3: this->
write<3,
false>(data,
type);
break;
106 case 4: this->
write<4,
false>(data,
type);
break;
110 case 1: this->
write<1,
true>(data,
type);
break;
111 case 2: this->
write<2,
true>(data,
type);
break;
112 case 3: this->
write<3,
true>(data,
type);
break;
113 case 4: this->
write<4,
true>(data,
type);
break;
138 if (fExpectedUniformIndex >= (
int) fExpectedUniforms.size()) {
144 const Uniform& expected = fExpectedUniforms[fExpectedUniformIndex++];
151 if (expectedType !=
type || expectedCount !=
count) {
158 int offset =
static_cast<int>(
reinterpret_cast<intptr_t
>(
dst) -
159 reinterpret_cast<intptr_t
>(fStorage.
data()));
161 if (
offset != fOffsetCalculator.advanceOffset(expected.
type(), expected.
count())) {
164 if (fReqAlignment != fOffsetCalculator.requiredAlignment()) {
168 return !(fWrotePaintColor && expected.isPaintColor());
173 return expected.isPaintColor();
177bool UniformManager::isReset()
const {
178 return fStorage.
empty();
182 fExpectedUniforms = expected;
183 fExpectedUniformIndex = 0;
186void UniformManager::doneWithExpectedUniforms() {
187 SkASSERT(fExpectedUniformIndex ==
static_cast<int>(fExpectedUniforms.size()));
188 fExpectedUniforms = {};
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
static int SkNextPow2(int value)
int SkSLTypeMatrixSize(SkSLType type)
bool SkSLTypeIsFullPrecisionNumericType(SkSLType type)
static constexpr bool SkSLTypeCanBeUniformValue(SkSLType type)
static constexpr int SkSLTypeVecLength(SkSLType type)
static constexpr bool UseFullPrecision(Layout layout)
static constexpr bool AlignArraysAsVec4(Layout layout)
static constexpr bool PadVec3Size(Layout layout)
static std::pair< SkSLType, int > adjust_for_matrix_type(SkSLType type, int count)