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 */
14 uniform sampler2D sampler;
19 uniform float ratio; // = 1.0/(xscale*yscale)
21 varying vec2 tex_coord;
23 // This mode makes the scaling work like maskedTextureFragmentShader.glsl
24 // (instead of like plain textureVertexShader.glsl).
26 varying vec2 mask_coord;
27 uniform sampler2D mask;
31 Just make the resulting color the average of all the source pixels
32 (which is an area (xscale)x(yscale) ).
36 vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
37 vec2 offset = vec2( 0.0, 0.0 );
38 for( int y = 0; y < yscale; ++y )
40 for( int x = 0; x < xscale; ++x )
43 sum += texture2D( sampler, tex_coord.st + offset );
46 texel = texture2D( sampler, tex_coord.st + offset );
47 texel.a = 1.0 - texture2D( mask, mask_coord.st + offset ).r;
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */