It seems that apparently useless public APIs are actually useful

Bug #6953651

Change-Id: Ic47ce504e63262711f5d3edc76f7d2b9c12471ad
This commit is contained in:
Romain Guy
2012-08-08 14:53:48 -07:00
parent 6ab4511aa6
commit c89b14bba0
6 changed files with 46 additions and 24 deletions

View File

@@ -82,11 +82,17 @@ class GLES20RenderLayer extends GLES20Layer {
}
@Override
void end() {
void end(Canvas currentCanvas) {
if (currentCanvas instanceof GLES20Canvas) {
((GLES20Canvas) currentCanvas).resume();
}
}
@Override
HardwareCanvas start() {
HardwareCanvas start(Canvas currentCanvas) {
if (currentCanvas instanceof GLES20Canvas) {
((GLES20Canvas) currentCanvas).interrupt();
}
return getCanvas();
}

View File

@@ -16,6 +16,7 @@
package android.view;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
@@ -56,12 +57,12 @@ class GLES20TextureLayer extends GLES20Layer {
}
@Override
HardwareCanvas start() {
HardwareCanvas start(Canvas currentCanvas) {
return null;
}
@Override
void end() {
void end(Canvas currentCanvas) {
}
SurfaceTexture getSurfaceTexture() {

View File

@@ -17,6 +17,7 @@
package android.view;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
@@ -143,13 +144,15 @@ abstract class HardwareLayer {
/**
* This must be invoked before drawing onto this layer.
* @param currentCanvas
*/
abstract HardwareCanvas start();
abstract HardwareCanvas start(Canvas currentCanvas);
/**
* This must be invoked after drawing onto this layer.
* @param currentCanvas
*/
abstract void end();
abstract void end(Canvas currentCanvas);
/**
* Copies this layer into the specified bitmap.

View File

@@ -1408,6 +1408,7 @@ public final class ViewRootImpl implements ViewParent,
disposeResizeBuffer();
boolean completed = false;
HardwareCanvas hwRendererCanvas = mAttachInfo.mHardwareRenderer.getCanvas();
HardwareCanvas layerCanvas = null;
try {
if (mResizeBuffer == null) {
@@ -1417,7 +1418,7 @@ public final class ViewRootImpl implements ViewParent,
mResizeBuffer.getHeight() != mHeight) {
mResizeBuffer.resize(mWidth, mHeight);
}
layerCanvas = mResizeBuffer.start();
layerCanvas = mResizeBuffer.start(hwRendererCanvas);
layerCanvas.setViewport(mWidth, mHeight);
layerCanvas.onPreDraw(null);
final int restoreCount = layerCanvas.save();
@@ -1456,7 +1457,7 @@ public final class ViewRootImpl implements ViewParent,
layerCanvas.onPostDraw();
}
if (mResizeBuffer != null) {
mResizeBuffer.end();
mResizeBuffer.end(hwRendererCanvas);
if (!completed) {
mResizeBuffer.destroy();
mResizeBuffer = null;

View File

@@ -720,6 +720,16 @@ static void android_view_GLES20Canvas_outputDisplayList(JNIEnv* env,
// Layers
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_interrupt(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer) {
renderer->interrupt();
}
static void android_view_GLES20Canvas_resume(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer) {
renderer->resume();
}
static OpenGLRenderer* android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env,
jobject clazz, Layer* layer) {
if (layer) {
@@ -962,6 +972,8 @@ static JNINativeMethod gMethods[] = {
{ "nResetDisplayListRenderer", "(I)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer },
{ "nOutputDisplayList", "(II)V", (void*) android_view_GLES20Canvas_outputDisplayList },
{ "nInterrupt", "(I)V", (void*) android_view_GLES20Canvas_interrupt },
{ "nResume", "(I)V", (void*) android_view_GLES20Canvas_resume },
{ "nCreateLayerRenderer", "(I)I", (void*) android_view_GLES20Canvas_createLayerRenderer },
{ "nCreateLayer", "(IIZ[I)I", (void*) android_view_GLES20Canvas_createLayer },

View File

@@ -112,6 +112,21 @@ public:
*/
virtual void finish();
/**
* This method must be invoked before handing control over to a draw functor.
* See callDrawGLFunction() for instance.
*
* This command must not be recorded inside display lists.
*/
virtual void interrupt();
/**
* This method must be invoked after getting control back from a draw functor.
*
* This command must not be recorded inside display lists.
*/
virtual void resume();
ANDROID_API status_t invokeFunctors(Rect& dirty);
ANDROID_API void detachFunctor(Functor* functor);
ANDROID_API void attachFunctor(Functor* functor);
@@ -219,22 +234,6 @@ public:
void endMark() const;
protected:
/**
* This method must be invoked before handing control over to a draw functor.
* See callDrawGLFunction() for instance.
*
* This command must not be recorded inside display lists.
*/
void interrupt();
/**
* This method must be invoked after getting control back from a draw functor.
*
* This command must not be recorded inside display lists.
*/
void resume();
/**
* Compose the layer defined in the current snapshot with the layer
* defined by the previous snapshot.