Merge "Add a workaround for simulate secondary display" into oc-dev

am: 31443a17e8

Change-Id: Ic63e4f48ec55bce9f51089bc41481ab8805ae8c7
This commit is contained in:
John Reck
2017-06-14 20:25:03 +00:00
committed by android-build-merger
8 changed files with 28 additions and 0 deletions

View File

@@ -970,6 +970,9 @@ public final class ThreadedRenderer {
observer.mNative = null; observer.mNative = null;
} }
/** Not actually public - internal use only. This doc to make lint happy */
public static native void disableVsync();
static native void setupShadersDiskCache(String cacheFile); static native void setupShadersDiskCache(String cacheFile);
private static native void nRotateProcessStatsBuffer(); private static native void nRotateProcessStatsBuffer();

View File

@@ -932,6 +932,10 @@ static jobject android_view_ThreadedRenderer_createHardwareBitmapFromRenderNode(
return createBitmap(env, bitmap.release(), android::bitmap::kBitmapCreateFlag_Mutable); return createBitmap(env, bitmap.release(), android::bitmap::kBitmapCreateFlag_Mutable);
} }
static void android_view_ThreadedRenderer_disableVsync(JNIEnv*, jclass) {
RenderProxy::disableVsync();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// FrameMetricsObserver // FrameMetricsObserver
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1030,6 +1034,7 @@ static const JNINativeMethod gMethods[] = {
(void*)android_view_ThreadedRenderer_copySurfaceInto }, (void*)android_view_ThreadedRenderer_copySurfaceInto },
{ "nCreateHardwareBitmap", "(JII)Landroid/graphics/Bitmap;", { "nCreateHardwareBitmap", "(JII)Landroid/graphics/Bitmap;",
(void*)android_view_ThreadedRenderer_createHardwareBitmapFromRenderNode }, (void*)android_view_ThreadedRenderer_createHardwareBitmapFromRenderNode },
{ "disableVsync", "()V", (void*)android_view_ThreadedRenderer_disableVsync },
}; };
int register_android_view_ThreadedRenderer(JNIEnv* env) { int register_android_view_ThreadedRenderer(JNIEnv* env) {

View File

@@ -69,6 +69,7 @@ bool Properties::waitForGpuCompletion = false;
bool Properties::forceDrawFrame = false; bool Properties::forceDrawFrame = false;
bool Properties::filterOutTestOverhead = false; bool Properties::filterOutTestOverhead = false;
bool Properties::disableVsync = false;
static int property_get_int(const char* key, int defaultValue) { static int property_get_int(const char* key, int defaultValue) {
char buf[PROPERTY_VALUE_MAX] = {'\0',}; char buf[PROPERTY_VALUE_MAX] = {'\0',};

View File

@@ -318,6 +318,12 @@ public:
// any overhead they add // any overhead they add
static bool filterOutTestOverhead; static bool filterOutTestOverhead;
// Workaround a device lockup in edge cases by switching to async mode
// instead of the default vsync (b/38372997). Only system_server should hit this.
// Any existing RenderProxy & Surface combination will be unaffected, only things
// created after changing this.
static bool disableVsync;
// Used for testing only to change the render pipeline. // Used for testing only to change the render pipeline.
#ifdef HWUI_GLES_WRAP_ENABLED #ifdef HWUI_GLES_WRAP_ENABLED
static void overrideRenderPipelineType(RenderPipelineType); static void overrideRenderPipelineType(RenderPipelineType);

View File

@@ -279,6 +279,9 @@ bool EglManager::makeCurrent(EGLSurface surface, EGLint* errOut) {
} }
} }
mCurrentSurface = surface; mCurrentSurface = surface;
if (Properties::disableVsync) {
eglSwapInterval(mEglDisplay, 0);
}
return true; return true;
} }

View File

@@ -18,6 +18,7 @@
#include "DeferredLayerUpdater.h" #include "DeferredLayerUpdater.h"
#include "DisplayList.h" #include "DisplayList.h"
#include "Properties.h"
#include "Readback.h" #include "Readback.h"
#include "Rect.h" #include "Rect.h"
#include "renderthread/CanvasContext.h" #include "renderthread/CanvasContext.h"
@@ -708,6 +709,10 @@ void RenderProxy::onBitmapDestroyed(uint32_t pixelRefId) {
thread.queue(task); thread.queue(task);
} }
void RenderProxy::disableVsync() {
Properties::disableVsync = true;
}
void RenderProxy::post(RenderTask* task) { void RenderProxy::post(RenderTask* task) {
mRenderThread.queue(task); mRenderThread.queue(task);
} }

View File

@@ -137,6 +137,8 @@ public:
static int copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap); static int copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap);
static void onBitmapDestroyed(uint32_t pixelRefId); static void onBitmapDestroyed(uint32_t pixelRefId);
ANDROID_API static void disableVsync();
private: private:
RenderThread& mRenderThread; RenderThread& mRenderThread;
CanvasContext* mContext; CanvasContext* mContext;

View File

@@ -30,6 +30,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.ScaleGestureDetector; import android.view.ScaleGestureDetector;
import android.view.TextureView; import android.view.TextureView;
import android.view.ThreadedRenderer;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.TextureView.SurfaceTextureListener; import android.view.TextureView.SurfaceTextureListener;
@@ -95,6 +96,8 @@ final class OverlayDisplayWindow implements DumpUtils.Dump {
public OverlayDisplayWindow(Context context, String name, public OverlayDisplayWindow(Context context, String name,
int width, int height, int densityDpi, int gravity, boolean secure, int width, int height, int densityDpi, int gravity, boolean secure,
Listener listener) { Listener listener) {
// Workaround device freeze (b/38372997)
ThreadedRenderer.disableVsync();
mContext = context; mContext = context;
mName = name; mName = name;
mGravity = gravity; mGravity = gravity;