Loading core/java/android/view/GLES20Canvas.java +8 −1 Original line number Diff line number Diff line Loading @@ -527,11 +527,18 @@ class GLES20Canvas extends Canvas { @Override public void drawPath(Path path, Paint paint) { boolean hasModifier = setupModifiers(paint); if (path.isSimplePath) { if (path.rects != null) { nDrawRects(mRenderer, path.rects.mNativeRegion, paint.mNativePaint); } } else { nDrawPath(mRenderer, path.mNativePath, paint.mNativePaint); } if (hasModifier) nResetModifiers(mRenderer); } private native void nDrawPath(int renderer, int path, int paint); private native void nDrawRects(int renderer, int region, int paint); @Override public void drawPicture(Picture picture) { Loading core/jni/android_view_GLES20Canvas.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,16 @@ static void android_view_GLES20Canvas_drawRect(JNIEnv* env, jobject canvas, renderer->drawRect(left, top, right, bottom, paint); } static void android_view_GLES20Canvas_drawRects(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, SkRegion* region, SkPaint* paint) { SkRegion::Iterator it(*region); while (!it.done()) { const SkIRect& r = it.rect(); renderer->drawRect(r.fLeft, r.fTop, r.fRight, r.fBottom, paint); it.next(); } } static void android_view_GLES20Canvas_drawPath(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, SkPath* path, SkPaint* paint) { renderer->drawPath(path, paint); Loading Loading @@ -386,6 +396,7 @@ static JNINativeMethod gMethods[] = { { "nDrawPatch", "(II[BFFFFI)V", (void*) android_view_GLES20Canvas_drawPatch }, { "nDrawColor", "(III)V", (void*) android_view_GLES20Canvas_drawColor }, { "nDrawRect", "(IFFFFI)V", (void*) android_view_GLES20Canvas_drawRect }, { "nDrawRects", "(III)V", (void*) android_view_GLES20Canvas_drawRects }, { "nDrawPath", "(III)V", (void*) android_view_GLES20Canvas_drawPath }, { "nResetModifiers", "(I)V", (void*) android_view_GLES20Canvas_resetModifiers }, Loading graphics/java/android/graphics/Path.java +50 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.graphics; import android.view.HardwareRenderer; /** * The Path class encapsulates compound (multiple contour) geometric paths * consisting of straight line segments, quadratic curves, and cubic curves. Loading @@ -29,11 +31,22 @@ public class Path { */ public final int mNativePath; /** * @hide */ public boolean isSimplePath = true; /** * @hide */ public Region rects; private boolean mDetectSimplePaths; /** * Create an empty path */ public Path() { mNativePath = init1(); mDetectSimplePaths = HardwareRenderer.isAvailable(); } /** Loading @@ -47,6 +60,7 @@ public class Path { valNative = src.mNativePath; } mNativePath = init2(valNative); mDetectSimplePaths = HardwareRenderer.isAvailable(); } /** Loading @@ -54,6 +68,10 @@ public class Path { * This does NOT change the fill-type setting. */ public void reset() { isSimplePath = true; if (mDetectSimplePaths) { if (rects != null) rects.setEmpty(); } native_reset(mNativePath); } Loading @@ -62,6 +80,10 @@ public class Path { * keeps the internal data structure for faster reuse. */ public void rewind() { isSimplePath = true; if (mDetectSimplePaths) { if (rects != null) rects.setEmpty(); } native_rewind(mNativePath); } Loading @@ -69,6 +91,7 @@ public class Path { */ public void set(Path src) { if (this != src) { isSimplePath = src.isSimplePath; native_set(mNativePath, src.mNativePath); } } Loading Loading @@ -164,6 +187,7 @@ public class Path { * @param bounds Returns the computed bounds of the path's control points. * @param exact This parameter is no longer used. */ @SuppressWarnings({"UnusedDeclaration"}) public void computeBounds(RectF bounds, boolean exact) { native_computeBounds(mNativePath, bounds); } Loading Loading @@ -240,6 +264,7 @@ public class Path { * @param y2 The y-coordinate of the end point on a quadratic curve */ public void quadTo(float x1, float y1, float x2, float y2) { isSimplePath = false; native_quadTo(mNativePath, x1, y1, x2, y2); } Loading @@ -258,6 +283,7 @@ public class Path { * this contour, for the end point of a quadratic curve */ public void rQuadTo(float dx1, float dy1, float dx2, float dy2) { isSimplePath = false; native_rQuadTo(mNativePath, dx1, dy1, dx2, dy2); } Loading @@ -275,6 +301,7 @@ public class Path { */ public void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) { isSimplePath = false; native_cubicTo(mNativePath, x1, y1, x2, y2, x3, y3); } Loading @@ -285,6 +312,7 @@ public class Path { */ public void rCubicTo(float x1, float y1, float x2, float y2, float x3, float y3) { isSimplePath = false; native_rCubicTo(mNativePath, x1, y1, x2, y2, x3, y3); } Loading @@ -303,6 +331,7 @@ public class Path { */ public void arcTo(RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) { isSimplePath = false; native_arcTo(mNativePath, oval, startAngle, sweepAngle, forceMoveTo); } Loading @@ -318,6 +347,7 @@ public class Path { * @param sweepAngle Sweep angle (in degrees) measured clockwise */ public void arcTo(RectF oval, float startAngle, float sweepAngle) { isSimplePath = false; native_arcTo(mNativePath, oval, startAngle, sweepAngle, false); } Loading @@ -326,6 +356,7 @@ public class Path { * first point of the contour, a line segment is automatically added. */ public void close() { isSimplePath = false; native_close(mNativePath); } Loading Loading @@ -355,6 +386,11 @@ public class Path { if (rect == null) { throw new NullPointerException("need rect parameter"); } if (mDetectSimplePaths) { if (rects == null) rects = new Region(); rects.op((int) rect.left, (int) rect.top, (int) rect.right, (int) rect.bottom, Region.Op.UNION); } native_addRect(mNativePath, rect, dir.nativeInt); } Loading @@ -367,8 +403,11 @@ public class Path { * @param bottom The bottom of a rectangle to add to the path * @param dir The direction to wind the rectangle's contour */ public void addRect(float left, float top, float right, float bottom, Direction dir) { public void addRect(float left, float top, float right, float bottom, Direction dir) { if (mDetectSimplePaths) { if (rects == null) rects = new Region(); rects.op((int) left, (int) top, (int) right, (int) bottom, Region.Op.UNION); } native_addRect(mNativePath, left, top, right, bottom, dir.nativeInt); } Loading @@ -382,6 +421,7 @@ public class Path { if (oval == null) { throw new NullPointerException("need oval parameter"); } isSimplePath = false; native_addOval(mNativePath, oval, dir.nativeInt); } Loading @@ -394,6 +434,7 @@ public class Path { * @param dir The direction to wind the circle's contour */ public void addCircle(float x, float y, float radius, Direction dir) { isSimplePath = false; native_addCircle(mNativePath, x, y, radius, dir.nativeInt); } Loading @@ -408,6 +449,7 @@ public class Path { if (oval == null) { throw new NullPointerException("need oval parameter"); } isSimplePath = false; native_addArc(mNativePath, oval, startAngle, sweepAngle); } Loading @@ -423,6 +465,7 @@ public class Path { if (rect == null) { throw new NullPointerException("need rect parameter"); } isSimplePath = false; native_addRoundRect(mNativePath, rect, rx, ry, dir.nativeInt); } Loading @@ -442,6 +485,7 @@ public class Path { if (radii.length < 8) { throw new ArrayIndexOutOfBoundsException("radii[] needs 8 values"); } isSimplePath = false; native_addRoundRect(mNativePath, rect, radii, dir.nativeInt); } Loading @@ -452,6 +496,7 @@ public class Path { * @param dx The amount to translate the path in X as it is added */ public void addPath(Path src, float dx, float dy) { isSimplePath = false; native_addPath(mNativePath, src.mNativePath, dx, dy); } Loading @@ -461,6 +506,7 @@ public class Path { * @param src The path that is appended to the current path */ public void addPath(Path src) { isSimplePath = false; native_addPath(mNativePath, src.mNativePath); } Loading @@ -470,6 +516,7 @@ public class Path { * @param src The path to add as a new contour */ public void addPath(Path src, Matrix matrix) { if (!src.isSimplePath) isSimplePath = false; native_addPath(mNativePath, src.mNativePath, matrix.native_instance); } Loading Loading @@ -506,6 +553,7 @@ public class Path { * @param dy The new Y coordinate for the last point */ public void setLastPoint(float dx, float dy) { isSimplePath = false; native_setLastPoint(mNativePath, dx, dy); } Loading libs/hwui/SkiaShader.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -137,9 +137,6 @@ SkiaLinearGradientShader::SkiaLinearGradientShader(float* bounds, uint32_t* colo SkMatrix* matrix, bool blend): SkiaShader(kLinearGradient, key, tileMode, tileMode, matrix, blend), mBounds(bounds), mColors(colors), mPositions(positions), mCount(count) { for (int i = 0; i < count; i++) { LOGD("[GL] Gradient color %d = 0x%x", i, colors[i]); } } SkiaLinearGradientShader::~SkiaLinearGradientShader() { Loading Loading
core/java/android/view/GLES20Canvas.java +8 −1 Original line number Diff line number Diff line Loading @@ -527,11 +527,18 @@ class GLES20Canvas extends Canvas { @Override public void drawPath(Path path, Paint paint) { boolean hasModifier = setupModifiers(paint); if (path.isSimplePath) { if (path.rects != null) { nDrawRects(mRenderer, path.rects.mNativeRegion, paint.mNativePaint); } } else { nDrawPath(mRenderer, path.mNativePath, paint.mNativePaint); } if (hasModifier) nResetModifiers(mRenderer); } private native void nDrawPath(int renderer, int path, int paint); private native void nDrawRects(int renderer, int region, int paint); @Override public void drawPicture(Picture picture) { Loading
core/jni/android_view_GLES20Canvas.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -236,6 +236,16 @@ static void android_view_GLES20Canvas_drawRect(JNIEnv* env, jobject canvas, renderer->drawRect(left, top, right, bottom, paint); } static void android_view_GLES20Canvas_drawRects(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, SkRegion* region, SkPaint* paint) { SkRegion::Iterator it(*region); while (!it.done()) { const SkIRect& r = it.rect(); renderer->drawRect(r.fLeft, r.fTop, r.fRight, r.fBottom, paint); it.next(); } } static void android_view_GLES20Canvas_drawPath(JNIEnv* env, jobject canvas, OpenGLRenderer* renderer, SkPath* path, SkPaint* paint) { renderer->drawPath(path, paint); Loading Loading @@ -386,6 +396,7 @@ static JNINativeMethod gMethods[] = { { "nDrawPatch", "(II[BFFFFI)V", (void*) android_view_GLES20Canvas_drawPatch }, { "nDrawColor", "(III)V", (void*) android_view_GLES20Canvas_drawColor }, { "nDrawRect", "(IFFFFI)V", (void*) android_view_GLES20Canvas_drawRect }, { "nDrawRects", "(III)V", (void*) android_view_GLES20Canvas_drawRects }, { "nDrawPath", "(III)V", (void*) android_view_GLES20Canvas_drawPath }, { "nResetModifiers", "(I)V", (void*) android_view_GLES20Canvas_resetModifiers }, Loading
graphics/java/android/graphics/Path.java +50 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.graphics; import android.view.HardwareRenderer; /** * The Path class encapsulates compound (multiple contour) geometric paths * consisting of straight line segments, quadratic curves, and cubic curves. Loading @@ -29,11 +31,22 @@ public class Path { */ public final int mNativePath; /** * @hide */ public boolean isSimplePath = true; /** * @hide */ public Region rects; private boolean mDetectSimplePaths; /** * Create an empty path */ public Path() { mNativePath = init1(); mDetectSimplePaths = HardwareRenderer.isAvailable(); } /** Loading @@ -47,6 +60,7 @@ public class Path { valNative = src.mNativePath; } mNativePath = init2(valNative); mDetectSimplePaths = HardwareRenderer.isAvailable(); } /** Loading @@ -54,6 +68,10 @@ public class Path { * This does NOT change the fill-type setting. */ public void reset() { isSimplePath = true; if (mDetectSimplePaths) { if (rects != null) rects.setEmpty(); } native_reset(mNativePath); } Loading @@ -62,6 +80,10 @@ public class Path { * keeps the internal data structure for faster reuse. */ public void rewind() { isSimplePath = true; if (mDetectSimplePaths) { if (rects != null) rects.setEmpty(); } native_rewind(mNativePath); } Loading @@ -69,6 +91,7 @@ public class Path { */ public void set(Path src) { if (this != src) { isSimplePath = src.isSimplePath; native_set(mNativePath, src.mNativePath); } } Loading Loading @@ -164,6 +187,7 @@ public class Path { * @param bounds Returns the computed bounds of the path's control points. * @param exact This parameter is no longer used. */ @SuppressWarnings({"UnusedDeclaration"}) public void computeBounds(RectF bounds, boolean exact) { native_computeBounds(mNativePath, bounds); } Loading Loading @@ -240,6 +264,7 @@ public class Path { * @param y2 The y-coordinate of the end point on a quadratic curve */ public void quadTo(float x1, float y1, float x2, float y2) { isSimplePath = false; native_quadTo(mNativePath, x1, y1, x2, y2); } Loading @@ -258,6 +283,7 @@ public class Path { * this contour, for the end point of a quadratic curve */ public void rQuadTo(float dx1, float dy1, float dx2, float dy2) { isSimplePath = false; native_rQuadTo(mNativePath, dx1, dy1, dx2, dy2); } Loading @@ -275,6 +301,7 @@ public class Path { */ public void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) { isSimplePath = false; native_cubicTo(mNativePath, x1, y1, x2, y2, x3, y3); } Loading @@ -285,6 +312,7 @@ public class Path { */ public void rCubicTo(float x1, float y1, float x2, float y2, float x3, float y3) { isSimplePath = false; native_rCubicTo(mNativePath, x1, y1, x2, y2, x3, y3); } Loading @@ -303,6 +331,7 @@ public class Path { */ public void arcTo(RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) { isSimplePath = false; native_arcTo(mNativePath, oval, startAngle, sweepAngle, forceMoveTo); } Loading @@ -318,6 +347,7 @@ public class Path { * @param sweepAngle Sweep angle (in degrees) measured clockwise */ public void arcTo(RectF oval, float startAngle, float sweepAngle) { isSimplePath = false; native_arcTo(mNativePath, oval, startAngle, sweepAngle, false); } Loading @@ -326,6 +356,7 @@ public class Path { * first point of the contour, a line segment is automatically added. */ public void close() { isSimplePath = false; native_close(mNativePath); } Loading Loading @@ -355,6 +386,11 @@ public class Path { if (rect == null) { throw new NullPointerException("need rect parameter"); } if (mDetectSimplePaths) { if (rects == null) rects = new Region(); rects.op((int) rect.left, (int) rect.top, (int) rect.right, (int) rect.bottom, Region.Op.UNION); } native_addRect(mNativePath, rect, dir.nativeInt); } Loading @@ -367,8 +403,11 @@ public class Path { * @param bottom The bottom of a rectangle to add to the path * @param dir The direction to wind the rectangle's contour */ public void addRect(float left, float top, float right, float bottom, Direction dir) { public void addRect(float left, float top, float right, float bottom, Direction dir) { if (mDetectSimplePaths) { if (rects == null) rects = new Region(); rects.op((int) left, (int) top, (int) right, (int) bottom, Region.Op.UNION); } native_addRect(mNativePath, left, top, right, bottom, dir.nativeInt); } Loading @@ -382,6 +421,7 @@ public class Path { if (oval == null) { throw new NullPointerException("need oval parameter"); } isSimplePath = false; native_addOval(mNativePath, oval, dir.nativeInt); } Loading @@ -394,6 +434,7 @@ public class Path { * @param dir The direction to wind the circle's contour */ public void addCircle(float x, float y, float radius, Direction dir) { isSimplePath = false; native_addCircle(mNativePath, x, y, radius, dir.nativeInt); } Loading @@ -408,6 +449,7 @@ public class Path { if (oval == null) { throw new NullPointerException("need oval parameter"); } isSimplePath = false; native_addArc(mNativePath, oval, startAngle, sweepAngle); } Loading @@ -423,6 +465,7 @@ public class Path { if (rect == null) { throw new NullPointerException("need rect parameter"); } isSimplePath = false; native_addRoundRect(mNativePath, rect, rx, ry, dir.nativeInt); } Loading @@ -442,6 +485,7 @@ public class Path { if (radii.length < 8) { throw new ArrayIndexOutOfBoundsException("radii[] needs 8 values"); } isSimplePath = false; native_addRoundRect(mNativePath, rect, radii, dir.nativeInt); } Loading @@ -452,6 +496,7 @@ public class Path { * @param dx The amount to translate the path in X as it is added */ public void addPath(Path src, float dx, float dy) { isSimplePath = false; native_addPath(mNativePath, src.mNativePath, dx, dy); } Loading @@ -461,6 +506,7 @@ public class Path { * @param src The path that is appended to the current path */ public void addPath(Path src) { isSimplePath = false; native_addPath(mNativePath, src.mNativePath); } Loading @@ -470,6 +516,7 @@ public class Path { * @param src The path to add as a new contour */ public void addPath(Path src, Matrix matrix) { if (!src.isSimplePath) isSimplePath = false; native_addPath(mNativePath, src.mNativePath, matrix.native_instance); } Loading Loading @@ -506,6 +553,7 @@ public class Path { * @param dy The new Y coordinate for the last point */ public void setLastPoint(float dx, float dy) { isSimplePath = false; native_setLastPoint(mNativePath, dx, dy); } Loading
libs/hwui/SkiaShader.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -137,9 +137,6 @@ SkiaLinearGradientShader::SkiaLinearGradientShader(float* bounds, uint32_t* colo SkMatrix* matrix, bool blend): SkiaShader(kLinearGradient, key, tileMode, tileMode, matrix, blend), mBounds(bounds), mColors(colors), mPositions(positions), mCount(count) { for (int i = 0; i < count; i++) { LOGD("[GL] Gradient color %d = 0x%x", i, colors[i]); } } SkiaLinearGradientShader::~SkiaLinearGradientShader() { Loading