Home | History | Annotate | Download | only in surfaceflinger
      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 
     31 namespace android {
     32 // ---------------------------------------------------------------------------
     33 
     34 LayerDim::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 
     39 LayerDim::~LayerDim() {
     40 }
     41 
     42 void LayerDim::onDraw(const sp<const DisplayDevice>& hw,
     43         const Region& /* clip */, bool useIdentityTransform) const
     44 {
     45     const State& s(getDrawingState());
     46     if (s.alpha>0) {
     47         Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2);
     48         computeGeometry(hw, mesh, useIdentityTransform);
     49         RenderEngine& engine(mFlinger->getRenderEngine());
     50         engine.setupDimLayerBlending(s.alpha);
     51         engine.drawMesh(mesh);
     52         engine.disableBlending();
     53     }
     54 }
     55 
     56 bool LayerDim::isVisible() const {
     57     const Layer::State& s(getDrawingState());
     58     return !(s.flags & layer_state_t::eLayerHidden) && s.alpha;
     59 }
     60 
     61 
     62 // ---------------------------------------------------------------------------
     63 
     64 }; // namespace android
     65