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

This commit is contained in:
TreeHugger Robot
2017-06-14 20:13:59 +00:00
committed by Android (Google) Code Review
8 changed files with 28 additions and 0 deletions

View File

@@ -970,6 +970,9 @@ public final class ThreadedRenderer {
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);
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);
}
static void android_view_ThreadedRenderer_disableVsync(JNIEnv*, jclass) {
RenderProxy::disableVsync();
}
// ----------------------------------------------------------------------------
// FrameMetricsObserver
// ----------------------------------------------------------------------------
@@ -1030,6 +1034,7 @@ static const JNINativeMethod gMethods[] = {
(void*)android_view_ThreadedRenderer_copySurfaceInto },
{ "nCreateHardwareBitmap", "(JII)Landroid/graphics/Bitmap;",
(void*)android_view_ThreadedRenderer_createHardwareBitmapFromRenderNode },
{ "disableVsync", "()V", (void*)android_view_ThreadedRenderer_disableVsync },
};
int register_android_view_ThreadedRenderer(JNIEnv* env) {

View File

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

View File

@@ -318,6 +318,12 @@ public:
// any overhead they add
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.
#ifdef HWUI_GLES_WRAP_ENABLED
static void overrideRenderPipelineType(RenderPipelineType);

View File

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

View File

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

View File

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

View File

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