diff options
author | Romain Guy <romainguy@google.com> | 2011-03-14 18:16:39 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-14 18:16:39 -0700 |
commit | ee7ace065f77b53a57cb6273b9f2f5d85caba90c (patch) | |
tree | f54744657dcd45c37587b454b3abc307755cb724 /core | |
parent | a5732aa275273edf9ae91340a440b3f2cd47c682 (diff) | |
parent | 7b5b6abf852c039983eded25ebe43a70fef5a4ab (diff) | |
download | frameworks_base-ee7ace065f77b53a57cb6273b9f2f5d85caba90c.zip frameworks_base-ee7ace065f77b53a57cb6273b9f2f5d85caba90c.tar.gz frameworks_base-ee7ace065f77b53a57cb6273b9f2f5d85caba90c.tar.bz2 |
Merge "Fix rendering artifact in edge fades. Bug #4092053" into honeycomb-mr1
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/GLES20Canvas.java | 7 | ||||
-rw-r--r-- | core/java/android/view/HardwareCanvas.java | 4 | ||||
-rw-r--r-- | core/java/android/view/HardwareRenderer.java | 3 | ||||
-rw-r--r-- | core/java/android/view/View.java | 16 | ||||
-rw-r--r-- | core/java/android/view/ViewGroup.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/AbsListView.java | 1 | ||||
-rw-r--r-- | core/jni/android/graphics/Shader.cpp | 20 | ||||
-rw-r--r-- | core/jni/android_view_GLES20Canvas.cpp | 7 |
8 files changed, 40 insertions, 20 deletions
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index fa5479b..14f2e9d 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -245,12 +245,13 @@ class GLES20Canvas extends HardwareCanvas { private static native void nDestroyDisplayList(int displayList); @Override - public boolean drawDisplayList(DisplayList displayList, Rect dirty) { + public boolean drawDisplayList(DisplayList displayList, int width, int height, Rect dirty) { return nDrawDisplayList(mRenderer, - ((GLES20DisplayList) displayList).mNativeDisplayList, dirty); + ((GLES20DisplayList) displayList).mNativeDisplayList, width, height, dirty); } - private static native boolean nDrawDisplayList(int renderer, int displayList, Rect dirty); + private static native boolean nDrawDisplayList(int renderer, int displayList, + int width, int height, Rect dirty); /////////////////////////////////////////////////////////////////////////// // Hardware layer diff --git a/core/java/android/view/HardwareCanvas.java b/core/java/android/view/HardwareCanvas.java index cb1003a..caa7b74 100644 --- a/core/java/android/view/HardwareCanvas.java +++ b/core/java/android/view/HardwareCanvas.java @@ -53,13 +53,15 @@ public abstract class HardwareCanvas extends Canvas { * Draws the specified display list onto this canvas. * * @param displayList The display list to replay. + * @param width The width of the display list. + * @param height The height of the display list. * @param dirty The dirty region to redraw in the next pass, matters only * if this method returns true, can be null. * * @return True if the content of the display list requires another * drawing pass (invalidate()), false otherwise */ - abstract boolean drawDisplayList(DisplayList displayList, Rect dirty); + abstract boolean drawDisplayList(DisplayList displayList, int width, int height, Rect dirty); /** * Draws the specified layer onto this canvas. diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index 0cf7ae6..8584bf2 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -608,7 +608,8 @@ public abstract class HardwareRenderer { DisplayList displayList = view.getDisplayList(); if (displayList != null) { - if (canvas.drawDisplayList(displayList, mRedrawClip)) { + if (canvas.drawDisplayList(displayList, view.getWidth(), + view.getHeight(), mRedrawClip)) { if (mRedrawClip.isEmpty() || view.getParent() == null) { view.invalidate(); } else { diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 32c9e27..5a96efd 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -59,7 +59,6 @@ import android.util.Pools; import android.util.SparseArray; import android.util.TypedValue; import android.view.ContextMenu.ContextMenuInfo; -import android.view.View.MeasureSpec; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEventSource; import android.view.accessibility.AccessibilityManager; @@ -4651,6 +4650,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * @return True if the event was handled by the view, false otherwise. */ public boolean dispatchGenericMotionEvent(MotionEvent event) { + //noinspection SimplifiableIfStatement if (mOnGenericMotionListener != null && (mViewFlags & ENABLED_MASK) == ENABLED && mOnGenericMotionListener.onGenericMotion(this, event)) { return true; @@ -9326,7 +9326,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } final ScrollabilityCache scrollabilityCache = mScrollCache; - int length = scrollabilityCache.fadingEdgeLength; + final float fadeHeight = scrollabilityCache.fadingEdgeLength; + int length = (int) fadeHeight; // clip the fade length if top and bottom fades overlap // overlapping fades produce odd-looking artifacts @@ -9341,16 +9342,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility if (verticalEdges) { topFadeStrength = Math.max(0.0f, Math.min(1.0f, getTopFadingEdgeStrength())); - drawTop = topFadeStrength > 0.0f; + drawTop = topFadeStrength * fadeHeight > 1.0f; bottomFadeStrength = Math.max(0.0f, Math.min(1.0f, getBottomFadingEdgeStrength())); - drawBottom = bottomFadeStrength > 0.0f; + drawBottom = bottomFadeStrength * fadeHeight > 1.0f; } if (horizontalEdges) { leftFadeStrength = Math.max(0.0f, Math.min(1.0f, getLeftFadingEdgeStrength())); - drawLeft = leftFadeStrength > 0.0f; + drawLeft = leftFadeStrength * fadeHeight > 1.0f; rightFadeStrength = Math.max(0.0f, Math.min(1.0f, getRightFadingEdgeStrength())); - drawRight = rightFadeStrength > 0.0f; + drawRight = rightFadeStrength * fadeHeight > 1.0f; } saveCount = canvas.getSaveCount(); @@ -9388,7 +9389,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility final Paint p = scrollabilityCache.paint; final Matrix matrix = scrollabilityCache.matrix; final Shader fade = scrollabilityCache.shader; - final float fadeHeight = scrollabilityCache.fadingEdgeLength; if (drawTop) { matrix.setScale(1, fadeHeight * topFadeStrength); @@ -9438,6 +9438,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * * @return The known solid color background for this view, or 0 if the color may vary */ + @ViewDebug.ExportedProperty(category = "drawing") public int getSolidColor() { return 0; } @@ -11644,6 +11645,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * @return true if scrolling was clamped to an over-scroll boundary along either * axis, false otherwise. */ + @SuppressWarnings({"UnusedParameters"}) protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index f9692da..8dc86ac 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2585,7 +2585,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } } else { child.mPrivateFlags &= ~DIRTY_MASK; - ((HardwareCanvas) canvas).drawDisplayList(displayList, null); + ((HardwareCanvas) canvas).drawDisplayList(displayList, cr - cl, cb - ct, null); } } } else if (cache != null) { diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index eca39fc..d39271e 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -5226,6 +5226,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te * * @return The cache color hint */ + @ViewDebug.ExportedProperty(category = "drawing") public int getCacheColorHint() { return mCacheColorHint; } diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp index 0ea8225..7fdad10 100644 --- a/core/jni/android/graphics/Shader.cpp +++ b/core/jni/android/graphics/Shader.cpp @@ -119,7 +119,7 @@ static SkShader* LinearGradient_create1(JNIEnv* env, jobject o, const jint* colorValues = env->GetIntArrayElements(colorArray, NULL); SkAutoSTMalloc<8, SkScalar> storage(posArray ? count : 0); - SkScalar* pos = NULL; + SkScalar* pos = NULL; if (posArray) { AutoJavaFloatArray autoPos(env, posArray, count); @@ -164,7 +164,11 @@ static SkiaShader* LinearGradient_postCreate1(JNIEnv* env, jobject o, SkShader* } } else { storedPositions[0] = 0.0f; - storedPositions[1] = 1.0f; + const jfloat step = 1.0f / (count - 1); + for (size_t i = 1; i < count - 1; i++) { + storedPositions[i] = step * i; + } + storedPositions[count - 1] = 1.0f; } SkiaShader* skiaShader = new SkiaLinearGradientShader(storedBounds, storedColors, @@ -289,7 +293,11 @@ static SkiaShader* RadialGradient_postCreate1(JNIEnv* env, jobject o, SkShader* } } else { storedPositions[0] = 0.0f; - storedPositions[1] = 1.0f; + const jfloat step = 1.0f / (count - 1); + for (size_t i = 1; i < count - 1; i++) { + storedPositions[i] = step * i; + } + storedPositions[count - 1] = 1.0f; } SkiaShader* skiaShader = new SkiaCircularGradientShader(x, y, radius, storedColors, @@ -384,7 +392,11 @@ static SkiaShader* SweepGradient_postCreate1(JNIEnv* env, jobject o, SkShader* s } } else { storedPositions[0] = 0.0f; - storedPositions[1] = 1.0f; + const jfloat step = 1.0f / (count - 1); + for (size_t i = 1; i < count - 1; i++) { + storedPositions[i] = step * i; + } + storedPositions[count - 1] = 1.0f; } SkiaShader* skiaShader = new SkiaSweepGradientShader(x, y, storedColors, storedPositions, count, diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp index a78f660..5116f09 100644 --- a/core/jni/android_view_GLES20Canvas.cpp +++ b/core/jni/android_view_GLES20Canvas.cpp @@ -498,9 +498,10 @@ static void android_view_GLES20Canvas_destroyDisplayList(JNIEnv* env, } static bool android_view_GLES20Canvas_drawDisplayList(JNIEnv* env, - jobject clazz, OpenGLRenderer* renderer, DisplayList* displayList, jobject dirty) { + jobject clazz, OpenGLRenderer* renderer, DisplayList* displayList, + jint width, jint height, jobject dirty) { android::uirenderer::Rect bounds; - bool redraw = renderer->drawDisplayList(displayList, bounds); + bool redraw = renderer->drawDisplayList(displayList, width, height, bounds); if (redraw && dirty != NULL) { env->CallVoidMethod(dirty, gRectClassInfo.set, int(bounds.left), int(bounds.top), int(bounds.right), int(bounds.bottom)); @@ -664,7 +665,7 @@ static JNINativeMethod gMethods[] = { { "nGetDisplayList", "(I)I", (void*) android_view_GLES20Canvas_getDisplayList }, { "nDestroyDisplayList", "(I)V", (void*) android_view_GLES20Canvas_destroyDisplayList }, { "nGetDisplayListRenderer", "(I)I", (void*) android_view_GLES20Canvas_getDisplayListRenderer }, - { "nDrawDisplayList", "(IILandroid/graphics/Rect;)Z", + { "nDrawDisplayList", "(IIIILandroid/graphics/Rect;)Z", (void*) android_view_GLES20Canvas_drawDisplayList }, { "nInterrupt", "(I)V", (void*) android_view_GLES20Canvas_interrupt }, |