blob: daebf8abcdc9c28eae20c06414e3ca0779c18d96 [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
Dan Stoza9e56aa02015-11-02 13:00:03 -080017// #define LOG_NDEBUG 0
18#undef LOG_TAG
19#define LOG_TAG "LayerDim"
20
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080021#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 Agopian3330b202009-10-05 17:07:12 -070028#include <ui/GraphicBuffer.h>
29
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080030#include "LayerDim.h"
31#include "SurfaceFlinger.h"
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070032#include "DisplayDevice.h"
Mathias Agopian875d8e12013-06-07 15:35:48 -070033#include "RenderEngine/RenderEngine.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034
35namespace android {
36// ---------------------------------------------------------------------------
37
Mathias Agopian4d9b8222013-03-12 17:11:48 -070038LayerDim::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 Projectedbf3b62009-03-03 19:31:44 -080041}
42
Mathias Agopian13127d82013-03-05 17:47:11 -080043LayerDim::~LayerDim() {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044}
45
Dan Stozac7014012014-02-14 15:03:43 -080046void LayerDim::onDraw(const sp<const DisplayDevice>& hw,
47 const Region& /* clip */, bool useIdentityTransform) const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080048{
Mathias Agopian1eae0ee2013-06-05 16:59:15 -070049 const State& s(getDrawingState());
Mathias Agopianf74e8e02012-04-16 03:14:05 -070050 if (s.alpha>0) {
Mathias Agopian3f844832013-08-07 21:24:32 -070051 Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2);
Dan Stozac7014012014-02-14 15:03:43 -080052 computeGeometry(hw, mesh, useIdentityTransform);
Mathias Agopian875d8e12013-06-07 15:35:48 -070053 RenderEngine& engine(mFlinger->getRenderEngine());
54 engine.setupDimLayerBlending(s.alpha);
Mathias Agopian3f844832013-08-07 21:24:32 -070055 engine.drawMesh(mesh);
Mathias Agopian875d8e12013-06-07 15:35:48 -070056 engine.disableBlending();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080058}
59
Mathias Agopian2f73af92013-03-05 15:50:58 -080060bool LayerDim::isVisible() const {
Mathias Agopian1eae0ee2013-06-05 16:59:15 -070061 const Layer::State& s(getDrawingState());
Robert Carr1f0a16a2016-10-24 16:27:39 -070062 return !isHiddenByPolicy() && s.alpha;
Mathias Agopian2f73af92013-03-05 15:50:58 -080063}
64
65
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080066// ---------------------------------------------------------------------------
67
68}; // namespace android