Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Unified Diff: src/gpu/gl/GrGLSL_impl.h

Issue 26190003: Potentially optimize some GrGLEffects for known input color values (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/GrGLShaderBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLSL_impl.h
diff --git a/src/gpu/gl/GrGLSL_impl.h b/src/gpu/gl/GrGLSL_impl.h
index bdd69cc76b37fc47d9747a1427d5043162ba36cf..5eb3c1b00a4a08d27414cbe4f285c85ce5c4ea3e 100644
--- a/src/gpu/gl/GrGLSL_impl.h
+++ b/src/gpu/gl/GrGLSL_impl.h
@@ -108,6 +108,66 @@ inline GrGLSLExpr1 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
return GrGLSLExpr1::Sub(in0, in1);
}
+inline GrGLSLExpr3 GrGLSLExpr3::VectorCast(const GrGLSLExpr1& expr) {
+ return INHERITED::VectorCastImpl(expr);
+}
+
+inline GrGLSLExpr3 GrGLSLExpr3::VectorCast(const GrGLSLExpr3& expr) {
+ return expr;
+}
+
+inline const char* GrGLSLExpr3::ZerosStr() {
+ return "vec3(0)";
+}
+
+inline const char* GrGLSLExpr3::OnesStr() {
+ return "vec3(1)";
+}
+
+inline const char* GrGLSLExpr3::CastStr() {
+ return "vec3(%s)";
+}
+
+inline const char* GrGLSLExpr3::CastIntStr() {
+ return "vec3(%d)";
+}
+
+inline GrGLSLExpr3 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr3& in1) {
+ return GrGLSLExpr3::Mul(in0, in1);
+}
+
+inline GrGLSLExpr3 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr3& in1) {
+ return GrGLSLExpr3::Add(in0, in1);
+}
+
+inline GrGLSLExpr3 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr3& in1) {
+ return GrGLSLExpr3::Sub(in0, in1);
+}
+
+inline GrGLSLExpr3 operator*(const GrGLSLExpr3& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr3::Mul(in0, in1);
+}
+
+inline GrGLSLExpr3 operator+(const GrGLSLExpr3& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr3::Add(in0, in1);
+}
+
+inline GrGLSLExpr3 operator-(const GrGLSLExpr3& in0, const GrGLSLExpr1& in1) {
+ return GrGLSLExpr3::Sub(in0, in1);
+}
+
+inline GrGLSLExpr3 operator*(const GrGLSLExpr3& in0, const GrGLSLExpr3& in1) {
+ return GrGLSLExpr3::Mul(in0, in1);
+}
+
+inline GrGLSLExpr3 operator+(const GrGLSLExpr3& in0, const GrGLSLExpr3& in1) {
+ return GrGLSLExpr3::Add(in0, in1);
+}
+
+inline GrGLSLExpr3 operator-(const GrGLSLExpr3& in0, const GrGLSLExpr3& in1) {
+ return GrGLSLExpr3::Sub(in0, in1);
+}
+
inline const char* GrGLSLExpr4::ZerosStr() {
return "vec4(0)";
}
@@ -132,10 +192,23 @@ inline GrGLSLExpr4 GrGLSLExpr4::VectorCast(const GrGLSLExpr4& expr) {
return expr;
}
+inline GrGLSLExpr1 GrGLSLExpr4::x() const { return this->extractComponents<GrGLSLExpr1>("%s.x"); }
+inline GrGLSLExpr1 GrGLSLExpr4::y() const { return this->extractComponents<GrGLSLExpr1>("%s.y"); }
+inline GrGLSLExpr1 GrGLSLExpr4::z() const { return this->extractComponents<GrGLSLExpr1>("%s.z"); }
+inline GrGLSLExpr1 GrGLSLExpr4::w() const { return this->extractComponents<GrGLSLExpr1>("%s.w"); }
+inline GrGLSLExpr1 GrGLSLExpr4::r() const { return this->extractComponents<GrGLSLExpr1>("%s.r"); }
+inline GrGLSLExpr1 GrGLSLExpr4::g() const { return this->extractComponents<GrGLSLExpr1>("%s.g"); }
+inline GrGLSLExpr1 GrGLSLExpr4::b() const { return this->extractComponents<GrGLSLExpr1>("%s.b"); }
+
inline GrGLSLExpr4::AExpr GrGLSLExpr4::a() const {
return this->extractComponents<GrGLSLExpr4::AExpr>("%s.a");
}
+inline GrGLSLExpr3 GrGLSLExpr4::xyz() const { return this->extractComponents<GrGLSLExpr3>("%s.xyz"); }
+inline GrGLSLExpr3 GrGLSLExpr4::rgb() const { return this->extractComponents<GrGLSLExpr3>("%s.rgb"); }
+
+
+
inline GrGLSLExpr4 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
return GrGLSLExpr4::Mul(in0, in1);
}
@@ -172,4 +245,65 @@ inline GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
return GrGLSLExpr4::Sub(in0, in1);
}
+namespace GrGLSL {
+inline GrGLSLExpr1 max(const GrGLSLExpr1& a, float b) {
+ if (a.isOnes()) {
+ if (b > 1) {
+ return GrGLSLExpr1(b);
+ }
+ return a;
+ } else if (a.isZeros()) {
+ if (b > 0) {
+ return GrGLSLExpr1(b);
+ }
+ return a;
+ }
+ SkString r;
+ r.printf("max(%s, %f)", a.c_str(), b);
+ return GrGLSLExpr1(r);
+}
+
+template<typename T>
+inline T min(const T& a, const T& b) {
+ if (a.isOnes()) {
+ if (b.isOnes()) {
+ return a;
+ }
+ if (b.isZeros()) {
+ return b;
+ }
+ }
+ if (a.isZeros()) {
+ if (b.isOnes()) {
+ return a;
+ }
+ if (b.isZeros()) {
+ return a;
+ }
+ }
+ return T("min(%s, %s)", a.c_str(), b.c_str());
+}
+
+template<typename T>
+inline T max(const T& a, const T& b) {
+ if (a.isOnes()) {
+ if (b.isOnes()) {
+ return a;
+ }
+ if (b.isZeros()) {
+ return a;
+ }
+ }
+ if (a.isZeros()) {
+ if (b.isOnes()) {
+ return b;
+ }
+ if (b.isZeros()) {
+ return a;
+ }
+ }
+ return T("max(%s, %s)", a.c_str(), b.c_str());
+}
+}
+
#endif
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/GrGLShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698