2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 // #define LOG_NDEBUG 0
19 #define LOG_TAG "LayerDim"
23 #include <sys/types.h>
25 #include <utils/Errors.h>
26 #include <utils/Log.h>
28 #include <ui/GraphicBuffer.h>
31 #include "SurfaceFlinger.h"
32 #include "DisplayDevice.h"
33 #include "RenderEngine/RenderEngine.h"
36 // ---------------------------------------------------------------------------
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) {
43 LayerDim::~LayerDim() {
46 void LayerDim::onDraw(const sp<const DisplayDevice>& hw,
47 const Region& /* clip */, bool useIdentityTransform) const
49 const State& s(getDrawingState());
51 Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2);
52 computeGeometry(hw, mesh, useIdentityTransform);
53 RenderEngine& engine(mFlinger->getRenderEngine());
54 engine.setupDimLayerBlending(s.alpha);
55 engine.drawMesh(mesh);
56 engine.disableBlending();
60 bool LayerDim::isVisible() const {
61 const Layer::State& s(getDrawingState());
62 return !isHiddenByPolicy() && s.alpha;
66 // ---------------------------------------------------------------------------
68 }; // namespace android