The Android Open Source Project | 9066cfe | 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 | 9066cfe | 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 | |
| 24 | #include "LayerDim.h" |
| 25 | #include "SurfaceFlinger.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include "DisplayHardware/DisplayHardware.h" |
| 27 | |
| 28 | namespace android { |
| 29 | // --------------------------------------------------------------------------- |
| 30 | |
| 31 | const uint32_t LayerDim::typeInfo = LayerBaseClient::typeInfo | 0x10; |
| 32 | const char* const LayerDim::typeID = "LayerDim"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | |
| 34 | // --------------------------------------------------------------------------- |
| 35 | |
| 36 | LayerDim::LayerDim(SurfaceFlinger* flinger, DisplayID display, |
| 37 | Client* client, int32_t i) |
| 38 | : LayerBaseClient(flinger, display, client, i) |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | void LayerDim::initDimmer(SurfaceFlinger* flinger, uint32_t w, uint32_t h) |
| 43 | { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | LayerDim::~LayerDim() |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | void LayerDim::onDraw(const Region& clip) const |
| 51 | { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 52 | // FIXME: on some h/w (like msm7K, it will be faster to use a texture) |
| 53 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | const State& s(drawingState()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | Region::iterator iterator(clip); |
| 56 | if (s.alpha>0 && iterator) { |
| 57 | const DisplayHardware& hw(graphicPlane(0).displayHardware()); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 58 | const GGLfixed alpha = (s.alpha << 16)/255; |
| 59 | const uint32_t fbHeight = hw.getHeight(); |
| 60 | glDisable(GL_TEXTURE_2D); |
| 61 | glDisable(GL_DITHER); |
| 62 | glEnable(GL_BLEND); |
| 63 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 64 | glColor4x(0, 0, 0, alpha); |
| 65 | glVertexPointer(2, GL_FIXED, 0, mVertices); |
| 66 | Rect r; |
| 67 | while (iterator.iterate(&r)) { |
| 68 | const GLint sy = fbHeight - (r.top + r.height()); |
| 69 | glScissor(r.left, sy, r.width(), r.height()); |
| 70 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // --------------------------------------------------------------------------- |
| 76 | |
| 77 | }; // namespace android |