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>
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <ui/PixelFormat.h>
|
2009-05-04 21:17:04 +00:00
|
|
|
#include <ui/FramebufferNativeWindow.h>
|
2009-08-06 23:05:39 +00:00
|
|
|
#include <ui/EGLUtils.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 <pixelflinger/pixelflinger.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
#include "DisplayHardware/DisplayHardware.h"
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <hardware/gralloc.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2010-06-26 01:02:21 +00:00
|
|
|
#include "GLExtensions.h"
|
2010-08-11 00:14:02 +00:00
|
|
|
#include "HWComposer.h"
|
2011-08-01 23:32:21 +00:00
|
|
|
#include "SurfaceFlinger.h"
|
2010-06-26 01:02:21 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
using namespace android;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2009-03-04 03:31:44 +00:00
|
|
|
LOGE("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)
|
|
|
|
{
|
|
|
|
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) {
|
|
|
|
LOGE("%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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the display to the specified values.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
DisplayHardware::DisplayHardware(
|
|
|
|
const sp<SurfaceFlinger>& flinger,
|
|
|
|
uint32_t dpy)
|
2010-06-26 01:02:21 +00:00
|
|
|
: DisplayHardwareBase(flinger, dpy),
|
2011-08-01 23:32:21 +00:00
|
|
|
mFlinger(flinger), mFlags(0), mHwc(0)
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
init(dpy);
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayHardware::~DisplayHardware()
|
|
|
|
{
|
|
|
|
fini();
|
|
|
|
}
|
|
|
|
|
|
|
|
float DisplayHardware::getDpiX() const { return mDpiX; }
|
|
|
|
float DisplayHardware::getDpiY() const { return mDpiY; }
|
|
|
|
float DisplayHardware::getDensity() const { return mDensity; }
|
|
|
|
float DisplayHardware::getRefreshRate() const { return mRefreshRate; }
|
|
|
|
int DisplayHardware::getWidth() const { return mWidth; }
|
|
|
|
int DisplayHardware::getHeight() const { return mHeight; }
|
|
|
|
PixelFormat DisplayHardware::getFormat() const { return mFormat; }
|
2010-04-14 23:43:44 +00:00
|
|
|
uint32_t DisplayHardware::getMaxTextureSize() const { return mMaxTextureSize; }
|
2011-04-18 22:59:24 +00:00
|
|
|
|
|
|
|
uint32_t DisplayHardware::getMaxViewportDims() const {
|
|
|
|
return mMaxViewportDims[0] < mMaxViewportDims[1] ?
|
|
|
|
mMaxViewportDims[0] : mMaxViewportDims[1];
|
|
|
|
}
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2011-07-06 23:35:30 +00:00
|
|
|
static status_t selectConfigForPixelFormat(
|
|
|
|
EGLDisplay dpy,
|
|
|
|
EGLint const* attrs,
|
|
|
|
PixelFormat format,
|
|
|
|
EGLConfig* outConfig)
|
|
|
|
{
|
|
|
|
EGLConfig config = NULL;
|
|
|
|
EGLint numConfigs = -1, n=0;
|
|
|
|
eglGetConfigs(dpy, NULL, 0, &numConfigs);
|
|
|
|
EGLConfig* const configs = new EGLConfig[numConfigs];
|
|
|
|
eglChooseConfig(dpy, attrs, configs, numConfigs, &n);
|
|
|
|
for (int i=0 ; i<n ; i++) {
|
|
|
|
EGLint nativeVisualId = 0;
|
|
|
|
eglGetConfigAttrib(dpy, configs[i], EGL_NATIVE_VISUAL_ID, &nativeVisualId);
|
|
|
|
if (nativeVisualId>0 && format == nativeVisualId) {
|
|
|
|
*outConfig = configs[i];
|
|
|
|
delete [] configs;
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete [] configs;
|
|
|
|
return NAME_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
void DisplayHardware::init(uint32_t dpy)
|
|
|
|
{
|
2009-04-10 21:24:30 +00:00
|
|
|
mNativeWindow = new FramebufferNativeWindow();
|
2009-08-07 23:38:10 +00:00
|
|
|
framebuffer_device_t const * fbDev = mNativeWindow->getDevice();
|
2011-07-02 00:08:43 +00:00
|
|
|
if (!fbDev) {
|
|
|
|
LOGE("Display subsystem failed to initialize. check logs. exiting...");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2011-07-06 23:35:30 +00:00
|
|
|
int format;
|
|
|
|
ANativeWindow const * const window = mNativeWindow.get();
|
|
|
|
window->query(window, NATIVE_WINDOW_FORMAT, &format);
|
2010-06-26 01:02:21 +00:00
|
|
|
mDpiX = mNativeWindow->xdpi;
|
|
|
|
mDpiY = mNativeWindow->ydpi;
|
|
|
|
mRefreshRate = fbDev->fps;
|
2009-04-10 21:24:30 +00:00
|
|
|
|
2011-11-05 01:46:11 +00:00
|
|
|
|
|
|
|
/* FIXME: this is a temporary HACK until we are able to report the refresh rate
|
|
|
|
* properly from the HAL. The WindowManagerService now relies on this value.
|
|
|
|
*/
|
|
|
|
#ifndef REFRESH_RATE
|
|
|
|
mRefreshRate = fbDev->fps;
|
|
|
|
#else
|
|
|
|
mRefreshRate = REFRESH_RATE;
|
|
|
|
#warning "refresh rate set via makefile to REFRESH_RATE"
|
|
|
|
#endif
|
|
|
|
|
2010-06-26 01:02:21 +00:00
|
|
|
EGLint w, h, dummy;
|
|
|
|
EGLint numConfigs=0;
|
|
|
|
EGLSurface surface;
|
|
|
|
EGLContext context;
|
2011-07-06 23:35:30 +00:00
|
|
|
EGLBoolean result;
|
|
|
|
status_t err;
|
2010-06-26 01:02:21 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// initialize EGL
|
2009-09-05 01:49:03 +00:00
|
|
|
EGLint attribs[] = {
|
2011-07-06 23:35:30 +00:00
|
|
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
|
|
EGL_NONE, 0,
|
2009-03-04 03:31:44 +00:00
|
|
|
EGL_NONE
|
|
|
|
};
|
2009-09-05 01:49:03 +00:00
|
|
|
|
|
|
|
// debug: disable h/w rendering
|
|
|
|
char property[PROPERTY_VALUE_MAX];
|
|
|
|
if (property_get("debug.sf.hw", property, NULL) > 0) {
|
|
|
|
if (atoi(property) == 0) {
|
|
|
|
LOGW("H/W composition disabled");
|
|
|
|
attribs[2] = EGL_CONFIG_CAVEAT;
|
|
|
|
attribs[3] = EGL_SLOW_CONFIG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// TODO: all the extensions below should be queried through
|
|
|
|
// eglGetProcAddress().
|
|
|
|
|
|
|
|
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
|
|
|
eglInitialize(display, NULL, NULL);
|
|
|
|
eglGetConfigs(display, NULL, 0, &numConfigs);
|
2009-04-10 21:24:30 +00:00
|
|
|
|
2011-07-06 23:35:30 +00:00
|
|
|
EGLConfig config = NULL;
|
|
|
|
err = selectConfigForPixelFormat(display, attribs, format, &config);
|
2009-08-06 23:05:39 +00:00
|
|
|
LOGE_IF(err, "couldn't find an EGLConfig matching the screen format");
|
|
|
|
|
2009-08-07 23:38:10 +00:00
|
|
|
EGLint r,g,b,a;
|
|
|
|
eglGetConfigAttrib(display, config, EGL_RED_SIZE, &r);
|
|
|
|
eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &g);
|
|
|
|
eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &b);
|
|
|
|
eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &a);
|
|
|
|
|
2009-05-08 00:40:23 +00:00
|
|
|
if (mNativeWindow->isUpdateOnDemand()) {
|
2009-09-24 21:57:26 +00:00
|
|
|
mFlags |= PARTIAL_UPDATES;
|
2009-05-08 00:40:23 +00:00
|
|
|
}
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy) == EGL_TRUE) {
|
|
|
|
if (dummy == EGL_SLOW_CONFIG)
|
|
|
|
mFlags |= SLOW_CONFIG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create our main surface
|
|
|
|
*/
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL);
|
2010-06-26 01:02:21 +00:00
|
|
|
eglQuerySurface(display, surface, EGL_WIDTH, &mWidth);
|
|
|
|
eglQuerySurface(display, surface, EGL_HEIGHT, &mHeight);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2009-09-24 21:57:26 +00:00
|
|
|
if (mFlags & PARTIAL_UPDATES) {
|
|
|
|
// if we have partial updates, we definitely don't need to
|
|
|
|
// preserve the backbuffer, which may be costly.
|
2009-09-17 03:15:42 +00:00
|
|
|
eglSurfaceAttrib(display, surface,
|
|
|
|
EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);
|
|
|
|
}
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
if (eglQuerySurface(display, surface, EGL_SWAP_BEHAVIOR, &dummy) == EGL_TRUE) {
|
|
|
|
if (dummy == EGL_BUFFER_PRESERVED) {
|
|
|
|
mFlags |= BUFFER_PRESERVED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-19 02:41:12 +00:00
|
|
|
/* Read density from build-specific ro.sf.lcd_density property
|
2009-08-13 04:18:15 +00:00
|
|
|
* except if it is overridden by qemu.sf.lcd_density.
|
2009-06-19 02:41:12 +00:00
|
|
|
*/
|
|
|
|
if (property_get("qemu.sf.lcd_density", property, NULL) <= 0) {
|
|
|
|
if (property_get("ro.sf.lcd_density", property, NULL) <= 0) {
|
|
|
|
LOGW("ro.sf.lcd_density not defined, using 160 dpi by default.");
|
|
|
|
strcpy(property, "160");
|
2009-06-18 02:30:32 +00:00
|
|
|
}
|
2009-07-28 22:38:58 +00:00
|
|
|
} else {
|
|
|
|
/* for the emulator case, reset the dpi values too */
|
|
|
|
mDpiX = mDpiY = atoi(property);
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
mDensity = atoi(property) * (1.0f/160.0f);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create our OpenGL ES context
|
|
|
|
*/
|
|
|
|
|
2010-10-12 00:54:43 +00:00
|
|
|
|
|
|
|
EGLint contextAttributes[] = {
|
|
|
|
#ifdef EGL_IMG_context_priority
|
|
|
|
#ifdef HAS_CONTEXT_PRIORITY
|
|
|
|
#warning "using EGL_IMG_context_priority"
|
|
|
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
EGL_NONE, EGL_NONE
|
|
|
|
};
|
|
|
|
context = eglCreateContext(display, config, NULL, contextAttributes);
|
|
|
|
|
2010-06-26 01:02:21 +00:00
|
|
|
mDisplay = display;
|
|
|
|
mConfig = config;
|
|
|
|
mSurface = surface;
|
|
|
|
mContext = context;
|
|
|
|
mFormat = fbDev->format;
|
|
|
|
mPageFlipCount = 0;
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* Gather OpenGL ES extensions
|
|
|
|
*/
|
|
|
|
|
2011-07-06 23:35:30 +00:00
|
|
|
result = eglMakeCurrent(display, surface, surface, context);
|
|
|
|
if (!result) {
|
|
|
|
LOGE("Couldn't create a working GLES context. check logs. exiting...");
|
|
|
|
exit(0);
|
|
|
|
}
|
2010-06-26 01:02:21 +00:00
|
|
|
|
|
|
|
GLExtensions& extensions(GLExtensions::getInstance());
|
|
|
|
extensions.initWithGLStrings(
|
|
|
|
glGetString(GL_VENDOR),
|
|
|
|
glGetString(GL_RENDERER),
|
|
|
|
glGetString(GL_VERSION),
|
|
|
|
glGetString(GL_EXTENSIONS),
|
|
|
|
eglQueryString(display, EGL_VENDOR),
|
|
|
|
eglQueryString(display, EGL_VERSION),
|
|
|
|
eglQueryString(display, EGL_EXTENSIONS));
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2010-04-14 23:43:44 +00:00
|
|
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
|
2011-04-18 22:59:24 +00:00
|
|
|
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);
|
2010-04-14 23:43:44 +00:00
|
|
|
|
2012-01-04 20:05:49 +00:00
|
|
|
ALOGI("EGL informations:");
|
|
|
|
ALOGI("# of configs : %d", numConfigs);
|
|
|
|
ALOGI("vendor : %s", extensions.getEglVendor());
|
|
|
|
ALOGI("version : %s", extensions.getEglVersion());
|
|
|
|
ALOGI("extensions: %s", extensions.getEglExtension());
|
|
|
|
ALOGI("Client API: %s", eglQueryString(display, EGL_CLIENT_APIS)?:"Not Supported");
|
|
|
|
ALOGI("EGLSurface: %d-%d-%d-%d, config=%p", r, g, b, a, config);
|
|
|
|
|
|
|
|
ALOGI("OpenGL informations:");
|
|
|
|
ALOGI("vendor : %s", extensions.getVendor());
|
|
|
|
ALOGI("renderer : %s", extensions.getRenderer());
|
|
|
|
ALOGI("version : %s", extensions.getVersion());
|
|
|
|
ALOGI("extensions: %s", extensions.getExtension());
|
|
|
|
ALOGI("GL_MAX_TEXTURE_SIZE = %d", mMaxTextureSize);
|
|
|
|
ALOGI("GL_MAX_VIEWPORT_DIMS = %d x %d", mMaxViewportDims[0], mMaxViewportDims[1]);
|
|
|
|
ALOGI("flags = %08x", mFlags);
|
2010-04-14 23:43:44 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// Unbind the context from this thread
|
|
|
|
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
2010-08-11 00:14:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
// initialize the H/W composer
|
2011-08-01 23:32:21 +00:00
|
|
|
mHwc = new HWComposer(mFlinger);
|
2010-08-11 00:14:02 +00:00
|
|
|
if (mHwc->initCheck() == NO_ERROR) {
|
|
|
|
mHwc->setFrameBuffer(mDisplay, mSurface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HWComposer& DisplayHardware::getHwComposer() const {
|
|
|
|
return *mHwc;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up. Throw out our local state.
|
|
|
|
*
|
|
|
|
* (It's entirely possible we'll never get here, since this is meant
|
|
|
|
* for real hardware, which doesn't restart.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
void DisplayHardware::fini()
|
|
|
|
{
|
|
|
|
eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
|
|
eglTerminate(mDisplay);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayHardware::releaseScreen() const
|
|
|
|
{
|
|
|
|
DisplayHardwareBase::releaseScreen();
|
2010-09-09 09:33:05 +00:00
|
|
|
if (mHwc->initCheck() == NO_ERROR) {
|
|
|
|
mHwc->release();
|
|
|
|
}
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayHardware::acquireScreen() const
|
|
|
|
{
|
|
|
|
DisplayHardwareBase::acquireScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t DisplayHardware::getPageFlipCount() const {
|
2009-04-10 21:24:30 +00:00
|
|
|
return mPageFlipCount;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 23:18:16 +00:00
|
|
|
status_t DisplayHardware::compositionComplete() const {
|
|
|
|
return mNativeWindow->compositionComplete();
|
|
|
|
}
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2010-09-14 05:57:58 +00:00
|
|
|
int DisplayHardware::getCurrentBufferIndex() const {
|
|
|
|
return mNativeWindow->getCurrentBufferIndex();
|
|
|
|
}
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
void DisplayHardware::flip(const Region& dirty) const
|
|
|
|
{
|
|
|
|
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) {
|
2009-06-30 01:49:56 +00:00
|
|
|
mNativeWindow->setUpdateRectangle(dirty.getBounds());
|
2009-05-08 00:40:23 +00:00
|
|
|
}
|
|
|
|
|
2009-04-10 21:24:30 +00:00
|
|
|
mPageFlipCount++;
|
2010-08-11 00:14:02 +00:00
|
|
|
|
|
|
|
if (mHwc->initCheck() == NO_ERROR) {
|
|
|
|
mHwc->commit();
|
|
|
|
} else {
|
|
|
|
eglSwapBuffers(dpy, surface);
|
|
|
|
}
|
2009-03-04 03:31:44 +00:00
|
|
|
checkEGLErrors("eglSwapBuffers");
|
|
|
|
|
|
|
|
// for debugging
|
|
|
|
//glClearColor(1,0,0,0);
|
|
|
|
//glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t DisplayHardware::getFlags() const
|
|
|
|
{
|
|
|
|
return mFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayHardware::makeCurrent() const
|
|
|
|
{
|
|
|
|
eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
|
|
|
|
}
|
2010-12-02 00:38:01 +00:00
|
|
|
|
|
|
|
void DisplayHardware::dump(String8& res) const
|
|
|
|
{
|
|
|
|
mNativeWindow->dump(res);
|
|
|
|
}
|