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 17// #define LOG_NDEBUG 0 18#undef LOG_TAG 19#define LOG_TAG "LayerDim" 20 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 28#include <ui/GraphicBuffer.h> 29 30#include "LayerDim.h" 31#include "SurfaceFlinger.h" 32#include "DisplayDevice.h" 33#include "RenderEngine/RenderEngine.h" 34 35namespace android { 36// --------------------------------------------------------------------------- 37 38LayerDim::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) { 41} 42 43LayerDim::~LayerDim() { 44} 45 46void LayerDim::onDraw(const sp<const DisplayDevice>& hw, 47 const Region& /* clip */, bool useIdentityTransform) const 48{ 49 const State& s(getDrawingState()); 50 if (s.alpha>0) { 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(); 57 } 58} 59 60bool LayerDim::isVisible() const { 61 const Layer::State& s(getDrawingState()); 62 return !(s.flags & layer_state_t::eLayerHidden) && s.alpha; 63} 64 65 66// --------------------------------------------------------------------------- 67 68}; // namespace android 69