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)
|
|
|
|
: LayerBaseClient(flinger, client)
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerDim::~LayerDim()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
}; // namespace android
|