diff options
| author | Romain Guy <romainguy@google.com> | 2012-12-03 12:34:51 -0800 |
|---|---|---|
| committer | Romain Guy <romainguy@google.com> | 2013-01-14 14:27:54 -0800 |
| commit | 735738c4ddf3229caa5f6e634bf591953ac29944 (patch) | |
| tree | 4e972e943ffefc5bc268629ed45e8a5783ffe7c5 /core/java/android/view/HardwareRenderer.java | |
| parent | 57b59e025bc10056daf42cd741b626843ff344f5 (diff) | |
Preliminary Support for region clipping
Region clipping, using Canvas.clipPath or Canvas.clipRegion, requires
a stencil buffer to be always present. In addition, extra wiring is
required in JNI and display lists.
This change only adds the necessary JNI/C++ APIs and some extra
plumbing to start the real work on properly supporting region
clipping.
A new debug define called DEBUG_CLIP_REGIONS can be used to draw
the current clip region. It is off by default, as is region
clipping.
The default implementation of clipPath() and clipRegion(), now
in native, mimics the previous Dalvik implementation to prevent
regressions.
Change-Id: I7903e7cfd7412b9b9b622566d4dbfce7bdcec00c
Diffstat (limited to 'core/java/android/view/HardwareRenderer.java')
| -rw-r--r-- | core/java/android/view/HardwareRenderer.java | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index 7ecdcbefc88a..0d45bbc20cca 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - package android.view; import android.content.ComponentCallbacks2; @@ -174,6 +173,17 @@ public abstract class HardwareRenderer { public static final String DEBUG_SHOW_OVERDRAW_PROPERTY = "debug.hwui.show_overdraw"; /** + * Turn on to allow region clipping (see + * {@link android.graphics.Canvas#clipPath(android.graphics.Path)} and + * {@link android.graphics.Canvas#clipRegion(android.graphics.Region)}. + * + * When this option is turned on a stencil buffer is always required. + * If this option is off a stencil buffer is only created when the overdraw + * debugging mode is turned on. + */ + private static final boolean REGION_CLIPPING_ENABLED = false; + + /** * A process can set this flag to false to prevent the use of hardware * rendering. * @@ -876,10 +886,12 @@ public abstract class HardwareRenderer { changed = true; mShowOverdraw = value; - if (surface != null && isEnabled()) { - if (validate()) { - sEglConfig = loadEglConfig(); - invalidate(surface); + if (!REGION_CLIPPING_ENABLED) { + if (surface != null && isEnabled()) { + if (validate()) { + sEglConfig = loadEglConfig(); + invalidate(surface); + } } } } @@ -1752,6 +1764,11 @@ public abstract class HardwareRenderer { @Override int[] getConfig(boolean dirtyRegions) { + //noinspection PointlessBooleanExpression + final int stencilSize = mShowOverdraw || REGION_CLIPPING_ENABLED ? + GLES20Canvas.getStencilSize() : 0; + final int swapBehavior = dirtyRegions ? EGL14.EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0; + return new int[] { EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL_RED_SIZE, 8, @@ -1760,14 +1777,12 @@ public abstract class HardwareRenderer { EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 0, EGL_CONFIG_CAVEAT, EGL_NONE, - // TODO: Find a better way to choose the stencil size - EGL_STENCIL_SIZE, mShowOverdraw ? GLES20Canvas.getStencilSize() : 0, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT | - (dirtyRegions ? EGL14.EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0), + EGL_STENCIL_SIZE, stencilSize, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT | swapBehavior, EGL_NONE }; } - + @Override void initCaches() { GLES20Canvas.initCaches(); |
