blob: aef37b154756d039b275ccae26687a82d26768d4 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080017#include <stdlib.h>
18#include <stdint.h>
19#include <sys/types.h>
20
Mathias Agopiand3ee2312012-08-02 14:01:42 -070021#include <GLES/gl.h>
22#include <GLES/glext.h>
23
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080024#include <utils/Errors.h>
25#include <utils/Log.h>
26
Mathias Agopian3330b202009-10-05 17:07:12 -070027#include <ui/GraphicBuffer.h>
28
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080029#include "LayerDim.h"
30#include "SurfaceFlinger.h"
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070031#include "DisplayDevice.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032
33namespace android {
34// ---------------------------------------------------------------------------
35
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080036LayerDim::LayerDim(SurfaceFlinger* flinger, DisplayID display,
Mathias Agopian96f08192010-06-02 23:28:45 -070037 const sp<Client>& client)
38 : LayerBaseClient(flinger, display, client)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080039{
40}
41
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042LayerDim::~LayerDim()
43{
44}
45
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070046void LayerDim::onDraw(const DisplayDevice& hw, const Region& clip) const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047{
48 const State& s(drawingState());
Mathias Agopianf74e8e02012-04-16 03:14:05 -070049 if (s.alpha>0) {
Mathias Agopian1f7bec62010-06-25 18:02:21 -070050 const GLfloat alpha = s.alpha/255.0f;
Mathias Agopian076b1cc2009-04-10 14:24:30 -070051 const uint32_t fbHeight = hw.getHeight();
Mathias Agopianc492e672011-10-18 14:49:27 -070052 glDisable(GL_TEXTURE_EXTERNAL_OES);
53 glDisable(GL_TEXTURE_2D);
Mathias Agopian0d156122011-01-25 20:17:45 -080054
55 if (s.alpha == 0xFF) {
56 glDisable(GL_BLEND);
57 } else {
58 glEnable(GL_BLEND);
59 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
60 }
61
Mathias Agopian1f7bec62010-06-25 18:02:21 -070062 glColor4f(0, 0, 0, alpha);
63
Mathias Agopian4fec8732012-06-29 14:12:52 -070064 LayerMesh mesh;
65 computeGeometry(hw, &mesh);
66
67 glVertexPointer(2, GL_FLOAT, 0, mesh.getVertices());
68 glDrawArrays(GL_TRIANGLE_FAN, 0, mesh.getVertexCount());
Mathias Agopian945ebbf2009-06-18 18:48:39 -070069
Mathias Agopianc492e672011-10-18 14:49:27 -070070 glDisable(GL_BLEND);
71 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080072 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080073}
74
75// ---------------------------------------------------------------------------
76
77}; // namespace android