Change copyrights from Nokia to Digia
[profile/ivi/qtwayland.git] / src / compositor / compositor_api / waylandsurfacetexturematerial.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "waylandsurfacetexturematerial.h"
43 #include <QtGui/QOpenGLContext>
44
45 static const char wayland_surface_texture_material_vertex[] =
46            "uniform highp mat4 qt_Matrix;                      \n"
47            "attribute highp vec4 qt_VertexPosition;            \n"
48            "attribute highp vec2 qt_VertexTexCoord;            \n"
49            "varying highp vec2 qt_TexCoord;                    \n"
50            "void main() {                                      \n"
51            "    qt_TexCoord = qt_VertexTexCoord;               \n"
52            "    gl_Position = qt_Matrix * qt_VertexPosition;   \n"
53            "}";
54
55
56 static const char wayland_surface_texture_opaque_material_fragment[] =
57            "varying highp vec2 qt_TexCoord;                    \n"
58            "uniform sampler2D qt_Texture;                      \n"
59            "uniform lowp float qt_Opacity;                     \n"
60            "void main() {                                      \n"
61            "    gl_FragColor = vec4(texture2D(qt_Texture, qt_TexCoord).rgb, 1.0) * qt_Opacity; \n"
62            "}";
63
64 static const char wayland_surface_texture_material_fragment[] =
65            "varying highp vec2 qt_TexCoord;                    \n"
66            "uniform sampler2D qt_Texture;                      \n"
67            "uniform lowp float qt_Opacity;                     \n"
68            "void main() {                                      \n"
69            "    gl_FragColor = texture2D(qt_Texture, qt_TexCoord) * qt_Opacity; \n"
70            "}";
71
72 QList<QByteArray> WaylandSurfaceTextureMaterial::attributes() const
73 {
74     QList<QByteArray> attributeList;
75     attributeList << "qt_VertexPosition";
76     attributeList << "qt_VertexTexCoord";
77     return attributeList;
78 }
79
80 void WaylandSurfaceTextureMaterial::updateState(const WaylandSurfaceTextureState *newState, const WaylandSurfaceTextureState *oldState)
81 {
82     Q_UNUSED(oldState);
83     newState->texture()->bind();
84 }
85
86 const char *WaylandSurfaceTextureMaterial::vertexShader() const
87 {
88     return wayland_surface_texture_material_vertex;
89 }
90
91 const char *WaylandSurfaceTextureMaterial::fragmentShader() const
92 {
93     return wayland_surface_texture_material_fragment;
94 }
95
96 QList<QByteArray> WaylandSurfaceTextureOpaqueMaterial::attributes() const
97 {
98     QList<QByteArray> attributeList;
99     attributeList << "qt_VertexPosition";
100     attributeList << "qt_VertexTexCoord";
101     return attributeList;
102 }
103
104 void WaylandSurfaceTextureOpaqueMaterial::updateState(const WaylandSurfaceTextureState *newState, const WaylandSurfaceTextureState *oldState)
105 {
106     Q_UNUSED(oldState);
107     newState->texture()->bind();
108 }
109
110 const char *WaylandSurfaceTextureOpaqueMaterial::vertexShader() const
111 {
112     return wayland_surface_texture_material_vertex;
113 }
114
115 const char *WaylandSurfaceTextureOpaqueMaterial::fragmentShader() const
116 {
117     return wayland_surface_texture_opaque_material_fragment;
118 }