blob: 062ad46a6b951d1e166fafdf85a142e4185da8cf [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
Mathias Agopian42977342012-08-05 00:40:46 -070042void LayerDim::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043{
Mathias Agopian1eae0ee2013-06-05 16:59:15 -070044 const State& s(getDrawingState());
Mathias Agopianf74e8e02012-04-16 03:14:05 -070045 if (s.alpha>0) {
Mathias Agopian4fec8732012-06-29 14:12:52 -070046 LayerMesh mesh;
47 computeGeometry(hw, &mesh);
Mathias Agopian875d8e12013-06-07 15:35:48 -070048 RenderEngine& engine(mFlinger->getRenderEngine());
49 engine.setupDimLayerBlending(s.alpha);
50 engine.drawMesh2D(mesh.getVertices(), NULL, mesh.getVertexCount());
51 engine.disableBlending();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053}
54
Mathias Agopian2f73af92013-03-05 15:50:58 -080055bool LayerDim::isVisible() const {
Mathias Agopian1eae0ee2013-06-05 16:59:15 -070056 const Layer::State& s(getDrawingState());
Mathias Agopian2f73af92013-03-05 15:50:58 -080057 return !(s.flags & layer_state_t::eLayerHidden) && s.alpha;
58}
59
60
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061// ---------------------------------------------------------------------------
62
63}; // namespace android