| 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 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 17 | // #define LOG_NDEBUG 0 | 
|  | 18 | #undef LOG_TAG | 
|  | 19 | #define LOG_TAG "LayerDim" | 
|  | 20 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | #include <stdlib.h> | 
|  | 22 | #include <stdint.h> | 
|  | 23 | #include <sys/types.h> | 
|  | 24 |  | 
|  | 25 | #include <utils/Errors.h> | 
|  | 26 | #include <utils/Log.h> | 
|  | 27 |  | 
| Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 28 | #include <ui/GraphicBuffer.h> | 
|  | 29 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | #include "LayerDim.h" | 
|  | 31 | #include "SurfaceFlinger.h" | 
| Mathias Agopian | 0f2f5ff | 2012-07-31 23:09:07 -0700 | [diff] [blame] | 32 | #include "DisplayDevice.h" | 
| Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 33 | #include "RenderEngine/RenderEngine.h" | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 |  | 
|  | 35 | namespace android { | 
|  | 36 | // --------------------------------------------------------------------------- | 
|  | 37 |  | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 38 | LayerDim::LayerDim(SurfaceFlinger* flinger, const sp<Client>& client, | 
|  | 39 | const String8& name, uint32_t w, uint32_t h, uint32_t flags) | 
|  | 40 | : Layer(flinger, client, name, w, h, flags) { | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | } | 
|  | 42 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 43 | LayerDim::~LayerDim() { | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | } | 
|  | 45 |  | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 46 | void LayerDim::onDraw(const sp<const DisplayDevice>& hw, | 
|  | 47 | const Region& /* clip */, bool useIdentityTransform) const | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | { | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 49 | const State& s(getDrawingState()); | 
| Mathias Agopian | f74e8e0 | 2012-04-16 03:14:05 -0700 | [diff] [blame] | 50 | if (s.alpha>0) { | 
| Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 51 | Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2); | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 52 | computeGeometry(hw, mesh, useIdentityTransform); | 
| Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 53 | RenderEngine& engine(mFlinger->getRenderEngine()); | 
|  | 54 | engine.setupDimLayerBlending(s.alpha); | 
| Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 55 | engine.drawMesh(mesh); | 
| Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 56 | engine.disableBlending(); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | } | 
|  | 59 |  | 
| Mathias Agopian | 2f73af9 | 2013-03-05 15:50:58 -0800 | [diff] [blame] | 60 | bool LayerDim::isVisible() const { | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 61 | const Layer::State& s(getDrawingState()); | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 62 | return !isHiddenByPolicy() && s.alpha; | 
| Mathias Agopian | 2f73af9 | 2013-03-05 15:50:58 -0800 | [diff] [blame] | 63 | } | 
|  | 64 |  | 
|  | 65 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | // --------------------------------------------------------------------------- | 
|  | 67 |  | 
|  | 68 | }; // namespace android |