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

Unified Diff: cc/output/shader.cc

Issue 2121043002: 16 bpp video stream capture, render and WebGL usage - Realsense R200 & SR300 support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 | « cc/output/shader.h ('k') | cc/output/software_renderer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/shader.cc
diff --git a/cc/output/shader.cc b/cc/output/shader.cc
index b5d163862d14e010aa19d5bcd083278366ed34b4..ed17163e7c7ffa5fff5c8217f1bd49028a526b7a 100644
--- a/cc/output/shader.cc
+++ b/cc/output/shader.cc
@@ -2176,6 +2176,58 @@ std::string FragmentShaderYUVVideo::GetShaderString(TexCoordPrecision precision,
return FRAGMENT_SHADER(head, functions);
}
+FragmentShaderYVideo::FragmentShaderYVideo()
+ : FragmentTexOpaqueBinding(),
+ x_derivative_location_(-1),
+ y_derivative_location_(-1) {}
+
+void FragmentShaderYVideo::Init(GLES2Interface* context,
+ unsigned program,
+ int* base_uniform_index) {
+ FragmentTexOpaqueBinding::Init(context, program, base_uniform_index);
+
+ static const char* uniforms[] = {"x_derivative", "y_derivative"};
+ int locations[arraysize(uniforms)];
+
+ GetProgramUniformLocations(context, program, arraysize(uniforms), uniforms,
+ locations, base_uniform_index);
+ x_derivative_location_ = locations[0];
+ y_derivative_location_ = locations[1];
+}
+
+std::string FragmentShaderYVideo::GetShaderString(TexCoordPrecision precision,
+ SamplerType sampler) const {
+ return FRAGMENT_SHADER(GetShaderHead(), GetShaderBody());
+}
+
+std::string FragmentShaderYVideo::GetShaderHead() {
+ return SHADER0([]() {
+ precision mediump float;
+ varying TexCoordPrecision vec2 v_texCoord;
+ uniform SamplerType s_texture;
+ uniform float x_derivative;
+ uniform float y_derivative;
+ });
+}
+
+std::string FragmentShaderYVideo::GetShaderBody() {
+ return SHADER0([]() {
+ vec4 TextureLookupBilinear(SamplerType sampler, highp vec2 texCoord) {
+ vec4 s1 = TextureLookup(sampler, texCoord);
+ vec4 s2 = TextureLookup(sampler, texCoord + vec2(x_derivative, 0.));
+ vec4 s3 = TextureLookup(sampler, texCoord + vec2(0., y_derivative));
+ vec4 s4 =
+ TextureLookup(sampler, texCoord + vec2(x_derivative, y_derivative));
+ vec2 f = fract(texCoord.xy / vec2(x_derivative, y_derivative));
+ return mix(mix(s1, s2, f.x), mix(s3, s4, f.x), f.y);
+ }
+ void main() {
+ gl_FragColor =
+ vec4(vec3(TextureLookupBilinear(s_texture, v_texCoord).g), 1.);
+ }
+ });
+}
+
FragmentShaderColor::FragmentShaderColor() : color_location_(-1) {
}
« no previous file with comments | « cc/output/shader.h ('k') | cc/output/software_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698