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" |
Mathias Agopian | 0f2f5ff | 2012-07-31 23:09:07 -0700 | [diff] [blame] | 28 | #include "DisplayDevice.h" |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame^] | 29 | #include "RenderEngine/RenderEngine.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | // --------------------------------------------------------------------------- |
| 33 | |
Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 34 | LayerDim::LayerDim(SurfaceFlinger* flinger, const sp<Client>& client, |
| 35 | const String8& name, uint32_t w, uint32_t h, uint32_t flags) |
| 36 | : Layer(flinger, client, name, w, h, flags) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | } |
| 38 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 39 | LayerDim::~LayerDim() { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | } |
| 41 | |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 42 | void LayerDim::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | { |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 44 | const State& s(getDrawingState()); |
Mathias Agopian | f74e8e0 | 2012-04-16 03:14:05 -0700 | [diff] [blame] | 45 | if (s.alpha>0) { |
Mathias Agopian | 4fec873 | 2012-06-29 14:12:52 -0700 | [diff] [blame] | 46 | LayerMesh mesh; |
| 47 | computeGeometry(hw, &mesh); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame^] | 48 | RenderEngine& engine(mFlinger->getRenderEngine()); |
| 49 | engine.setupDimLayerBlending(s.alpha); |
| 50 | engine.drawMesh2D(mesh.getVertices(), NULL, mesh.getVertexCount()); |
| 51 | engine.disableBlending(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Mathias Agopian | 2f73af9 | 2013-03-05 15:50:58 -0800 | [diff] [blame] | 55 | bool LayerDim::isVisible() const { |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 56 | const Layer::State& s(getDrawingState()); |
Mathias Agopian | 2f73af9 | 2013-03-05 15:50:58 -0800 | [diff] [blame] | 57 | return !(s.flags & layer_state_t::eLayerHidden) && s.alpha; |
| 58 | } |
| 59 | |
| 60 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | // --------------------------------------------------------------------------- |
| 62 | |
| 63 | }; // namespace android |