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>
|
|
|
|
|
2012-08-02 21:01:42 +00:00
|
|
|
#include <GLES/gl.h>
|
|
|
|
#include <GLES/glext.h>
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
#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"
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2012-08-27 23:28:24 +00:00
|
|
|
LayerDim::LayerDim(SurfaceFlinger* flinger, const sp<Client>& client)
|
2013-03-06 01:47:11 +00:00
|
|
|
: Layer(flinger, client) {
|
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
|
|
|
}
|
|
|
|
|
2012-08-05 07:40:46 +00:00
|
|
|
void LayerDim::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
const State& s(drawingState());
|
2012-04-16 10:14:05 +00:00
|
|
|
if (s.alpha>0) {
|
2010-06-26 01:02:21 +00:00
|
|
|
const GLfloat alpha = s.alpha/255.0f;
|
2012-08-05 07:40:46 +00:00
|
|
|
const uint32_t fbHeight = hw->getHeight();
|
2011-10-18 21:49:27 +00:00
|
|
|
glDisable(GL_TEXTURE_EXTERNAL_OES);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
2011-01-26 04:17:45 +00:00
|
|
|
|
|
|
|
if (s.alpha == 0xFF) {
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
} else {
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
|
|
|
|
2010-06-26 01:02:21 +00:00
|
|
|
glColor4f(0, 0, 0, alpha);
|
|
|
|
|
2012-06-29 21:12:52 +00:00
|
|
|
LayerMesh mesh;
|
|
|
|
computeGeometry(hw, &mesh);
|
|
|
|
|
|
|
|
glVertexPointer(2, GL_FLOAT, 0, mesh.getVertices());
|
|
|
|
glDrawArrays(GL_TRIANGLE_FAN, 0, mesh.getVertexCount());
|
2009-06-19 01:48:39 +00:00
|
|
|
|
2011-10-18 21:49:27 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-05 23:50:58 +00:00
|
|
|
sp<ISurface> LayerDim::createSurface()
|
|
|
|
{
|
|
|
|
class BSurface : public BnSurface, public LayerCleaner {
|
|
|
|
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const { return 0; }
|
|
|
|
public:
|
|
|
|
BSurface(const sp<SurfaceFlinger>& flinger,
|
2013-03-06 01:47:11 +00:00
|
|
|
const sp<Layer>& layer)
|
2013-03-05 23:50:58 +00:00
|
|
|
: LayerCleaner(flinger, layer) { }
|
|
|
|
};
|
|
|
|
sp<ISurface> sur(new BSurface(mFlinger, this));
|
|
|
|
return sur;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LayerDim::isVisible() const {
|
2013-03-06 01:47:11 +00:00
|
|
|
const Layer::State& s(drawingState());
|
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
|