The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | #include <stdlib.h> |
| 18 | #include <stdint.h> |
| 19 | #include <sys/types.h> |
| 20 | |
| 21 | #include <utils/Errors.h> |
| 22 | #include <utils/Log.h> |
| 23 | |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 24 | #include <ui/GraphicBuffer.h> |
| 25 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include "LayerDim.h" |
| 27 | #include "SurfaceFlinger.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | #include "DisplayHardware/DisplayHardware.h" |
| 29 | |
| 30 | namespace android { |
| 31 | // --------------------------------------------------------------------------- |
| 32 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | LayerDim::LayerDim(SurfaceFlinger* flinger, DisplayID display, |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 34 | const sp<Client>& client) |
| 35 | : LayerBaseClient(flinger, display, client) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | { |
| 37 | } |
| 38 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | LayerDim::~LayerDim() |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | void LayerDim::onDraw(const Region& clip) const |
| 44 | { |
| 45 | const State& s(drawingState()); |
Mathias Agopian | f74e8e0 | 2012-04-16 03:14:05 -0700 | [diff] [blame] | 46 | if (s.alpha>0) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | const DisplayHardware& hw(graphicPlane(0).displayHardware()); |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 48 | const GLfloat alpha = s.alpha/255.0f; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 49 | const uint32_t fbHeight = hw.getHeight(); |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 50 | glDisable(GL_TEXTURE_EXTERNAL_OES); |
| 51 | glDisable(GL_TEXTURE_2D); |
Mathias Agopian | 0d15612 | 2011-01-25 20:17:45 -0800 | [diff] [blame] | 52 | |
| 53 | if (s.alpha == 0xFF) { |
| 54 | glDisable(GL_BLEND); |
| 55 | } else { |
| 56 | glEnable(GL_BLEND); |
| 57 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 58 | } |
| 59 | |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 60 | glColor4f(0, 0, 0, alpha); |
| 61 | |
Mathias Agopian | bce26da | 2011-02-02 16:03:19 -0800 | [diff] [blame] | 62 | glVertexPointer(2, GL_FLOAT, 0, mVertices); |
Mathias Agopian | f74e8e0 | 2012-04-16 03:14:05 -0700 | [diff] [blame] | 63 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
Mathias Agopian | 945ebbf | 2009-06-18 18:48:39 -0700 | [diff] [blame] | 64 | |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 65 | glDisable(GL_BLEND); |
| 66 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | // --------------------------------------------------------------------------- |
| 71 | |
| 72 | }; // namespace android |