1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18package android.filterpacks.imageproc;
19
20import android.filterfw.core.FilterContext;
21import android.filterfw.core.NativeProgram;
22import android.filterfw.core.Program;
23import android.filterfw.core.ShaderProgram;
24
25/**
26 * @hide
27 */
28public class BrightnessFilter extends SimpleImageFilter {
29
30    private static final String mBrightnessShader =
31            "precision mediump float;\n" +
32            "uniform sampler2D tex_sampler_0;\n" +
33            "uniform float brightness;\n" +
34            "varying vec2 v_texcoord;\n" +
35            "void main() {\n" +
36            "  vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
37            "  gl_FragColor = brightness * color;\n" +
38            "}\n";
39
40    public BrightnessFilter(String name) {
41        super(name, "brightness");
42    }
43
44    @Override
45    protected Program getNativeProgram(FilterContext context) {
46        return new NativeProgram("filterpack_imageproc", "brightness");
47    }
48
49    @Override
50    protected Program getShaderProgram(FilterContext context) {
51        return new ShaderProgram(context, mBrightnessShader);
52    }
53
54}
55