blob: 14aa328fef3c2bdb97cb78bbbf152551b767803e [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
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080017#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 Agopian3330b202009-10-05 17:07:12 -070024#include <ui/GraphicBuffer.h>
25
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080026#include "LayerDim.h"
27#include "SurfaceFlinger.h"
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070028#include "DisplayDevice.h"
Mathias Agopian875d8e12013-06-07 15:35:48 -070029#include "RenderEngine/RenderEngine.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080030
31namespace android {
32// ---------------------------------------------------------------------------
33
Mathias Agopian4d9b8222013-03-12 17:11:48 -070034LayerDim::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 Projectedbf3b62009-03-03 19:31:44 -080037}
38
Mathias Agopian13127d82013-03-05 17:47:11 -080039LayerDim::~LayerDim() {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040}
41
Dan Stozac7014012014-02-14 15:03:43 -080042void LayerDim::onDraw(const sp<const DisplayDevice>& hw,
43 const Region& /* clip */, bool useIdentityTransform) const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044{
Mathias Agopian1eae0ee2013-06-05 16:59:15 -070045 const State& s(getDrawingState());
Mathias Agopianf74e8e02012-04-16 03:14:05 -070046 if (s.alpha>0) {
Mathias Agopian3f844832013-08-07 21:24:32 -070047 Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2);
Dan Stozac7014012014-02-14 15:03:43 -080048 computeGeometry(hw, mesh, useIdentityTransform);
Mathias Agopian875d8e12013-06-07 15:35:48 -070049 RenderEngine& engine(mFlinger->getRenderEngine());
50 engine.setupDimLayerBlending(s.alpha);
Mathias Agopian3f844832013-08-07 21:24:32 -070051 engine.drawMesh(mesh);
Mathias Agopian875d8e12013-06-07 15:35:48 -070052 engine.disableBlending();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080054}
55
Mathias Agopian2f73af92013-03-05 15:50:58 -080056bool LayerDim::isVisible() const {
Mathias Agopian1eae0ee2013-06-05 16:59:15 -070057 const Layer::State& s(getDrawingState());
Mathias Agopian2f73af92013-03-05 15:50:58 -080058 return !(s.flags & layer_state_t::eLayerHidden) && s.alpha;
59}
60
61
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080062// ---------------------------------------------------------------------------
63
64}; // namespace android