Flutter Engine
The Flutter Engine
GrGLSLProgramDataManager.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
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
9
13
14#include <cstddef>
15
16void GrGLSLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const {
17 float mt[] = {
27 };
28 this->setMatrix3f(u, mt);
29}
30
31void GrGLSLProgramDataManager::setSkM44(UniformHandle u, const SkM44& matrix) const {
33}
34
38 SkSpan<const Specialized> specialized,
39 const void* src) const {
40 SkASSERT(uniforms.empty() || src);
41 SkASSERT(specialized.empty() || specialized.size() == uniforms.size());
42 SkASSERT(!specialized.empty() || handles.size() == uniforms.size());
43
45 size_t handleIdx = 0;
46 for (size_t uniformIdx = 0; uniformIdx < uniforms.size(); ++uniformIdx) {
47 const auto& u = uniforms[uniformIdx];
48 auto floatData = [=] { return SkTAddOffset<const float>(src, u.offset); };
49 auto intData = [=] { return SkTAddOffset<const int >(src, u.offset); };
50 if (!specialized.empty() && specialized[uniformIdx] == Specialized::kYes) {
51 continue;
52 }
53 const auto h = handles[handleIdx++];
54 switch (u.type) {
55 case Type::kFloat: this->set1fv(h, u.count, floatData()); break;
56 case Type::kFloat2: this->set2fv(h, u.count, floatData()); break;
57 case Type::kFloat3: this->set3fv(h, u.count, floatData()); break;
58 case Type::kFloat4: this->set4fv(h, u.count, floatData()); break;
59
60 case Type::kFloat2x2: this->setMatrix2fv(h, u.count, floatData()); break;
61 case Type::kFloat3x3: this->setMatrix3fv(h, u.count, floatData()); break;
62 case Type::kFloat4x4: this->setMatrix4fv(h, u.count, floatData()); break;
63
64 case Type::kInt: this->set1iv(h, u.count, intData()); break;
65 case Type::kInt2: this->set2iv(h, u.count, intData()); break;
66 case Type::kInt3: this->set3iv(h, u.count, intData()); break;
67 case Type::kInt4: this->set4iv(h, u.count, intData()); break;
68
69 default:
70 SkDEBUGFAIL("Unsupported uniform type");
71 break;
72 }
73 }
74 SkASSERT(handleIdx == handles.size());
75}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
#define SkASSERT(cond)
Definition: SkAssert.h:116
void setRuntimeEffectUniforms(SkSpan< const SkRuntimeEffect::Uniform >, SkSpan< const UniformHandle >, SkSpan< const Specialized >, const void *src) const
virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const =0
virtual void set3fv(UniformHandle, int arrayCount, const float v[]) const =0
void setSkMatrix(UniformHandle, const SkMatrix &) const
virtual void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const =0
virtual void setMatrix3f(UniformHandle, const float matrix[]) const =0
virtual void set1fv(UniformHandle, int arrayCount, const float v[]) const =0
virtual void set4iv(UniformHandle, int arrayCount, const int v[]) const =0
virtual void set1iv(UniformHandle, int arrayCount, const int v[]) const =0
virtual void set2fv(UniformHandle, int arrayCount, const float v[]) const =0
virtual void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const =0
virtual void set3iv(UniformHandle, int arrayCount, const int v[]) const =0
void setSkM44(UniformHandle, const SkM44 &) const
virtual void set2iv(UniformHandle, int arrayCount, const int v[]) const =0
virtual void setMatrix4f(UniformHandle, const float matrix[]) const =0
virtual void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const =0
Definition: SkM44.h:150
static const SkScalar * M44ColMajor(const SkM44 &m)
Definition: SkMatrixPriv.h:185
static constexpr int kMScaleX
horizontal scale factor
Definition: SkMatrix.h:353
static constexpr int kMTransY
vertical translation
Definition: SkMatrix.h:358
static constexpr int kMPersp1
input y perspective factor
Definition: SkMatrix.h:360
static constexpr int kMPersp0
input x perspective factor
Definition: SkMatrix.h:359
static constexpr int kMPersp2
perspective bias
Definition: SkMatrix.h:361
static constexpr int kMTransX
horizontal translation
Definition: SkMatrix.h:355
static constexpr int kMSkewY
vertical skew factor
Definition: SkMatrix.h:356
static constexpr int kMScaleY
vertical scale factor
Definition: SkMatrix.h:357
static constexpr int kMSkewX
horizontal skew factor
Definition: SkMatrix.h:354
constexpr bool empty() const
Definition: SkSpan_impl.h:96
constexpr size_t size() const
Definition: SkSpan_impl.h:95
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
SkScalar h