1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 /* TODO Use textureOffset for newest version of GLSL */
12 uniform sampler2D sampler;
17 uniform float ratio; // = 1.0/(xscale*yscale)
19 varying vec2 tex_coord;
21 // This mode makes the scaling work like maskedTextureFragmentShader.glsl
22 // (instead of like plain textureVertexShader.glsl).
24 varying vec2 mask_coord;
25 uniform sampler2D mask;
29 Just make the resulting color the average of all the source pixels
30 (which is an area (xscale)x(yscale) ).
34 vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
35 vec2 offset = vec2( 0.0, 0.0 );
36 for( int y = 0; y < yscale; ++y )
38 for( int x = 0; x < xscale; ++x )
41 sum += texture2D( sampler, tex_coord.st + offset );
44 texel = texture2D( sampler, tex_coord.st + offset );
45 texel.a = 1.0 - texture2D( mask, mask_coord.st + offset ).r;
57 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */