aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ir/SkSLSwizzle.h
diff options
context:
space:
mode:
authorGravatar ethannicholas <ethannicholas@google.com>2016-07-25 10:08:54 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-25 10:08:54 -0700
commitd598f7981f34811e6f2a949207dc13638852f3f7 (patch)
tree83dd4cf4983f90125651a0ab380f4f71cb3e27f2 /src/sksl/ir/SkSLSwizzle.h
parentd9ddad2952cdfd0809249abbd94a285abdb6b1d0 (diff)
SkSL performance improvements (plus a couple of minor warning fixes)
Diffstat (limited to 'src/sksl/ir/SkSLSwizzle.h')
-rw-r--r--src/sksl/ir/SkSLSwizzle.h49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h
index ce360d1847..0eb4a00dca 100644
--- a/src/sksl/ir/SkSLSwizzle.h
+++ b/src/sksl/ir/SkSLSwizzle.h
@@ -18,41 +18,40 @@ namespace SkSL {
* instance, swizzling a vec3 with two components will result in a vec2. It is possible to swizzle
* with more components than the source vector, as in 'vec2(1).xxxx'.
*/
-static std::shared_ptr<Type> get_type(Expression& value,
- size_t count) {
- std::shared_ptr<Type> base = value.fType->componentType();
+static const Type& get_type(const Context& context, Expression& value, size_t count) {
+ const Type& base = value.fType.componentType();
if (count == 1) {
return base;
}
- if (base == kFloat_Type) {
+ if (base == *context.fFloat_Type) {
switch (count) {
- case 2: return kVec2_Type;
- case 3: return kVec3_Type;
- case 4: return kVec4_Type;
+ case 2: return *context.fVec2_Type;
+ case 3: return *context.fVec3_Type;
+ case 4: return *context.fVec4_Type;
}
- } else if (base == kDouble_Type) {
+ } else if (base == *context.fDouble_Type) {
switch (count) {
- case 2: return kDVec2_Type;
- case 3: return kDVec3_Type;
- case 4: return kDVec4_Type;
+ case 2: return *context.fDVec2_Type;
+ case 3: return *context.fDVec3_Type;
+ case 4: return *context.fDVec4_Type;
}
- } else if (base == kInt_Type) {
+ } else if (base == *context.fInt_Type) {
switch (count) {
- case 2: return kIVec2_Type;
- case 3: return kIVec3_Type;
- case 4: return kIVec4_Type;
+ case 2: return *context.fIVec2_Type;
+ case 3: return *context.fIVec3_Type;
+ case 4: return *context.fIVec4_Type;
}
- } else if (base == kUInt_Type) {
+ } else if (base == *context.fUInt_Type) {
switch (count) {
- case 2: return kUVec2_Type;
- case 3: return kUVec3_Type;
- case 4: return kUVec4_Type;
+ case 2: return *context.fUVec2_Type;
+ case 3: return *context.fUVec3_Type;
+ case 4: return *context.fUVec4_Type;
}
- } else if (base == kBool_Type) {
+ } else if (base == *context.fBool_Type) {
switch (count) {
- case 2: return kBVec2_Type;
- case 3: return kBVec3_Type;
- case 4: return kBVec4_Type;
+ case 2: return *context.fBVec2_Type;
+ case 3: return *context.fBVec3_Type;
+ case 4: return *context.fBVec4_Type;
}
}
ABORT("cannot swizzle %s\n", value.description().c_str());
@@ -62,8 +61,8 @@ static std::shared_ptr<Type> get_type(Expression& value,
* Represents a vector swizzle operation such as 'vec2(1, 2, 3).zyx'.
*/
struct Swizzle : public Expression {
- Swizzle(std::unique_ptr<Expression> base, std::vector<int> components)
- : INHERITED(base->fPosition, kSwizzle_Kind, get_type(*base, components.size()))
+ Swizzle(const Context& context, std::unique_ptr<Expression> base, std::vector<int> components)
+ : INHERITED(base->fPosition, kSwizzle_Kind, get_type(context, *base, components.size()))
, fBase(std::move(base))
, fComponents(std::move(components)) {
ASSERT(fComponents.size() >= 1 && fComponents.size() <= 4);