Merge "Fix 5240036: Generate a reasonable bitrate for intermediate clips."
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index 710ef94..0bee0f1 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -219,9 +219,12 @@
if (i < 0) {
return i;
}
- mSurfaceTexture->queueBuffer(i, timestamp,
+ status_t err = mSurfaceTexture->queueBuffer(i, timestamp,
&mDefaultWidth, &mDefaultHeight, &mTransformHint);
- return OK;
+ if (err != OK) {
+ LOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
+ }
+ return err;
}
int SurfaceTextureClient::query(int what, int* value) const {
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index e94e50e..325193c 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -23,6 +23,7 @@
#include <limits.h>
#include <cutils/log.h>
+#include <cutils/properties.h>
#include <EGL/egl.h>
@@ -45,6 +46,39 @@
ANDROID_SINGLETON_STATIC_INSTANCE( Loader )
+/* This function is called to check whether we run inside the emulator,
+ * and if this is the case whether GLES GPU emulation is supported.
+ *
+ * Returned values are:
+ * -1 -> not running inside the emulator
+ * 0 -> running inside the emulator, but GPU emulation not supported
+ * 1 -> running inside the emulator, GPU emulation is supported
+ * through the "emulation" config.
+ */
+static int
+checkGlesEmulationStatus(void)
+{
+ /* We're going to check for the following kernel parameters:
+ *
+ * qemu=1 -> tells us that we run inside the emulator
+ * android.qemu.gles=<number> -> tells us the GLES GPU emulation status
+ *
+ * Note that we will return <number> if we find it. This let us support
+ * more additionnal emulation modes in the future.
+ */
+ char prop[PROPERTY_VALUE_MAX];
+ int result = -1;
+
+ /* First, check for qemu=1 */
+ property_get("ro.kernel.qemu",prop,"0");
+ if (atoi(prop) != 1)
+ return -1;
+
+ /* We are in the emulator, get GPU status value */
+ property_get("ro.kernel.qemu.gles",prop,"0");
+ return atoi(prop);
+}
+
// ----------------------------------------------------------------------------
Loader::driver_t::driver_t(void* gles)
@@ -94,6 +128,15 @@
{
char line[256];
char tag[256];
+
+ /* Special case for GLES emulation */
+ if (checkGlesEmulationStatus() == 0) {
+ LOGD("Emulator without GPU support detected. Fallback to software renderer.");
+ gConfig.add( entry_t(0, 0, "android") );
+ return;
+ }
+
+ /* Otherwise, use egl.cfg */
FILE* cfg = fopen("/system/lib/egl/egl.cfg", "r");
if (cfg == NULL) {
// default config
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 7d1bdf0..0ff1cce 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -108,8 +108,21 @@
}
status_t HWComposer::release() const {
- int err = mHwc->set(mHwc, NULL, NULL, NULL);
- return (status_t)err;
+ if (mHwc) {
+ int err = mHwc->set(mHwc, NULL, NULL, NULL);
+ return (status_t)err;
+ }
+ return NO_ERROR;
+}
+
+status_t HWComposer::disable() {
+ if (mHwc) {
+ free(mList);
+ mList = NULL;
+ int err = mHwc->prepare(mHwc, NULL);
+ return (status_t)err;
+ }
+ return NO_ERROR;
}
size_t HWComposer::getNumLayers() const {
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index 983898a..77c1a4b 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -50,6 +50,9 @@
// Asks the HAL what it can do
status_t prepare() const;
+ // disable hwc until next createWorkList
+ status_t disable();
+
// commits the list
status_t commit() const;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 598220f..4a3a8ea 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -817,6 +817,20 @@
mHwWorkListDirty = false;
HWComposer& hwc(graphicPlane(0).displayHardware().getHwComposer());
if (hwc.initCheck() == NO_ERROR) {
+
+ const DisplayHardware& hw(graphicPlane(0).displayHardware());
+ uint32_t flags = hw.getFlags();
+ if ((flags & DisplayHardware::SWAP_RECTANGLE) ||
+ (flags & DisplayHardware::BUFFER_PRESERVED))
+ {
+ // we need to redraw everything (the whole screen)
+ // NOTE: we could be more subtle here and redraw only
+ // the area which will end-up in an overlay. But since this
+ // shouldn't happen often, we invalidate everything.
+ mDirtyRegion.set(hw.bounds());
+ mInvalidRegion = mDirtyRegion;
+ }
+
const Vector< sp<LayerBase> >& currentLayers(mVisibleLayersSortedByZ);
const size_t count = currentLayers.size();
hwc.createWorkList(count);
@@ -2099,6 +2113,12 @@
// we're already off
return NO_ERROR;
}
+
+ // turn off hwc while we're doing the animation
+ hw.getHwComposer().disable();
+ // and make sure to turn it back on (if needed) next time we compose
+ invalidateHwcGeometry();
+
if (mode & ISurfaceComposer::eElectronBeamAnimationOff) {
electronBeamOffAnimationImplLocked();
}