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"
|
|
|
|
#include "DisplayHardware/DisplayHardware.h"
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
LayerDim::LayerDim(SurfaceFlinger* flinger, DisplayID display,
|
2010-06-03 06:28:45 +00:00
|
|
|
const sp<Client>& client)
|
|
|
|
: LayerBaseClient(flinger, display, client)
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerDim::~LayerDim()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerDim::onDraw(const Region& clip) const
|
|
|
|
{
|
|
|
|
const State& s(drawingState());
|
2009-05-11 07:03:41 +00:00
|
|
|
Region::const_iterator it = clip.begin();
|
|
|
|
Region::const_iterator const end = clip.end();
|
|
|
|
if (s.alpha>0 && (it != end)) {
|
2009-03-04 03:31:44 +00:00
|
|
|
const DisplayHardware& hw(graphicPlane(0).displayHardware());
|
2010-06-26 01:02:21 +00:00
|
|
|
const GLfloat alpha = s.alpha/255.0f;
|
2009-04-10 21:24:30 +00:00
|
|
|
const uint32_t fbHeight = hw.getHeight();
|
|
|
|
glDisable(GL_DITHER);
|
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);
|
|
|
|
|
2010-09-15 22:46:24 +00:00
|
|
|
#if defined(GL_OES_EGL_image_external)
|
2010-06-26 01:02:21 +00:00
|
|
|
if (GLExtensions::getInstance().haveTextureExternal()) {
|
|
|
|
glDisable(GL_TEXTURE_EXTERNAL_OES);
|
|
|
|
}
|
2010-06-15 04:20:00 +00:00
|
|
|
#endif
|
2010-06-29 22:31:58 +00:00
|
|
|
glDisable(GL_TEXTURE_2D);
|
2009-06-19 01:48:39 +00:00
|
|
|
|
2011-02-03 00:03:19 +00:00
|
|
|
glVertexPointer(2, GL_FLOAT, 0, mVertices);
|
2009-06-19 01:48:39 +00:00
|
|
|
|
2009-05-11 07:03:41 +00:00
|
|
|
while (it != end) {
|
|
|
|
const Rect& r = *it++;
|
2009-04-10 21:24:30 +00:00
|
|
|
const GLint sy = fbHeight - (r.top + r.height());
|
|
|
|
glScissor(r.left, sy, r.width(), r.height());
|
|
|
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-19 01:48:39 +00:00
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
}; // namespace android
|