LayerDim.cpp revision 875d8e1323536e16dcfc90c9674d7ad32116a69a
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#include <stdlib.h> 18#include <stdint.h> 19#include <sys/types.h> 20 21#include <utils/Errors.h> 22#include <utils/Log.h> 23 24#include <ui/GraphicBuffer.h> 25 26#include "LayerDim.h" 27#include "SurfaceFlinger.h" 28#include "DisplayDevice.h" 29#include "RenderEngine/RenderEngine.h" 30 31namespace android { 32// --------------------------------------------------------------------------- 33 34LayerDim::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) { 37} 38 39LayerDim::~LayerDim() { 40} 41 42void LayerDim::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const 43{ 44 const State& s(getDrawingState()); 45 if (s.alpha>0) { 46 LayerMesh mesh; 47 computeGeometry(hw, &mesh); 48 RenderEngine& engine(mFlinger->getRenderEngine()); 49 engine.setupDimLayerBlending(s.alpha); 50 engine.drawMesh2D(mesh.getVertices(), NULL, mesh.getVertexCount()); 51 engine.disableBlending(); 52 } 53} 54 55bool LayerDim::isVisible() const { 56 const Layer::State& s(getDrawingState()); 57 return !(s.flags & layer_state_t::eLayerHidden) && s.alpha; 58} 59 60 61// --------------------------------------------------------------------------- 62 63}; // namespace android 64