Merge "Cleanup of libhwui" into jb-mr1-dev

This commit is contained in:
Romain Guy
2012-08-07 11:59:35 -07:00
committed by Android (Google) Code Review
6 changed files with 92 additions and 40 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -720,16 +720,6 @@ static void android_view_GLES20Canvas_outputDisplayList(JNIEnv* env,
// Layers // 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, static OpenGLRenderer* android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env,
jobject clazz, Layer* layer) { jobject clazz, Layer* layer) {
if (layer) { if (layer) {
@@ -972,8 +962,6 @@ static JNINativeMethod gMethods[] = {
{ "nResetDisplayListRenderer", "(I)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer }, { "nResetDisplayListRenderer", "(I)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer },
{ "nOutputDisplayList", "(II)V", (void*) android_view_GLES20Canvas_outputDisplayList }, { "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 }, { "nCreateLayerRenderer", "(I)I", (void*) android_view_GLES20Canvas_createLayerRenderer },
{ "nCreateLayer", "(IIZ[I)I", (void*) android_view_GLES20Canvas_createLayer }, { "nCreateLayer", "(IIZ[I)I", (void*) android_view_GLES20Canvas_createLayer },

View File

@@ -63,17 +63,54 @@ public:
ANDROID_API OpenGLRenderer(); ANDROID_API OpenGLRenderer();
virtual ~OpenGLRenderer(); virtual ~OpenGLRenderer();
/**
* Indicates whether this renderer executes drawing commands immediately.
* If this method returns true, the drawing commands will be executed
* later.
*/
virtual bool isDeferred(); virtual bool isDeferred();
/**
* Sets the dimension of the underlying drawing surface. This method must
* be called at least once every time the drawing surface changes size.
*
* @param width The width in pixels of the underlysing surface
* @param height The height in pixels of the underlysing surface
*/
virtual void setViewport(int width, int height); virtual void setViewport(int width, int height);
/**
* Prepares the renderer to draw a frame. This method must be invoked
* at the beginning of each frame. When this method is invoked, the
* entire drawing surface is assumed to be redrawn.
*
* @param opaque If true, the target surface is considered opaque
* and will not be cleared. If false, the target surface
* will be cleared
*/
ANDROID_API int prepare(bool opaque); ANDROID_API int prepare(bool opaque);
virtual int prepareDirty(float left, float top, float right, float bottom, bool opaque);
virtual void finish();
// These two calls must not be recorded in display lists /**
virtual void interrupt(); * Prepares the renderer to draw a frame. This method must be invoked
virtual void resume(); * at the beginning of each frame. Only the specified rectangle of the
* frame is assumed to be dirty. A clip will automatically be set to
* the specified rectangle.
*
* @param left The left coordinate of the dirty rectangle
* @param top The top coordinate of the dirty rectangle
* @param right The right coordinate of the dirty rectangle
* @param bottom The bottom coordinate of the dirty rectangle
* @param opaque If true, the target surface is considered opaque
* and will not be cleared. If false, the target surface
* will be cleared in the specified dirty rectangle
*/
virtual int prepareDirty(float left, float top, float right, float bottom, bool opaque);
/**
* Indicates the end of a frame. This method must be invoked whenever
* the caller is done rendering a frame.
*/
virtual void finish();
ANDROID_API status_t invokeFunctors(Rect& dirty); ANDROID_API status_t invokeFunctors(Rect& dirty);
ANDROID_API void detachFunctor(Functor* functor); ANDROID_API void detachFunctor(Functor* functor);
@@ -90,10 +127,6 @@ public:
virtual int saveLayerAlpha(float left, float top, float right, float bottom, virtual int saveLayerAlpha(float left, float top, float right, float bottom,
int alpha, int flags); int alpha, int flags);
void setAlpha(float alpha) {
mSnapshot->alpha = alpha;
}
virtual void translate(float dx, float dy); virtual void translate(float dx, float dy);
virtual void rotate(float degrees); virtual void rotate(float degrees);
virtual void scale(float sx, float sy); virtual void scale(float sx, float sy);
@@ -159,12 +192,49 @@ public:
SkPaint* filterPaint(SkPaint* paint); SkPaint* filterPaint(SkPaint* paint);
/**
* Returns the desired size for the stencil buffer. If the returned value
* is 0, then no stencil buffer is required.
*/
ANDROID_API static uint32_t getStencilSize(); ANDROID_API static uint32_t getStencilSize();
/**
* Sets the alpha on the current snapshot. This alpha value will be modulated
* with other alpha values when drawing primitives.
*/
void setAlpha(float alpha) {
mSnapshot->alpha = alpha;
}
/**
* Inserts a named group marker in the stream of GL commands. This marker
* can be used by tools to group commands into logical groups. A call to
* this method must always be followed later on by a call to endMark().
*/
void startMark(const char* name) const; void startMark(const char* name) const;
/**
* Closes the last group marker opened by startMark().
*/
void endMark() const; void endMark() const;
protected: 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 * Compose the layer defined in the current snapshot with the layer
* defined by the previous snapshot. * defined by the previous snapshot.
@@ -579,6 +649,7 @@ private:
* Invoked before any drawing operation. This sets required state. * Invoked before any drawing operation. This sets required state.
*/ */
void setupDraw(bool clear = true); void setupDraw(bool clear = true);
/** /**
* Various methods to setup OpenGL rendering. * Various methods to setup OpenGL rendering.
*/ */
@@ -626,6 +697,10 @@ private:
void finishDrawTexture(); void finishDrawTexture();
void accountForClear(SkXfermode::Mode mode); void accountForClear(SkXfermode::Mode mode);
/**
* Renders the specified region as a series of rectangles. This method
* is used for debugging only.
*/
void drawRegionRects(const Region& region); void drawRegionRects(const Region& region);
/** /**