diff options
author | ethannicholas <ethannicholas@google.com> | 2016-07-12 09:07:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-12 09:07:21 -0700 |
commit | 9fd67a1f53809f5eff1210dd107241b450c48acc (patch) | |
tree | da60b78933d92f796cf1f5dc3ff3dffa6febf78f /src/sksl/ir/SkSLSwizzle.h | |
parent | 5dba301e916448bbb17bfe8e70dc367f32eb7159 (diff) |
SkSL performance improvements (plus a couple of minor warning fixes)
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2131223002
Review-Url: https://codereview.chromium.org/2131223002
Diffstat (limited to 'src/sksl/ir/SkSLSwizzle.h')
-rw-r--r-- | src/sksl/ir/SkSLSwizzle.h | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h index ce360d1847..fad71b8114 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(Expression& value, size_t count) { + const Type& base = value.fType.componentType(); if (count == 1) { return base; } - if (base == kFloat_Type) { + if (base == *kFloat_Type) { switch (count) { - case 2: return kVec2_Type; - case 3: return kVec3_Type; - case 4: return kVec4_Type; + case 2: return *kVec2_Type; + case 3: return *kVec3_Type; + case 4: return *kVec4_Type; } - } else if (base == kDouble_Type) { + } else if (base == *kDouble_Type) { switch (count) { - case 2: return kDVec2_Type; - case 3: return kDVec3_Type; - case 4: return kDVec4_Type; + case 2: return *kDVec2_Type; + case 3: return *kDVec3_Type; + case 4: return *kDVec4_Type; } - } else if (base == kInt_Type) { + } else if (base == *kInt_Type) { switch (count) { - case 2: return kIVec2_Type; - case 3: return kIVec3_Type; - case 4: return kIVec4_Type; + case 2: return *kIVec2_Type; + case 3: return *kIVec3_Type; + case 4: return *kIVec4_Type; } - } else if (base == kUInt_Type) { + } else if (base == *kUInt_Type) { switch (count) { - case 2: return kUVec2_Type; - case 3: return kUVec3_Type; - case 4: return kUVec4_Type; + case 2: return *kUVec2_Type; + case 3: return *kUVec3_Type; + case 4: return *kUVec4_Type; } - } else if (base == kBool_Type) { + } else if (base == *kBool_Type) { switch (count) { - case 2: return kBVec2_Type; - case 3: return kBVec3_Type; - case 4: return kBVec4_Type; + case 2: return *kBVec2_Type; + case 3: return *kBVec3_Type; + case 4: return *kBVec4_Type; } } ABORT("cannot swizzle %s\n", value.description().c_str()); |