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

Unified Diff: cc/output/shader.cc

Issue 881963002: Clamp YUV videos to their visible size in the shader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/quads/draw_quad_unittest.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 5bc704497ca5b63c24547ac5d9ea15092783b454..ad0a939d458f7f303529c234496eb4a18d63de3e 100644
--- a/cc/output/shader.cc
+++ b/cc/output/shader.cc
@@ -191,14 +191,17 @@ std::string VertexShaderPosTex::GetShaderString() const {
}
VertexShaderPosTexYUVStretchOffset::VertexShaderPosTexYUVStretchOffset()
- : matrix_location_(-1), tex_scale_location_(-1), tex_offset_location_(-1) {
+ : matrix_location_(-1),
+ tex_scale_location_(-1),
+ tex_offset_location_(-1),
+ clamp_size_location_(-1) {
}
void VertexShaderPosTexYUVStretchOffset::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "matrix", "texScale", "texOffset",
+ "matrix", "texScale", "texOffset", "clampSize",
};
int locations[arraysize(uniforms)];
@@ -211,22 +214,21 @@ void VertexShaderPosTexYUVStretchOffset::Init(GLES2Interface* context,
matrix_location_ = locations[0];
tex_scale_location_ = locations[1];
tex_offset_location_ = locations[2];
+ clamp_size_location_ = locations[3];
}
std::string VertexShaderPosTexYUVStretchOffset::GetShaderString() const {
// clang-format off
return VERTEX_SHADER(
// clang-format on
- precision mediump float;
- attribute vec4 a_position;
- attribute TexCoordPrecision vec2 a_texCoord;
- uniform mat4 matrix;
+ precision mediump float; attribute vec4 a_position;
+ attribute TexCoordPrecision vec2 a_texCoord; uniform mat4 matrix;
varying TexCoordPrecision vec2 v_texCoord;
uniform TexCoordPrecision vec2 texScale;
uniform TexCoordPrecision vec2 texOffset;
- void main() {
+ uniform TexCoordPrecision vec2 clampSize; void main() {
danakj 2015/01/28 01:02:00 formatting..
enne (OOO) 2015/01/31 01:32:13 git cl format T_T
gl_Position = matrix * a_position;
- v_texCoord = a_texCoord * texScale + texOffset;
+ v_texCoord = min(clampSize, a_texCoord * texScale + texOffset);
danakj 2015/01/28 01:02:00 do we not have to clamp on the left/top too?
enne (OOO) 2015/01/31 01:32:13 Turns out we do. Thanks. I changed clampSize to
}
// clang-format off
); // NOLINT(whitespace/parens)
« no previous file with comments | « cc/output/shader.h ('k') | cc/quads/draw_quad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698