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 <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <utils/RefBase.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
#include <utils/Log.h>
|
|
|
|
|
2012-07-26 01:56:13 +00:00
|
|
|
#include <ui/DisplayInfo.h>
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <ui/PixelFormat.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
#include <GLES/gl.h>
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <EGL/egl.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
#include <EGL/eglext.h>
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <hardware/gralloc.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-06-21 00:51:20 +00:00
|
|
|
#include "DisplayHardware/FramebufferSurface.h"
|
|
|
|
#include "DisplayHardware/HWComposer.h"
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
#include "DisplayDevice.h"
|
2010-06-26 01:02:21 +00:00
|
|
|
#include "GLExtensions.h"
|
2011-08-01 23:32:21 +00:00
|
|
|
#include "SurfaceFlinger.h"
|
2012-07-24 06:11:29 +00:00
|
|
|
#include "LayerBase.h"
|
2010-06-26 01:02:21 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2009-03-04 03:31:44 +00:00
|
|
|
using namespace android;
|
2012-07-12 21:25:33 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
static __attribute__((noinline))
|
|
|
|
void checkGLErrors()
|
|
|
|
{
|
fix [2068105] implement queueBuffer/lockBuffer/dequeueBuffer properly
Rewrote SurfaceFlinger's buffer management from the ground-up.
The design now support an arbitrary number of buffers per surface, however the current implementation is limited to four. Currently only 2 buffers are used in practice.
The main new feature is to be able to dequeue all buffers at once (very important when there are only two).
A client can dequeue all buffers until there are none available, it can lock all buffers except the last one that is used for composition. The client will block then, until a new buffer is enqueued.
The current implementation requires that buffers are locked in the same order they are dequeued and enqueued in the same order they are locked. Only one buffer can be locked at a time.
eg. Allowed sequence: DQ, DQ, LOCK, Q, LOCK, Q
eg. Forbidden sequence: DQ, DQ, LOCK, LOCK, Q, Q
2009-09-07 23:32:45 +00:00
|
|
|
do {
|
|
|
|
// there could be more than one error flag
|
|
|
|
GLenum error = glGetError();
|
|
|
|
if (error == GL_NO_ERROR)
|
|
|
|
break;
|
2012-01-06 19:20:56 +00:00
|
|
|
ALOGE("GL error 0x%04x", int(error));
|
fix [2068105] implement queueBuffer/lockBuffer/dequeueBuffer properly
Rewrote SurfaceFlinger's buffer management from the ground-up.
The design now support an arbitrary number of buffers per surface, however the current implementation is limited to four. Currently only 2 buffers are used in practice.
The main new feature is to be able to dequeue all buffers at once (very important when there are only two).
A client can dequeue all buffers until there are none available, it can lock all buffers except the last one that is used for composition. The client will block then, until a new buffer is enqueued.
The current implementation requires that buffers are locked in the same order they are dequeued and enqueued in the same order they are locked. Only one buffer can be locked at a time.
eg. Allowed sequence: DQ, DQ, LOCK, Q, LOCK, Q
eg. Forbidden sequence: DQ, DQ, LOCK, LOCK, Q, Q
2009-09-07 23:32:45 +00:00
|
|
|
} while(true);
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __attribute__((noinline))
|
|
|
|
void checkEGLErrors(const char* token)
|
|
|
|
{
|
2012-02-25 00:42:46 +00:00
|
|
|
struct EGLUtils {
|
|
|
|
static const char *strerror(EGLint err) {
|
|
|
|
switch (err){
|
|
|
|
case EGL_SUCCESS: return "EGL_SUCCESS";
|
|
|
|
case EGL_NOT_INITIALIZED: return "EGL_NOT_INITIALIZED";
|
|
|
|
case EGL_BAD_ACCESS: return "EGL_BAD_ACCESS";
|
|
|
|
case EGL_BAD_ALLOC: return "EGL_BAD_ALLOC";
|
|
|
|
case EGL_BAD_ATTRIBUTE: return "EGL_BAD_ATTRIBUTE";
|
|
|
|
case EGL_BAD_CONFIG: return "EGL_BAD_CONFIG";
|
|
|
|
case EGL_BAD_CONTEXT: return "EGL_BAD_CONTEXT";
|
|
|
|
case EGL_BAD_CURRENT_SURFACE: return "EGL_BAD_CURRENT_SURFACE";
|
|
|
|
case EGL_BAD_DISPLAY: return "EGL_BAD_DISPLAY";
|
|
|
|
case EGL_BAD_MATCH: return "EGL_BAD_MATCH";
|
|
|
|
case EGL_BAD_NATIVE_PIXMAP: return "EGL_BAD_NATIVE_PIXMAP";
|
|
|
|
case EGL_BAD_NATIVE_WINDOW: return "EGL_BAD_NATIVE_WINDOW";
|
|
|
|
case EGL_BAD_PARAMETER: return "EGL_BAD_PARAMETER";
|
|
|
|
case EGL_BAD_SURFACE: return "EGL_BAD_SURFACE";
|
|
|
|
case EGL_CONTEXT_LOST: return "EGL_CONTEXT_LOST";
|
|
|
|
default: return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
EGLint error = eglGetError();
|
fix [2068105] implement queueBuffer/lockBuffer/dequeueBuffer properly
Rewrote SurfaceFlinger's buffer management from the ground-up.
The design now support an arbitrary number of buffers per surface, however the current implementation is limited to four. Currently only 2 buffers are used in practice.
The main new feature is to be able to dequeue all buffers at once (very important when there are only two).
A client can dequeue all buffers until there are none available, it can lock all buffers except the last one that is used for composition. The client will block then, until a new buffer is enqueued.
The current implementation requires that buffers are locked in the same order they are dequeued and enqueued in the same order they are locked. Only one buffer can be locked at a time.
eg. Allowed sequence: DQ, DQ, LOCK, Q, LOCK, Q
eg. Forbidden sequence: DQ, DQ, LOCK, LOCK, Q, Q
2009-09-07 23:32:45 +00:00
|
|
|
if (error && error != EGL_SUCCESS) {
|
2012-01-06 19:20:56 +00:00
|
|
|
ALOGE("%s: EGL error 0x%04x (%s)",
|
2009-08-07 23:38:10 +00:00
|
|
|
token, int(error), EGLUtils::strerror(error));
|
fix [2068105] implement queueBuffer/lockBuffer/dequeueBuffer properly
Rewrote SurfaceFlinger's buffer management from the ground-up.
The design now support an arbitrary number of buffers per surface, however the current implementation is limited to four. Currently only 2 buffers are used in practice.
The main new feature is to be able to dequeue all buffers at once (very important when there are only two).
A client can dequeue all buffers until there are none available, it can lock all buffers except the last one that is used for composition. The client will block then, until a new buffer is enqueued.
The current implementation requires that buffers are locked in the same order they are dequeued and enqueued in the same order they are locked. Only one buffer can be locked at a time.
eg. Allowed sequence: DQ, DQ, LOCK, Q, LOCK, Q
eg. Forbidden sequence: DQ, DQ, LOCK, LOCK, Q, Q
2009-09-07 23:32:45 +00:00
|
|
|
}
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* Initialize the display to the specified values.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-08-03 01:32:23 +00:00
|
|
|
DisplayDevice::DisplayDevice()
|
|
|
|
: mId(0),
|
|
|
|
mDisplay(EGL_NO_DISPLAY),
|
|
|
|
mSurface(EGL_NO_SURFACE),
|
|
|
|
mContext(EGL_NO_CONTEXT)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
DisplayDevice::DisplayDevice(
|
2009-03-04 03:31:44 +00:00
|
|
|
const sp<SurfaceFlinger>& flinger,
|
2012-07-12 21:25:33 +00:00
|
|
|
int display,
|
|
|
|
const sp<SurfaceTextureClient>& surface,
|
|
|
|
EGLConfig config)
|
2012-08-03 01:32:23 +00:00
|
|
|
: mFlinger(flinger),
|
|
|
|
mId(display),
|
|
|
|
mNativeWindow(surface),
|
|
|
|
mDisplay(EGL_NO_DISPLAY),
|
|
|
|
mSurface(EGL_NO_SURFACE),
|
|
|
|
mContext(EGL_NO_CONTEXT),
|
|
|
|
mDpiX(), mDpiY(),
|
|
|
|
mRefreshRate(),
|
|
|
|
mDensity(),
|
|
|
|
mDisplayWidth(), mDisplayHeight(), mFormat(),
|
|
|
|
mFlags(),
|
|
|
|
mPageFlipCount(),
|
|
|
|
mRefreshPeriod(),
|
|
|
|
mSecureLayerVisible(false),
|
|
|
|
mScreenAcquired(false),
|
|
|
|
mOrientation(),
|
|
|
|
mLayerStack(0)
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
2012-07-12 21:25:33 +00:00
|
|
|
init(config);
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
DisplayDevice::~DisplayDevice() {
|
2012-08-03 01:32:23 +00:00
|
|
|
// DO NOT call terminate() from here, because we create
|
|
|
|
// temporaries of this class (on the stack typically), and we don't
|
|
|
|
// want to destroy the EGLSurface in that case
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayDevice::terminate() {
|
|
|
|
if (mSurface != EGL_NO_SURFACE) {
|
|
|
|
eglDestroySurface(mDisplay, mSurface);
|
|
|
|
mSurface = EGL_NO_SURFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayDevice::isValid() const {
|
|
|
|
return mFlinger != NULL;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
float DisplayDevice::getDpiX() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
return mDpiX;
|
2011-04-18 22:59:24 +00:00
|
|
|
}
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
float DisplayDevice::getDpiY() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
return mDpiY;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
float DisplayDevice::getDensity() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
return mDensity;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
float DisplayDevice::getRefreshRate() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
return mRefreshRate;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
int DisplayDevice::getWidth() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
return mDisplayWidth;
|
2011-07-06 23:35:30 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
int DisplayDevice::getHeight() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
return mDisplayHeight;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
PixelFormat DisplayDevice::getFormat() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
return mFormat;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
EGLSurface DisplayDevice::getEGLSurface() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
return mSurface;
|
|
|
|
}
|
2011-07-06 23:35:30 +00:00
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
status_t DisplayDevice::getInfo(DisplayInfo* info) const {
|
2012-07-26 01:56:13 +00:00
|
|
|
info->w = getWidth();
|
|
|
|
info->h = getHeight();
|
|
|
|
info->xdpi = getDpiX();
|
|
|
|
info->ydpi = getDpiY();
|
|
|
|
info->fps = getRefreshRate();
|
|
|
|
info->density = getDensity();
|
|
|
|
info->orientation = getOrientation();
|
|
|
|
// TODO: this needs to go away (currently needed only by webkit)
|
|
|
|
getPixelFormatInfo(getFormat(), &info->pixelFormatInfo);
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
void DisplayDevice::init(EGLConfig config)
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
2012-07-12 21:25:33 +00:00
|
|
|
ANativeWindow* const window = mNativeWindow.get();
|
|
|
|
|
|
|
|
int concreteType;
|
|
|
|
window->query(window, NATIVE_WINDOW_CONCRETE_TYPE, &concreteType);
|
|
|
|
if (concreteType == NATIVE_WINDOW_FRAMEBUFFER) {
|
|
|
|
mFramebufferSurface = static_cast<FramebufferSurface *>(mNativeWindow.get());
|
2011-07-02 00:08:43 +00:00
|
|
|
}
|
|
|
|
|
2011-07-06 23:35:30 +00:00
|
|
|
int format;
|
|
|
|
window->query(window, NATIVE_WINDOW_FORMAT, &format);
|
2012-07-12 21:25:33 +00:00
|
|
|
mDpiX = window->xdpi;
|
|
|
|
mDpiY = window->ydpi;
|
|
|
|
if (mFramebufferSurface != NULL) {
|
|
|
|
mRefreshRate = mFramebufferSurface->getRefreshRate();
|
|
|
|
} else {
|
|
|
|
mRefreshRate = 60;
|
2012-03-22 19:15:54 +00:00
|
|
|
}
|
2012-07-12 21:25:33 +00:00
|
|
|
mRefreshPeriod = nsecs_t(1e9 / mRefreshRate);
|
2011-11-05 01:46:11 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
|
|
|
|
// TODO: Not sure if display density should handled by SF any longer
|
2012-03-22 19:15:54 +00:00
|
|
|
class Density {
|
|
|
|
static int getDensityFromProperty(char const* propName) {
|
|
|
|
char property[PROPERTY_VALUE_MAX];
|
|
|
|
int density = 0;
|
|
|
|
if (property_get(propName, property, NULL) > 0) {
|
|
|
|
density = atoi(property);
|
|
|
|
}
|
|
|
|
return density;
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
static int getEmuDensity() {
|
|
|
|
return getDensityFromProperty("qemu.sf.lcd_density"); }
|
|
|
|
static int getBuildDensity() {
|
|
|
|
return getDensityFromProperty("ro.sf.lcd_density"); }
|
|
|
|
};
|
|
|
|
// The density of the device is provided by a build property
|
|
|
|
mDensity = Density::getBuildDensity() / 160.0f;
|
|
|
|
if (mDensity == 0) {
|
|
|
|
// the build doesn't provide a density -- this is wrong!
|
|
|
|
// use xdpi instead
|
|
|
|
ALOGE("ro.sf.lcd_density must be defined as a build property");
|
|
|
|
mDensity = mDpiX / 160.0f;
|
|
|
|
}
|
|
|
|
if (Density::getEmuDensity()) {
|
|
|
|
// if "qemu.sf.lcd_density" is specified, it overrides everything
|
|
|
|
mDpiX = mDpiY = mDensity = Density::getEmuDensity();
|
|
|
|
mDensity /= 160.0f;
|
|
|
|
}
|
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
/*
|
|
|
|
* Create our display's surface
|
2012-03-22 19:15:54 +00:00
|
|
|
*/
|
2011-11-05 01:46:11 +00:00
|
|
|
|
2010-06-26 01:02:21 +00:00
|
|
|
EGLSurface surface;
|
2012-07-12 21:25:33 +00:00
|
|
|
EGLint w, h;
|
2009-03-04 03:31:44 +00:00
|
|
|
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
2012-07-12 21:25:33 +00:00
|
|
|
surface = eglCreateWindowSurface(display, config, window, NULL);
|
2012-06-21 00:51:20 +00:00
|
|
|
eglQuerySurface(display, surface, EGL_WIDTH, &mDisplayWidth);
|
|
|
|
eglQuerySurface(display, surface, EGL_HEIGHT, &mDisplayHeight);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
if (mFramebufferSurface != NULL) {
|
|
|
|
if (mFramebufferSurface->isUpdateOnDemand()) {
|
|
|
|
mFlags |= PARTIAL_UPDATES;
|
|
|
|
// if we have partial updates, we definitely don't need to
|
|
|
|
// preserve the backbuffer, which may be costly.
|
|
|
|
eglSurfaceAttrib(display, surface,
|
|
|
|
EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);
|
|
|
|
}
|
2009-09-17 03:15:42 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 01:02:21 +00:00
|
|
|
mDisplay = display;
|
|
|
|
mSurface = surface;
|
2012-07-12 21:25:33 +00:00
|
|
|
mFormat = format;
|
2010-06-26 01:02:21 +00:00
|
|
|
mPageFlipCount = 0;
|
|
|
|
|
2012-07-25 04:08:59 +00:00
|
|
|
// initialize the display orientation transform.
|
2012-08-01 06:09:07 +00:00
|
|
|
DisplayDevice::setOrientation(ISurfaceComposer::eOrientationDefault);
|
2010-08-11 00:14:02 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
uint32_t DisplayDevice::getPageFlipCount() const {
|
2009-04-10 21:24:30 +00:00
|
|
|
return mPageFlipCount;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
nsecs_t DisplayDevice::getRefreshPeriod() const {
|
2012-01-20 02:34:40 +00:00
|
|
|
return mRefreshPeriod;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
status_t DisplayDevice::compositionComplete() const {
|
2012-07-12 21:25:33 +00:00
|
|
|
if (mFramebufferSurface == NULL) {
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
return mFramebufferSurface->compositionComplete();
|
2009-09-17 23:18:16 +00:00
|
|
|
}
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
void DisplayDevice::flip(const Region& dirty) const
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
checkGLErrors();
|
|
|
|
|
|
|
|
EGLDisplay dpy = mDisplay;
|
|
|
|
EGLSurface surface = mSurface;
|
|
|
|
|
2009-06-12 00:19:54 +00:00
|
|
|
#ifdef EGL_ANDROID_swap_rectangle
|
2009-05-05 02:29:25 +00:00
|
|
|
if (mFlags & SWAP_RECTANGLE) {
|
2009-06-27 02:06:36 +00:00
|
|
|
const Region newDirty(dirty.intersect(bounds()));
|
|
|
|
const Rect b(newDirty.getBounds());
|
2009-05-05 02:29:25 +00:00
|
|
|
eglSetSwapRectangleANDROID(dpy, surface,
|
|
|
|
b.left, b.top, b.width(), b.height());
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
2009-06-12 00:19:54 +00:00
|
|
|
#endif
|
|
|
|
|
2009-09-24 21:57:26 +00:00
|
|
|
if (mFlags & PARTIAL_UPDATES) {
|
2012-07-12 21:25:33 +00:00
|
|
|
if (mFramebufferSurface != NULL) {
|
|
|
|
mFramebufferSurface->setUpdateRectangle(dirty.getBounds());
|
|
|
|
}
|
2009-05-08 00:40:23 +00:00
|
|
|
}
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
mPageFlipCount++;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
uint32_t DisplayDevice::getFlags() const
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
return mFlags;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
void DisplayDevice::dump(String8& res) const
|
2010-12-02 00:38:01 +00:00
|
|
|
{
|
2012-07-12 21:25:33 +00:00
|
|
|
if (mFramebufferSurface != NULL) {
|
|
|
|
mFramebufferSurface->dump(res);
|
|
|
|
}
|
2010-12-02 00:38:01 +00:00
|
|
|
}
|
2012-06-21 00:51:20 +00:00
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
void DisplayDevice::makeCurrent(const DisplayDevice& hw, EGLContext ctx) {
|
2012-08-01 02:01:53 +00:00
|
|
|
EGLSurface sur = eglGetCurrentSurface(EGL_DRAW);
|
|
|
|
if (sur != hw.mSurface) {
|
|
|
|
EGLDisplay dpy = eglGetCurrentDisplay();
|
|
|
|
eglMakeCurrent(dpy, hw.mSurface, hw.mSurface, ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-21 00:51:20 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp<LayerBase> >& layers) {
|
2012-07-11 20:48:17 +00:00
|
|
|
mVisibleLayersSortedByZ = layers;
|
|
|
|
size_t count = layers.size();
|
|
|
|
for (size_t i=0 ; i<count ; i++) {
|
|
|
|
if (layers[i]->isSecure()) {
|
|
|
|
mSecureLayerVisible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
Vector< sp<LayerBase> > DisplayDevice::getVisibleLayersSortedByZ() const {
|
2012-07-11 20:48:17 +00:00
|
|
|
return mVisibleLayersSortedByZ;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
bool DisplayDevice::getSecureLayerVisible() const {
|
2012-07-11 20:48:17 +00:00
|
|
|
return mSecureLayerVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2012-08-02 21:01:42 +00:00
|
|
|
|
|
|
|
bool DisplayDevice::canDraw() const {
|
|
|
|
return mScreenAcquired;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayDevice::releaseScreen() const {
|
|
|
|
mScreenAcquired = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayDevice::acquireScreen() const {
|
|
|
|
mScreenAcquired = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DisplayDevice::isScreenAcquired() const {
|
|
|
|
return mScreenAcquired;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2012-07-11 20:48:17 +00:00
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
status_t DisplayDevice::orientationToTransfrom(
|
2012-06-21 00:51:20 +00:00
|
|
|
int orientation, int w, int h, Transform* tr)
|
|
|
|
{
|
|
|
|
uint32_t flags = 0;
|
|
|
|
switch (orientation) {
|
|
|
|
case ISurfaceComposer::eOrientationDefault:
|
|
|
|
flags = Transform::ROT_0;
|
|
|
|
break;
|
|
|
|
case ISurfaceComposer::eOrientation90:
|
|
|
|
flags = Transform::ROT_90;
|
|
|
|
break;
|
|
|
|
case ISurfaceComposer::eOrientation180:
|
|
|
|
flags = Transform::ROT_180;
|
|
|
|
break;
|
|
|
|
case ISurfaceComposer::eOrientation270:
|
|
|
|
flags = Transform::ROT_270;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return BAD_VALUE;
|
|
|
|
}
|
|
|
|
tr->set(flags, w, h);
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
status_t DisplayDevice::setOrientation(int orientation) {
|
2012-07-25 04:08:59 +00:00
|
|
|
int w = mDisplayWidth;
|
|
|
|
int h = mDisplayHeight;
|
2012-06-21 00:51:20 +00:00
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
DisplayDevice::orientationToTransfrom(
|
2012-07-25 04:08:59 +00:00
|
|
|
orientation, w, h, &mGlobalTransform);
|
2012-06-21 00:51:20 +00:00
|
|
|
if (orientation & ISurfaceComposer::eOrientationSwapMask) {
|
2012-07-25 04:08:59 +00:00
|
|
|
int tmp = w;
|
|
|
|
w = h;
|
|
|
|
h = tmp;
|
2012-06-21 00:51:20 +00:00
|
|
|
}
|
|
|
|
mOrientation = orientation;
|
2012-08-03 01:32:23 +00:00
|
|
|
dirtyRegion.set(bounds());
|
2012-06-21 00:51:20 +00:00
|
|
|
return NO_ERROR;
|
|
|
|
}
|