Merge "Apply surface parameters in sync with RenderThread"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2147cfe02f
@@ -790,7 +790,8 @@ public final class ThreadedRenderer {
|
||||
* @param attachInfo AttachInfo tied to the specified view.
|
||||
* @param callbacks Callbacks invoked when drawing happens.
|
||||
*/
|
||||
void draw(View view, AttachInfo attachInfo, DrawCallbacks callbacks) {
|
||||
void draw(View view, AttachInfo attachInfo, DrawCallbacks callbacks,
|
||||
FrameDrawingCallback frameDrawingCallback) {
|
||||
final Choreographer choreographer = attachInfo.mViewRootImpl.mChoreographer;
|
||||
choreographer.mFrameInfo.markDrawStart();
|
||||
|
||||
@@ -811,6 +812,9 @@ public final class ThreadedRenderer {
|
||||
}
|
||||
|
||||
final long[] frameInfo = choreographer.mFrameInfo.mFrameInfo;
|
||||
if (frameDrawingCallback != null) {
|
||||
nSetFrameCallback(mNativeProxy, frameDrawingCallback);
|
||||
}
|
||||
int syncResult = nSyncAndDrawFrame(mNativeProxy, frameInfo, frameInfo.length);
|
||||
if ((syncResult & SYNC_LOST_SURFACE_REWARD_IF_FOUND) != 0) {
|
||||
setEnabled(false);
|
||||
|
||||
@@ -80,6 +80,7 @@ import android.util.SparseBooleanArray;
|
||||
import android.util.TimeUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Surface.OutOfResourcesException;
|
||||
import android.view.ThreadedRenderer.FrameDrawingCallback;
|
||||
import android.view.View.AttachInfo;
|
||||
import android.view.View.FocusDirection;
|
||||
import android.view.View.MeasureSpec;
|
||||
@@ -175,6 +176,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
static final ArrayList<Runnable> sFirstDrawHandlers = new ArrayList();
|
||||
static boolean sFirstDrawComplete = false;
|
||||
|
||||
private FrameDrawingCallback mNextRtFrameCallback;
|
||||
|
||||
/**
|
||||
* Callback for notifying about global configuration changes.
|
||||
*/
|
||||
@@ -967,6 +970,17 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback to be executed when the next frame is being drawn on RenderThread. This
|
||||
* callback will be executed on a RenderThread worker thread, and only used for the next frame
|
||||
* and thus it will only fire once.
|
||||
*
|
||||
* @param callback The callback to register.
|
||||
*/
|
||||
public void registerRtFrameCallback(FrameDrawingCallback callback) {
|
||||
mNextRtFrameCallback = callback;
|
||||
}
|
||||
|
||||
private void enableHardwareAcceleration(WindowManager.LayoutParams attrs) {
|
||||
mAttachInfo.mHardwareAccelerated = false;
|
||||
mAttachInfo.mHardwareAccelerationRequested = false;
|
||||
@@ -3252,7 +3266,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
requestDrawWindow();
|
||||
}
|
||||
|
||||
mAttachInfo.mThreadedRenderer.draw(mView, mAttachInfo, this);
|
||||
mAttachInfo.mThreadedRenderer.draw(mView, mAttachInfo, this, mNextRtFrameCallback);
|
||||
mNextRtFrameCallback = null;
|
||||
} else {
|
||||
// If we get here with a disabled & requested hardware renderer, something went
|
||||
// wrong (an invalidate posted right before we destroyed the hardware surface
|
||||
|
||||
Reference in New Issue
Block a user