Skip to content

Commit 6972659

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Add stencil buffer to the EGL config"
2 parents 4d6da86 + 530041d commit 6972659

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

core/java/android/view/GLES20Canvas.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public int getMaximumBitmapHeight() {
189189
}
190190

191191
private static native int nGetMaximumTextureWidth();
192-
private static native int nGetMaximumTextureHeight();
192+
private static native int nGetMaximumTextureHeight();
193193

194194
///////////////////////////////////////////////////////////////////////////
195195
// Setup
@@ -268,14 +268,31 @@ public void onPostDraw() {
268268

269269
private static native void nFinish(int renderer);
270270

271+
/**
272+
* Returns the size of the stencil buffer required by the underlying
273+
* implementation.
274+
*
275+
* @return The minimum number of bits the stencil buffer must. Always >= 0.
276+
*
277+
* @hide
278+
*/
279+
public static int getStencilSize() {
280+
return nGetStencilSize();
281+
}
282+
283+
private static native int nGetStencilSize();
284+
285+
///////////////////////////////////////////////////////////////////////////
286+
// Functor
287+
///////////////////////////////////////////////////////////////////////////
288+
271289
@Override
272290
public boolean callDrawGLFunction(int drawGLFunction) {
273291
return nCallDrawGLFunction(mRenderer, drawGLFunction);
274292
}
275293

276294
private static native boolean nCallDrawGLFunction(int renderer, int drawGLFunction);
277295

278-
279296
///////////////////////////////////////////////////////////////////////////
280297
// Memory
281298
///////////////////////////////////////////////////////////////////////////

core/java/android/view/HardwareRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ int[] getConfig(boolean dirtyRegions) {
10471047
EGL_BLUE_SIZE, 8,
10481048
EGL_ALPHA_SIZE, 8,
10491049
EGL_DEPTH_SIZE, 0,
1050-
EGL_STENCIL_SIZE, 0,
1050+
EGL_STENCIL_SIZE, GLES20Canvas.getStencilSize(),
10511051
EGL_SURFACE_TYPE, EGL_WINDOW_BIT |
10521052
(dirtyRegions ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0),
10531053
EGL_NONE

core/jni/android_view_GLES20Canvas.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ static void android_view_GLES20Canvas_finish(JNIEnv* env, jobject clazz,
188188
renderer->finish();
189189
}
190190

191+
static jint android_view_GLES20Canvas_getStencilSize(JNIEnv* env, jobject clazz) {
192+
return OpenGLRenderer::getStencilSize();
193+
}
194+
195+
// ----------------------------------------------------------------------------
196+
// Functor
197+
// ----------------------------------------------------------------------------
198+
191199
static bool android_view_GLES20Canvas_callDrawGLFunction(JNIEnv* env, jobject clazz,
192200
OpenGLRenderer* renderer, Functor *functor) {
193201
android::uirenderer::Rect dirty;
@@ -808,6 +816,8 @@ static JNINativeMethod gMethods[] = {
808816
{ "nPrepareDirty", "(IIIIIZ)V", (void*) android_view_GLES20Canvas_prepareDirty },
809817
{ "nFinish", "(I)V", (void*) android_view_GLES20Canvas_finish },
810818

819+
{ "nGetStencilSize", "()I", (void*) android_view_GLES20Canvas_getStencilSize },
820+
811821
{ "nCallDrawGLFunction", "(II)Z",
812822
(void*) android_view_GLES20Canvas_callDrawGLFunction },
813823

docs/html/guide/topics/ui/how-android-draws.jd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ and each View is responsible for drawing itself.
6262

6363
<p>
6464
The measure pass uses two classes to communicate dimensions. The
65-
{@link android.view.View.MeasureSpec} class is used by Views to tell their parents how they
65+
{@link android.view.ViewGroup.LayoutParams} class is used by Views to tell their parents how they
6666
want to be measured and positioned. The base LayoutParams class just
6767
describes how big the View wants to be for both width and height. For each
6868
dimension, it can specify one of:</p>

libs/hwui/OpenGLRenderer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ OpenGLRenderer::~OpenGLRenderer() {
127127
// Setup
128128
///////////////////////////////////////////////////////////////////////////////
129129

130+
uint32_t OpenGLRenderer::getStencilSize() {
131+
return STENCIL_BUFFER_SIZE;
132+
}
133+
130134
void OpenGLRenderer::setViewport(int width, int height) {
131135
mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
132136

libs/hwui/OpenGLRenderer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ class OpenGLRenderer {
141141

142142
SkPaint* filterPaint(SkPaint* paint);
143143

144+
ANDROID_API static uint32_t getStencilSize();
145+
144146
protected:
145147
/**
146148
* Compose the layer defined in the current snapshot with the layer

libs/hwui/Properties.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
// Textures used by layers must have dimensions multiples of this number
3838
#define LAYER_SIZE 64
3939

40+
// Defines the size in bits of the stencil buffer
41+
// Note: We only want 1 bit, but in practice we'll get 8 bits on all GPUs
42+
// for the foreseeable future
43+
#define STENCIL_BUFFER_SIZE 0
44+
4045
/**
4146
* Debug level for app developers.
4247
*/

0 commit comments

Comments
 (0)