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
void end(Canvas currentCanvas) {
if (currentCanvas instanceof GLES20Canvas) {
((GLES20Canvas) currentCanvas).resume();
}
void end() {
}
@Override
HardwareCanvas start(Canvas currentCanvas) {
if (currentCanvas instanceof GLES20Canvas) {
((GLES20Canvas) currentCanvas).interrupt();
}
HardwareCanvas start() {
return getCanvas();
}

View File

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

View File

@@ -17,7 +17,6 @@
package android.view;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
@@ -144,15 +143,13 @@ abstract class HardwareLayer {
/**
* 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.
* @param currentCanvas
*/
abstract void end(Canvas currentCanvas);
abstract void end();
/**
* Copies this layer into the specified bitmap.

View File

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

View File

@@ -720,16 +720,6 @@ 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) {
@@ -972,8 +962,6 @@ 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

@@ -63,17 +63,54 @@ public:
ANDROID_API 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();
/**
* 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);
/**
* 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);
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();
virtual void resume();
/**
* Prepares the renderer to draw a frame. This method must be invoked
* 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 void detachFunctor(Functor* functor);
@@ -90,10 +127,6 @@ public:
virtual int saveLayerAlpha(float left, float top, float right, float bottom,
int alpha, int flags);
void setAlpha(float alpha) {
mSnapshot->alpha = alpha;
}
virtual void translate(float dx, float dy);
virtual void rotate(float degrees);
virtual void scale(float sx, float sy);
@@ -159,12 +192,49 @@ public:
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();
/**
* 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;
/**
* Closes the last group marker opened by startMark().
*/
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.
@@ -579,6 +649,7 @@ private:
* Invoked before any drawing operation. This sets required state.
*/
void setupDraw(bool clear = true);
/**
* Various methods to setup OpenGL rendering.
*/
@@ -626,6 +697,10 @@ private:
void finishDrawTexture();
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);
/**