Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b2f5267 authored by Romain Guy's avatar Romain Guy
Browse files

Add support for arcs.

Change-Id: I96c057ff4eb1b464b03f132da0b85333777bee4f
parent c1cd9ba3
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -525,9 +525,15 @@ class GLES20Canvas extends HardwareCanvas {
    @Override
    public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter,
            Paint paint) {
        // TODO: Implement
        boolean hasModifier = setupModifiers(paint);
        nDrawArc(mRenderer, oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle,
                useCenter, paint.mNativePaint);
        if (hasModifier) nResetModifiers(mRenderer);
    }

    private native void nDrawArc(int renderer, float left, float top, float right, float bottom,
            float startAngle, float sweepAngle, boolean useCenter, int paint);

    @Override
    public void drawARGB(int a, int r, int g, int b) {
        drawColor((a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF));
+8 −0
Original line number Diff line number Diff line
@@ -332,6 +332,12 @@ static void android_view_GLES20Canvas_drawOval(JNIEnv* env, jobject canvas,
    renderer->drawOval(left, top, right, bottom, paint);
}

static void android_view_GLES20Canvas_drawArc(JNIEnv* env, jobject canvas,
        OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom,
        jfloat startAngle, jfloat sweepAngle, jboolean useCenter, SkPaint* paint) {
    renderer->drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint);
}

static void android_view_GLES20Canvas_drawRects(JNIEnv* env, jobject canvas,
        OpenGLRenderer* renderer, SkRegion* region, SkPaint* paint) {
    SkRegion::Iterator it(*region);
@@ -609,6 +615,8 @@ static JNINativeMethod gMethods[] = {
    { "nDrawRoundRect",     "(IFFFFFFI)V",     (void*) android_view_GLES20Canvas_drawRoundRect },
    { "nDrawCircle",        "(IFFFI)V",        (void*) android_view_GLES20Canvas_drawCircle },
    { "nDrawOval",          "(IFFFFI)V",       (void*) android_view_GLES20Canvas_drawOval },
    { "nDrawArc",           "(IFFFFFFZI)V",    (void*) android_view_GLES20Canvas_drawArc },

    { "nDrawPath",          "(III)V",          (void*) android_view_GLES20Canvas_drawPath },
    { "nDrawLines",         "(I[FIII)V",       (void*) android_view_GLES20Canvas_drawLines },

+1 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ public:
    CircleShapeCache circleShapeCache;
    OvalShapeCache ovalShapeCache;
    RectShapeCache rectShapeCache;
    ArcShapeCache arcShapeCache;
    PatchCache patchCache;
    TextDropShadowCache dropShadowCache;
    FboCache fboCache;
+15 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ const char* DisplayList::OP_NAMES[] = {
    "DrawRoundRect",
    "DrawCircle",
    "DrawOval",
    "DrawArc",
    "DrawPath",
    "DrawLines",
    "DrawText",
@@ -363,6 +364,11 @@ void DisplayList::replay(OpenGLRenderer& renderer, uint32_t level) {
                renderer.drawOval(getFloat(), getFloat(), getFloat(), getFloat(), getPaint());
            }
            break;
            case DrawArc: {
                renderer.drawArc(getFloat(), getFloat(), getFloat(), getFloat(),
                        getFloat(), getFloat(), getInt() == 1, getPaint());
            }
            break;
            case DrawPath: {
                renderer.drawPath(getPath(), getPaint());
            }
@@ -675,6 +681,15 @@ void DisplayListRenderer::drawOval(float left, float top, float right, float bot
    addPaint(paint);
}

void DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
        float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
    addOp(DisplayList::DrawOval);
    addBounds(left, top, right, bottom);
    addPoint(startAngle, sweepAngle);
    addInt(useCenter ? 1 : 0);
    addPaint(paint);
}

void DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
    addOp(DisplayList::DrawPath);
    addPath(path);
+3 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ public:
        DrawRoundRect,
        DrawCircle,
        DrawOval,
        DrawArc,
        DrawPath,
        DrawLines,
        DrawText,
@@ -281,6 +282,8 @@ public:
            float rx, float ry, SkPaint* paint);
    void drawCircle(float x, float y, float radius, SkPaint* paint);
    void drawOval(float left, float top, float right, float bottom, SkPaint* paint);
    void drawArc(float left, float top, float right, float bottom,
            float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
    void drawPath(SkPath* path, SkPaint* paint);
    void drawLines(float* points, int count, SkPaint* paint);
    void drawText(const char* text, int bytesCount, int count, float x, float y, SkPaint* paint);
Loading