Loading core/java/android/view/View.java +43 −21 Original line number Diff line number Diff line Loading @@ -22015,23 +22015,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } saveCount = canvas.getSaveCount(); int topSaveCount = -1; int bottomSaveCount = -1; int leftSaveCount = -1; int rightSaveCount = -1; int solidColor = getSolidColor(); if (solidColor == 0) { if (drawTop) { canvas.saveUnclippedLayer(left, top, right, top + length); topSaveCount = canvas.saveUnclippedLayer(left, top, right, top + length); } if (drawBottom) { canvas.saveUnclippedLayer(left, bottom - length, right, bottom); bottomSaveCount = canvas.saveUnclippedLayer(left, bottom - length, right, bottom); } if (drawLeft) { canvas.saveUnclippedLayer(left, top, left + length, bottom); leftSaveCount = canvas.saveUnclippedLayer(left, top, left + length, bottom); } if (drawRight) { canvas.saveUnclippedLayer(right - length, top, right, bottom); rightSaveCount = canvas.saveUnclippedLayer(right - length, top, right, bottom); } } else { scrollabilityCache.setFadeColor(solidColor); Loading @@ -22048,12 +22052,32 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final Matrix matrix = scrollabilityCache.matrix; final Shader fade = scrollabilityCache.shader; if (drawTop) { matrix.setScale(1, fadeHeight * topFadeStrength); // must be restored in the reverse order that they were saved if (drawRight) { matrix.setScale(1, fadeHeight * rightFadeStrength); matrix.postRotate(90); matrix.postTranslate(right, top); fade.setLocalMatrix(matrix); p.setShader(fade); if (solidColor == 0) { canvas.restoreUnclippedLayer(rightSaveCount, p); } else { canvas.drawRect(right - length, top, right, bottom, p); } } if (drawLeft) { matrix.setScale(1, fadeHeight * leftFadeStrength); matrix.postRotate(-90); matrix.postTranslate(left, top); fade.setLocalMatrix(matrix); p.setShader(fade); canvas.drawRect(left, top, right, top + length, p); if (solidColor == 0) { canvas.restoreUnclippedLayer(leftSaveCount, p); } else { canvas.drawRect(left, top, left + length, bottom, p); } } if (drawBottom) { Loading @@ -22062,25 +22086,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback, matrix.postTranslate(left, bottom); fade.setLocalMatrix(matrix); p.setShader(fade); if (solidColor == 0) { canvas.restoreUnclippedLayer(bottomSaveCount, p); } else { canvas.drawRect(left, bottom - length, right, bottom, p); } } if (drawLeft) { matrix.setScale(1, fadeHeight * leftFadeStrength); matrix.postRotate(-90); if (drawTop) { matrix.setScale(1, fadeHeight * topFadeStrength); matrix.postTranslate(left, top); fade.setLocalMatrix(matrix); p.setShader(fade); canvas.drawRect(left, top, left + length, bottom, p); if (solidColor == 0) { canvas.restoreUnclippedLayer(topSaveCount, p); } else { canvas.drawRect(left, top, right, top + length, p); } if (drawRight) { matrix.setScale(1, fadeHeight * rightFadeStrength); matrix.postRotate(90); matrix.postTranslate(right, top); fade.setLocalMatrix(matrix); p.setShader(fade); canvas.drawRect(right - length, top, right, bottom, p); } canvas.restoreToCount(saveCount); core/jni/android_graphics_Canvas.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,11 @@ static jint saveUnclippedLayer(jlong canvasHandle, jint l, jint t, jint r, jint return reinterpret_cast<jint>(get_canvas(canvasHandle)->saveUnclippedLayer(l, t, r, b)); } static void restoreUnclippedLayer(jlong canvasHandle, jint saveCount, jlong paintHandle) { Paint* paint = reinterpret_cast<Paint*>(paintHandle); get_canvas(canvasHandle)->restoreUnclippedLayer(saveCount, *paint); } static bool restore(jlong canvasHandle) { Canvas* canvas = get_canvas(canvasHandle); if (canvas->getSaveCount() <= 1) { Loading Loading @@ -668,6 +673,7 @@ static const JNINativeMethod gMethods[] = { {"nSaveLayer","(JFFFFJI)I", (void*) CanvasJNI::saveLayer}, {"nSaveLayerAlpha","(JFFFFII)I", (void*) CanvasJNI::saveLayerAlpha}, {"nSaveUnclippedLayer","(JIIII)I", (void*) CanvasJNI::saveUnclippedLayer}, {"nRestoreUnclippedLayer","(JIJ)V", (void*) CanvasJNI::restoreUnclippedLayer}, {"nGetSaveCount","(J)I", (void*) CanvasJNI::getSaveCount}, {"nRestore","(J)Z", (void*) CanvasJNI::restore}, {"nRestoreToCount","(JI)V", (void*) CanvasJNI::restoreToCount}, Loading graphics/java/android/graphics/Canvas.java +13 −0 Original line number Diff line number Diff line Loading @@ -558,6 +558,16 @@ public class Canvas extends BaseCanvas { return nSaveUnclippedLayer(mNativeCanvasWrapper, left, top, right, bottom); } /** * @hide * @param saveCount The save level to restore to. * @param paint This is copied and is applied to the area within the unclipped layer's * bounds (i.e. equivalent to a drawPaint()) before restore() is called. */ public void restoreUnclippedLayer(int saveCount, Paint paint) { nRestoreUnclippedLayer(mNativeCanvasWrapper, saveCount, paint.getNativeInstance()); } /** * Helper version of saveLayer() that takes 4 values rather than a RectF. * Loading Loading @@ -1398,6 +1408,9 @@ public class Canvas extends BaseCanvas { @CriticalNative private static native int nSaveUnclippedLayer(long nativeCanvas, int l, int t, int r, int b); @CriticalNative private static native void nRestoreUnclippedLayer(long nativeCanvas, int saveCount, long nativePaint); @CriticalNative private static native boolean nRestore(long canvasHandle); @CriticalNative private static native void nRestoreToCount(long canvasHandle, int saveCount); Loading libs/hwui/DisplayListOps.in +2 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ X(ClipRect) X(ClipRRect) X(ClipRegion) X(DrawPaint) X(DrawBehind) X(DrawPath) X(DrawRect) X(DrawRegion) Loading libs/hwui/RecordingCanvas.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "SkAndroidFrameworkUtils.h" #include "SkCanvas.h" #include "SkCanvasPriv.h" #include "SkData.h" #include "SkDrawShadowInfo.h" #include "SkImage.h" Loading Loading @@ -187,6 +188,12 @@ struct DrawPaint final : Op { SkPaint paint; void draw(SkCanvas* c, const SkMatrix&) const { c->drawPaint(paint); } }; struct DrawBehind final : Op { static const auto kType = Type::DrawBehind; DrawBehind(const SkPaint& paint) : paint(paint) {} SkPaint paint; void draw(SkCanvas* c, const SkMatrix&) const { SkCanvasPriv::DrawBehind(c, paint); } }; struct DrawPath final : Op { static const auto kType = Type::DrawPath; DrawPath(const SkPath& path, const SkPaint& paint) : path(path), paint(paint) {} Loading Loading @@ -565,6 +572,9 @@ void DisplayListData::clipRegion(const SkRegion& region, SkClipOp op) { void DisplayListData::drawPaint(const SkPaint& paint) { this->push<DrawPaint>(0, paint); } void DisplayListData::drawBehind(const SkPaint& paint) { this->push<DrawBehind>(0, paint); } void DisplayListData::drawPath(const SkPath& path, const SkPaint& paint) { this->push<DrawPath>(0, path, paint); } Loading Loading @@ -834,6 +844,9 @@ void RecordingCanvas::onClipRegion(const SkRegion& region, SkClipOp op) { void RecordingCanvas::onDrawPaint(const SkPaint& paint) { fDL->drawPaint(paint); } void RecordingCanvas::onDrawBehind(const SkPaint& paint) { fDL->drawBehind(paint); } void RecordingCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { fDL->drawPath(path, paint); } Loading Loading
core/java/android/view/View.java +43 −21 Original line number Diff line number Diff line Loading @@ -22015,23 +22015,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } saveCount = canvas.getSaveCount(); int topSaveCount = -1; int bottomSaveCount = -1; int leftSaveCount = -1; int rightSaveCount = -1; int solidColor = getSolidColor(); if (solidColor == 0) { if (drawTop) { canvas.saveUnclippedLayer(left, top, right, top + length); topSaveCount = canvas.saveUnclippedLayer(left, top, right, top + length); } if (drawBottom) { canvas.saveUnclippedLayer(left, bottom - length, right, bottom); bottomSaveCount = canvas.saveUnclippedLayer(left, bottom - length, right, bottom); } if (drawLeft) { canvas.saveUnclippedLayer(left, top, left + length, bottom); leftSaveCount = canvas.saveUnclippedLayer(left, top, left + length, bottom); } if (drawRight) { canvas.saveUnclippedLayer(right - length, top, right, bottom); rightSaveCount = canvas.saveUnclippedLayer(right - length, top, right, bottom); } } else { scrollabilityCache.setFadeColor(solidColor); Loading @@ -22048,12 +22052,32 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final Matrix matrix = scrollabilityCache.matrix; final Shader fade = scrollabilityCache.shader; if (drawTop) { matrix.setScale(1, fadeHeight * topFadeStrength); // must be restored in the reverse order that they were saved if (drawRight) { matrix.setScale(1, fadeHeight * rightFadeStrength); matrix.postRotate(90); matrix.postTranslate(right, top); fade.setLocalMatrix(matrix); p.setShader(fade); if (solidColor == 0) { canvas.restoreUnclippedLayer(rightSaveCount, p); } else { canvas.drawRect(right - length, top, right, bottom, p); } } if (drawLeft) { matrix.setScale(1, fadeHeight * leftFadeStrength); matrix.postRotate(-90); matrix.postTranslate(left, top); fade.setLocalMatrix(matrix); p.setShader(fade); canvas.drawRect(left, top, right, top + length, p); if (solidColor == 0) { canvas.restoreUnclippedLayer(leftSaveCount, p); } else { canvas.drawRect(left, top, left + length, bottom, p); } } if (drawBottom) { Loading @@ -22062,25 +22086,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback, matrix.postTranslate(left, bottom); fade.setLocalMatrix(matrix); p.setShader(fade); if (solidColor == 0) { canvas.restoreUnclippedLayer(bottomSaveCount, p); } else { canvas.drawRect(left, bottom - length, right, bottom, p); } } if (drawLeft) { matrix.setScale(1, fadeHeight * leftFadeStrength); matrix.postRotate(-90); if (drawTop) { matrix.setScale(1, fadeHeight * topFadeStrength); matrix.postTranslate(left, top); fade.setLocalMatrix(matrix); p.setShader(fade); canvas.drawRect(left, top, left + length, bottom, p); if (solidColor == 0) { canvas.restoreUnclippedLayer(topSaveCount, p); } else { canvas.drawRect(left, top, right, top + length, p); } if (drawRight) { matrix.setScale(1, fadeHeight * rightFadeStrength); matrix.postRotate(90); matrix.postTranslate(right, top); fade.setLocalMatrix(matrix); p.setShader(fade); canvas.drawRect(right - length, top, right, bottom, p); } canvas.restoreToCount(saveCount);
core/jni/android_graphics_Canvas.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,11 @@ static jint saveUnclippedLayer(jlong canvasHandle, jint l, jint t, jint r, jint return reinterpret_cast<jint>(get_canvas(canvasHandle)->saveUnclippedLayer(l, t, r, b)); } static void restoreUnclippedLayer(jlong canvasHandle, jint saveCount, jlong paintHandle) { Paint* paint = reinterpret_cast<Paint*>(paintHandle); get_canvas(canvasHandle)->restoreUnclippedLayer(saveCount, *paint); } static bool restore(jlong canvasHandle) { Canvas* canvas = get_canvas(canvasHandle); if (canvas->getSaveCount() <= 1) { Loading Loading @@ -668,6 +673,7 @@ static const JNINativeMethod gMethods[] = { {"nSaveLayer","(JFFFFJI)I", (void*) CanvasJNI::saveLayer}, {"nSaveLayerAlpha","(JFFFFII)I", (void*) CanvasJNI::saveLayerAlpha}, {"nSaveUnclippedLayer","(JIIII)I", (void*) CanvasJNI::saveUnclippedLayer}, {"nRestoreUnclippedLayer","(JIJ)V", (void*) CanvasJNI::restoreUnclippedLayer}, {"nGetSaveCount","(J)I", (void*) CanvasJNI::getSaveCount}, {"nRestore","(J)Z", (void*) CanvasJNI::restore}, {"nRestoreToCount","(JI)V", (void*) CanvasJNI::restoreToCount}, Loading
graphics/java/android/graphics/Canvas.java +13 −0 Original line number Diff line number Diff line Loading @@ -558,6 +558,16 @@ public class Canvas extends BaseCanvas { return nSaveUnclippedLayer(mNativeCanvasWrapper, left, top, right, bottom); } /** * @hide * @param saveCount The save level to restore to. * @param paint This is copied and is applied to the area within the unclipped layer's * bounds (i.e. equivalent to a drawPaint()) before restore() is called. */ public void restoreUnclippedLayer(int saveCount, Paint paint) { nRestoreUnclippedLayer(mNativeCanvasWrapper, saveCount, paint.getNativeInstance()); } /** * Helper version of saveLayer() that takes 4 values rather than a RectF. * Loading Loading @@ -1398,6 +1408,9 @@ public class Canvas extends BaseCanvas { @CriticalNative private static native int nSaveUnclippedLayer(long nativeCanvas, int l, int t, int r, int b); @CriticalNative private static native void nRestoreUnclippedLayer(long nativeCanvas, int saveCount, long nativePaint); @CriticalNative private static native boolean nRestore(long canvasHandle); @CriticalNative private static native void nRestoreToCount(long canvasHandle, int saveCount); Loading
libs/hwui/DisplayListOps.in +2 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ X(ClipRect) X(ClipRRect) X(ClipRegion) X(DrawPaint) X(DrawBehind) X(DrawPath) X(DrawRect) X(DrawRegion) Loading
libs/hwui/RecordingCanvas.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "SkAndroidFrameworkUtils.h" #include "SkCanvas.h" #include "SkCanvasPriv.h" #include "SkData.h" #include "SkDrawShadowInfo.h" #include "SkImage.h" Loading Loading @@ -187,6 +188,12 @@ struct DrawPaint final : Op { SkPaint paint; void draw(SkCanvas* c, const SkMatrix&) const { c->drawPaint(paint); } }; struct DrawBehind final : Op { static const auto kType = Type::DrawBehind; DrawBehind(const SkPaint& paint) : paint(paint) {} SkPaint paint; void draw(SkCanvas* c, const SkMatrix&) const { SkCanvasPriv::DrawBehind(c, paint); } }; struct DrawPath final : Op { static const auto kType = Type::DrawPath; DrawPath(const SkPath& path, const SkPaint& paint) : path(path), paint(paint) {} Loading Loading @@ -565,6 +572,9 @@ void DisplayListData::clipRegion(const SkRegion& region, SkClipOp op) { void DisplayListData::drawPaint(const SkPaint& paint) { this->push<DrawPaint>(0, paint); } void DisplayListData::drawBehind(const SkPaint& paint) { this->push<DrawBehind>(0, paint); } void DisplayListData::drawPath(const SkPath& path, const SkPaint& paint) { this->push<DrawPath>(0, path, paint); } Loading Loading @@ -834,6 +844,9 @@ void RecordingCanvas::onClipRegion(const SkRegion& region, SkClipOp op) { void RecordingCanvas::onDrawPaint(const SkPaint& paint) { fDL->drawPaint(paint); } void RecordingCanvas::onDrawBehind(const SkPaint& paint) { fDL->drawBehind(paint); } void RecordingCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { fDL->drawPath(path, paint); } Loading