Merge "Fix rotation displays frame N-1 briefly while rotating" into ics-mr1
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index 3fa2acb..33b2f00 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -110,7 +110,8 @@
// Place a file descriptor into the parcel. The given fd must remain
// valid for the lifetime of the parcel.
- status_t writeFileDescriptor(int fd);
+ // The Parcel does not take ownership of the given fd unless you ask it to.
+ status_t writeFileDescriptor(int fd, bool takeOwnership = false);
// Place a file descriptor into the parcel. A dup of the fd is made, which
// will be closed once the parcel is destroyed.
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index c7180ce..6b4c1a6 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -710,24 +710,19 @@
return err;
}
-status_t Parcel::writeFileDescriptor(int fd)
+status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership)
{
flat_binder_object obj;
obj.type = BINDER_TYPE_FD;
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
obj.handle = fd;
- obj.cookie = (void*)0;
+ obj.cookie = (void*) (takeOwnership ? 1 : 0);
return writeObject(obj, true);
}
status_t Parcel::writeDupFileDescriptor(int fd)
{
- flat_binder_object obj;
- obj.type = BINDER_TYPE_FD;
- obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
- obj.handle = dup(fd);
- obj.cookie = (void*)1;
- return writeObject(obj, true);
+ return writeFileDescriptor(dup(fd), true /*takeOwnership*/);
}
status_t Parcel::writeBlob(size_t len, WritableBlob* outBlob)
@@ -764,7 +759,7 @@
} else {
status = writeInt32(1);
if (!status) {
- status = writeFileDescriptor(fd);
+ status = writeFileDescriptor(fd, true /*takeOwnership*/);
if (!status) {
outBlob->init(true /*mapped*/, ptr, len);
return NO_ERROR;
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index 3e66a13..5855b63 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -8,6 +8,7 @@
LOCAL_SRC_FILES:= \
EGL/egl_tls.cpp \
+ EGL/egl_cache.cpp \
EGL/egl_display.cpp \
EGL/egl_object.cpp \
EGL/egl.cpp \
@@ -157,4 +158,3 @@
include $(BUILD_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))
-
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 1f9ce68..60ac34b 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -858,10 +858,17 @@
return NULL;
}
+ // The EGL_ANDROID_blob_cache extension should not be exposed to
+ // applications. It is used internally by the Android EGL layer.
+ if (!strcmp(procname, "eglSetBlobCacheFuncs")) {
+ return NULL;
+ }
+
__eglMustCastToProperFunctionPointerType addr;
addr = findProcAddress(procname, sExtentionMap, NELEM(sExtentionMap));
if (addr) return addr;
+
// this protects accesses to sGLExtentionMap and sGLExtentionSlot
pthread_mutex_lock(&sExtensionMapMutex);
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
new file mode 100644
index 0000000..1e64302
--- /dev/null
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -0,0 +1,95 @@
+/*
+ ** Copyright 2011, 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 "egl_cache.h"
+#include "egl_display.h"
+#include "egl_impl.h"
+#include "egldefs.h"
+
+// ----------------------------------------------------------------------------
+namespace android {
+// ----------------------------------------------------------------------------
+
+#define BC_EXT_STR "EGL_ANDROID_blob_cache"
+
+//
+// EGL_ANDROID_blob_cache types and functions
+//
+typedef khronos_ssize_t EGLsizei;
+
+typedef void (*EGLSetBlobFunc) (const void* key, EGLsizei keySize,
+ const void* value, EGLsizei valueSize);
+
+typedef EGLsizei (*EGLGetBlobFunc) (const void* key, EGLsizei keySize,
+ void* value, EGLsizei valueSize);
+
+typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSPROC) (EGLDisplay dpy,
+ EGLSetBlobFunc set, EGLGetBlobFunc get);
+
+//
+// egl_cache_t definition
+//
+static void setBlob(const void* key, EGLsizei keySize, const void* value,
+ EGLsizei valueSize) {
+}
+
+static EGLsizei getBlob(const void* key, EGLsizei keySize, void* value,
+ EGLsizei valueSize) {
+ return 0;
+}
+
+egl_cache_t* egl_cache_t::get() {
+ static egl_cache_t theCache;
+ return &theCache;
+}
+
+void egl_cache_t::initialize(egl_display_t *display) {
+ for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
+ egl_connection_t* const cnx = &gEGLImpl[i];
+ if (cnx->dso && cnx->major >= 0 && cnx->minor >= 0) {
+ const char* exts = display->disp[i].queryString.extensions;
+ size_t bcExtLen = strlen(BC_EXT_STR);
+ size_t extsLen = strlen(exts);
+ bool equal = !strcmp(BC_EXT_STR, exts);
+ bool atStart = !strncmp(BC_EXT_STR " ", exts, bcExtLen+1);
+ bool atEnd = (bcExtLen+1) < extsLen &&
+ !strcmp(" " BC_EXT_STR, exts + extsLen - (bcExtLen+1));
+ bool inMiddle = strstr(" " BC_EXT_STR " ", exts);
+ if (equal || atStart || atEnd || inMiddle) {
+ PFNEGLSETBLOBCACHEFUNCSPROC eglSetBlobCacheFuncs;
+ eglSetBlobCacheFuncs =
+ reinterpret_cast<PFNEGLSETBLOBCACHEFUNCSPROC>(
+ cnx->egl.eglGetProcAddress("eglSetBlobCacheFuncs"));
+ if (eglSetBlobCacheFuncs == NULL) {
+ LOGE("EGL_ANDROID_blob_cache advertised by display %d, "
+ "but unable to get eglSetBlobCacheFuncs", i);
+ continue;
+ }
+
+ eglSetBlobCacheFuncs(display->disp[i].dpy, setBlob, getBlob);
+ EGLint err = cnx->egl.eglGetError();
+ if (err != EGL_SUCCESS) {
+ LOGE("eglSetBlobCacheFuncs resulted in an error: %#x",
+ err);
+ }
+ }
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+}; // namespace android
+// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/egl_cache.h b/opengl/libs/EGL/egl_cache.h
new file mode 100644
index 0000000..1fcfacc
--- /dev/null
+++ b/opengl/libs/EGL/egl_cache.h
@@ -0,0 +1,33 @@
+/*
+ ** Copyright 2011, 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.
+ */
+
+// ----------------------------------------------------------------------------
+namespace android {
+// ----------------------------------------------------------------------------
+
+class egl_display_t;
+
+class egl_cache_t {
+public:
+
+ static egl_cache_t* get();
+
+ void initialize(egl_display_t* display);
+};
+
+// ----------------------------------------------------------------------------
+}; // namespace android
+// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index 83aafa6..0f92864 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -14,6 +14,7 @@
** limitations under the License.
*/
+#include "egl_cache.h"
#include "egl_display.h"
#include "egl_object.h"
#include "egl_tls.h"
@@ -170,6 +171,8 @@
}
}
+ egl_cache_t::get()->initialize(this);
+
EGLBoolean res = EGL_FALSE;
for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 61a8358..b916bd7 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -30,6 +30,10 @@
LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY -DNEVER_DEFAULT_TO_ASYNC_MODE
endif
+ifneq (,$(findstring $(TARGET_DEVICE),tuna toro maguro))
+ LOCAL_CFLAGS += -DREFRESH_RATE=48
+endif
+
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
index f4be168..329c052 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
@@ -141,6 +141,17 @@
mDpiY = mNativeWindow->ydpi;
mRefreshRate = fbDev->fps;
+
+/* 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
+
EGLint w, h, dummy;
EGLint numConfigs=0;
EGLSurface surface;