Skip to content

Commit 03ad783

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Cleanup of libhwui" into jb-mr1-dev
2 parents a419150 + 17112ad commit 03ad783

File tree

6 files changed

+91
-39
lines changed

6 files changed

+91
-39
lines changed

core/java/android/view/GLES20RenderLayer.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,11 @@ HardwareCanvas getCanvas() {
8282
}
8383

8484
@Override
85-
void end(Canvas currentCanvas) {
86-
if (currentCanvas instanceof GLES20Canvas) {
87-
((GLES20Canvas) currentCanvas).resume();
88-
}
85+
void end() {
8986
}
9087

9188
@Override
92-
HardwareCanvas start(Canvas currentCanvas) {
93-
if (currentCanvas instanceof GLES20Canvas) {
94-
((GLES20Canvas) currentCanvas).interrupt();
95-
}
89+
HardwareCanvas start() {
9690
return getCanvas();
9791
}
9892

core/java/android/view/GLES20TextureLayer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package android.view;
1818

19-
import android.graphics.Canvas;
2019
import android.graphics.Matrix;
2120
import android.graphics.Rect;
2221
import android.graphics.SurfaceTexture;
@@ -57,12 +56,12 @@ HardwareCanvas getCanvas() {
5756
}
5857

5958
@Override
60-
HardwareCanvas start(Canvas currentCanvas) {
59+
HardwareCanvas start() {
6160
return null;
6261
}
6362

6463
@Override
65-
void end(Canvas currentCanvas) {
64+
void end() {
6665
}
6766

6867
SurfaceTexture getSurfaceTexture() {

core/java/android/view/HardwareLayer.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package android.view;
1818

1919
import android.graphics.Bitmap;
20-
import android.graphics.Canvas;
2120
import android.graphics.Matrix;
2221
import android.graphics.Rect;
2322

@@ -144,15 +143,13 @@ boolean isOpaque() {
144143

145144
/**
146145
* This must be invoked before drawing onto this layer.
147-
* @param currentCanvas
148146
*/
149-
abstract HardwareCanvas start(Canvas currentCanvas);
147+
abstract HardwareCanvas start();
150148

151149
/**
152150
* This must be invoked after drawing onto this layer.
153-
* @param currentCanvas
154151
*/
155-
abstract void end(Canvas currentCanvas);
152+
abstract void end();
156153

157154
/**
158155
* Copies this layer into the specified bitmap.

core/java/android/view/ViewRootImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,6 @@ private void performTraversals() {
14081408
disposeResizeBuffer();
14091409

14101410
boolean completed = false;
1411-
HardwareCanvas hwRendererCanvas = mAttachInfo.mHardwareRenderer.getCanvas();
14121411
HardwareCanvas layerCanvas = null;
14131412
try {
14141413
if (mResizeBuffer == null) {
@@ -1418,7 +1417,7 @@ private void performTraversals() {
14181417
mResizeBuffer.getHeight() != mHeight) {
14191418
mResizeBuffer.resize(mWidth, mHeight);
14201419
}
1421-
layerCanvas = mResizeBuffer.start(hwRendererCanvas);
1420+
layerCanvas = mResizeBuffer.start();
14221421
layerCanvas.setViewport(mWidth, mHeight);
14231422
layerCanvas.onPreDraw(null);
14241423
final int restoreCount = layerCanvas.save();
@@ -1457,7 +1456,7 @@ private void performTraversals() {
14571456
layerCanvas.onPostDraw();
14581457
}
14591458
if (mResizeBuffer != null) {
1460-
mResizeBuffer.end(hwRendererCanvas);
1459+
mResizeBuffer.end();
14611460
if (!completed) {
14621461
mResizeBuffer.destroy();
14631462
mResizeBuffer = null;

core/jni/android_view_GLES20Canvas.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -720,16 +720,6 @@ static void android_view_GLES20Canvas_outputDisplayList(JNIEnv* env,
720720
// Layers
721721
// ----------------------------------------------------------------------------
722722

723-
static void android_view_GLES20Canvas_interrupt(JNIEnv* env, jobject clazz,
724-
OpenGLRenderer* renderer) {
725-
renderer->interrupt();
726-
}
727-
728-
static void android_view_GLES20Canvas_resume(JNIEnv* env, jobject clazz,
729-
OpenGLRenderer* renderer) {
730-
renderer->resume();
731-
}
732-
733723
static OpenGLRenderer* android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env,
734724
jobject clazz, Layer* layer) {
735725
if (layer) {
@@ -972,8 +962,6 @@ static JNINativeMethod gMethods[] = {
972962
{ "nResetDisplayListRenderer", "(I)V", (void*) android_view_GLES20Canvas_resetDisplayListRenderer },
973963

974964
{ "nOutputDisplayList", "(II)V", (void*) android_view_GLES20Canvas_outputDisplayList },
975-
{ "nInterrupt", "(I)V", (void*) android_view_GLES20Canvas_interrupt },
976-
{ "nResume", "(I)V", (void*) android_view_GLES20Canvas_resume },
977965

978966
{ "nCreateLayerRenderer", "(I)I", (void*) android_view_GLES20Canvas_createLayerRenderer },
979967
{ "nCreateLayer", "(IIZ[I)I", (void*) android_view_GLES20Canvas_createLayer },

libs/hwui/OpenGLRenderer.h

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,54 @@ class OpenGLRenderer {
6363
ANDROID_API OpenGLRenderer();
6464
virtual ~OpenGLRenderer();
6565

66+
/**
67+
* Indicates whether this renderer executes drawing commands immediately.
68+
* If this method returns true, the drawing commands will be executed
69+
* later.
70+
*/
6671
virtual bool isDeferred();
6772

73+
/**
74+
* Sets the dimension of the underlying drawing surface. This method must
75+
* be called at least once every time the drawing surface changes size.
76+
*
77+
* @param width The width in pixels of the underlysing surface
78+
* @param height The height in pixels of the underlysing surface
79+
*/
6880
virtual void setViewport(int width, int height);
6981

82+
/**
83+
* Prepares the renderer to draw a frame. This method must be invoked
84+
* at the beginning of each frame. When this method is invoked, the
85+
* entire drawing surface is assumed to be redrawn.
86+
*
87+
* @param opaque If true, the target surface is considered opaque
88+
* and will not be cleared. If false, the target surface
89+
* will be cleared
90+
*/
7091
ANDROID_API int prepare(bool opaque);
92+
93+
/**
94+
* Prepares the renderer to draw a frame. This method must be invoked
95+
* at the beginning of each frame. Only the specified rectangle of the
96+
* frame is assumed to be dirty. A clip will automatically be set to
97+
* the specified rectangle.
98+
*
99+
* @param left The left coordinate of the dirty rectangle
100+
* @param top The top coordinate of the dirty rectangle
101+
* @param right The right coordinate of the dirty rectangle
102+
* @param bottom The bottom coordinate of the dirty rectangle
103+
* @param opaque If true, the target surface is considered opaque
104+
* and will not be cleared. If false, the target surface
105+
* will be cleared in the specified dirty rectangle
106+
*/
71107
virtual int prepareDirty(float left, float top, float right, float bottom, bool opaque);
72-
virtual void finish();
73108

74-
// These two calls must not be recorded in display lists
75-
virtual void interrupt();
76-
virtual void resume();
109+
/**
110+
* Indicates the end of a frame. This method must be invoked whenever
111+
* the caller is done rendering a frame.
112+
*/
113+
virtual void finish();
77114

78115
ANDROID_API status_t invokeFunctors(Rect& dirty);
79116
ANDROID_API void detachFunctor(Functor* functor);
@@ -90,10 +127,6 @@ class OpenGLRenderer {
90127
virtual int saveLayerAlpha(float left, float top, float right, float bottom,
91128
int alpha, int flags);
92129

93-
void setAlpha(float alpha) {
94-
mSnapshot->alpha = alpha;
95-
}
96-
97130
virtual void translate(float dx, float dy);
98131
virtual void rotate(float degrees);
99132
virtual void scale(float sx, float sy);
@@ -159,12 +192,49 @@ class OpenGLRenderer {
159192

160193
SkPaint* filterPaint(SkPaint* paint);
161194

195+
/**
196+
* Returns the desired size for the stencil buffer. If the returned value
197+
* is 0, then no stencil buffer is required.
198+
*/
162199
ANDROID_API static uint32_t getStencilSize();
163200

201+
/**
202+
* Sets the alpha on the current snapshot. This alpha value will be modulated
203+
* with other alpha values when drawing primitives.
204+
*/
205+
void setAlpha(float alpha) {
206+
mSnapshot->alpha = alpha;
207+
}
208+
209+
/**
210+
* Inserts a named group marker in the stream of GL commands. This marker
211+
* can be used by tools to group commands into logical groups. A call to
212+
* this method must always be followed later on by a call to endMark().
213+
*/
164214
void startMark(const char* name) const;
215+
216+
/**
217+
* Closes the last group marker opened by startMark().
218+
*/
165219
void endMark() const;
166220

167221
protected:
222+
223+
/**
224+
* This method must be invoked before handing control over to a draw functor.
225+
* See callDrawGLFunction() for instance.
226+
*
227+
* This command must not be recorded inside display lists.
228+
*/
229+
void interrupt();
230+
231+
/**
232+
* This method must be invoked after getting control back from a draw functor.
233+
*
234+
* This command must not be recorded inside display lists.
235+
*/
236+
void resume();
237+
168238
/**
169239
* Compose the layer defined in the current snapshot with the layer
170240
* defined by the previous snapshot.
@@ -579,6 +649,7 @@ class OpenGLRenderer {
579649
* Invoked before any drawing operation. This sets required state.
580650
*/
581651
void setupDraw(bool clear = true);
652+
582653
/**
583654
* Various methods to setup OpenGL rendering.
584655
*/
@@ -626,6 +697,10 @@ class OpenGLRenderer {
626697
void finishDrawTexture();
627698
void accountForClear(SkXfermode::Mode mode);
628699

700+
/**
701+
* Renders the specified region as a series of rectangles. This method
702+
* is used for debugging only.
703+
*/
629704
void drawRegionRects(const Region& region);
630705

631706
/**

0 commit comments

Comments
 (0)