2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <utils/Errors.h>
|
|
|
|
#include <utils/Log.h>
|
|
|
|
|
2009-10-06 00:07:12 +00:00
|
|
|
#include <ui/GraphicBuffer.h>
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
#include "LayerDim.h"
|
|
|
|
#include "SurfaceFlinger.h"
|
2012-08-01 06:09:07 +00:00
|
|
|
#include "DisplayDevice.h"
|
2013-06-07 22:35:48 +00:00
|
|
|
#include "RenderEngine/RenderEngine.h"
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2013-03-13 00:11:48 +00:00
|
|
|
LayerDim::LayerDim(SurfaceFlinger* flinger, const sp<Client>& client,
|
|
|
|
const String8& name, uint32_t w, uint32_t h, uint32_t flags)
|
|
|
|
: Layer(flinger, client, name, w, h, flags) {
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2013-03-06 01:47:11 +00:00
|
|
|
LayerDim::~LayerDim() {
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 23:03:43 +00:00
|
|
|
void LayerDim::onDraw(const sp<const DisplayDevice>& hw,
|
|
|
|
const Region& /* clip */, bool useIdentityTransform) const
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
2013-06-05 23:59:15 +00:00
|
|
|
const State& s(getDrawingState());
|
2012-04-16 10:14:05 +00:00
|
|
|
if (s.alpha>0) {
|
2013-08-08 04:24:32 +00:00
|
|
|
Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2);
|
2014-02-14 23:03:43 +00:00
|
|
|
computeGeometry(hw, mesh, useIdentityTransform);
|
2013-06-07 22:35:48 +00:00
|
|
|
RenderEngine& engine(mFlinger->getRenderEngine());
|
|
|
|
engine.setupDimLayerBlending(s.alpha);
|
2013-08-08 04:24:32 +00:00
|
|
|
engine.drawMesh(mesh);
|
2013-06-07 22:35:48 +00:00
|
|
|
engine.disableBlending();
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-05 23:50:58 +00:00
|
|
|
bool LayerDim::isVisible() const {
|
2013-06-05 23:59:15 +00:00
|
|
|
const Layer::State& s(getDrawingState());
|
2013-03-05 23:50:58 +00:00
|
|
|
return !(s.flags & layer_state_t::eLayerHidden) && s.alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
}; // namespace android
|