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

Commit 13908822 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Update HWUI matrix API

1. more closely mirror Skia API by using const ref instead of ptrs
2. store SkMatrix in the drawOp instead of the linear allocation heap

Change-Id: I4b9f6f76b9f7d19325e29303d27b793679fd4823
parent 1015efb1
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -373,7 +373,7 @@ static void android_view_GLES20Canvas_setMatrix(JNIEnv* env, jobject clazz,
        jlong rendererPtr, jlong matrixPtr) {
    OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererPtr);
    SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr);
    renderer->setMatrix(matrix);
    renderer->setMatrix(matrix ? *matrix : SkMatrix::I());
}

static void android_view_GLES20Canvas_getMatrix(JNIEnv* env, jobject clazz,
@@ -387,7 +387,7 @@ static void android_view_GLES20Canvas_concatMatrix(JNIEnv* env, jobject clazz,
        jlong rendererPtr, jlong matrixPtr) {
    OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererPtr);
    SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr);
    renderer->concatMatrix(matrix);
    renderer->concatMatrix(*matrix);
}

// ----------------------------------------------------------------------------
@@ -430,7 +430,7 @@ static void android_view_GLES20Canvas_drawBitmapMatrix(JNIEnv* env, jobject claz
    OpenGLRenderer* renderer = reinterpret_cast<OpenGLRenderer*>(rendererPtr);
    SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr);
    SkPaint* paint = reinterpret_cast<SkPaint*>(paintPtr);
    renderer->drawBitmap(bitmap, matrix, paint);
    renderer->drawBitmap(bitmap, *matrix, paint);
}

static void android_view_GLES20Canvas_drawBitmapData(JNIEnv* env, jobject clazz,
+0 −5
Original line number Diff line number Diff line
@@ -80,10 +80,6 @@ void DisplayListData::cleanupResources() {
        delete paths.itemAt(i);
    }

    for (size_t i = 0; i < matrices.size(); i++) {
        delete matrices.itemAt(i);
    }

    bitmapResources.clear();
    ownedBitmapResources.clear();
    patchResources.clear();
@@ -91,7 +87,6 @@ void DisplayListData::cleanupResources() {
    paints.clear();
    regions.clear();
    paths.clear();
    matrices.clear();
    layers.clear();
}

+0 −1
Original line number Diff line number Diff line
@@ -125,7 +125,6 @@ public:
    Vector<const SkPath*> paths;
    SortedVector<const SkPath*> sourcePaths;
    Vector<const SkRegion*> regions;
    Vector<const SkMatrix*> matrices;
    Vector<Layer*> layers;
    uint32_t functorCount;
    bool hasDrawOps;
+12 −12
Original line number Diff line number Diff line
@@ -472,7 +472,7 @@ private:

class SetMatrixOp : public StateOp {
public:
    SetMatrixOp(const SkMatrix* matrix)
    SetMatrixOp(const SkMatrix& matrix)
            : mMatrix(matrix) {}

    virtual void applyState(OpenGLRenderer& renderer, int saveCount) const {
@@ -480,22 +480,22 @@ public:
    }

    virtual void output(int level, uint32_t logFlags) const {
        if (mMatrix) {
            OP_LOG("SetMatrix " SK_MATRIX_STRING, SK_MATRIX_ARGS(mMatrix));
        } else {
        if (mMatrix.isIdentity()) {
            OP_LOGS("SetMatrix (reset)");
        } else {
            OP_LOG("SetMatrix " SK_MATRIX_STRING, SK_MATRIX_ARGS(&mMatrix));
        }
    }

    virtual const char* name() { return "SetMatrix"; }

private:
    const SkMatrix* mMatrix;
    const SkMatrix mMatrix;
};

class ConcatMatrixOp : public StateOp {
public:
    ConcatMatrixOp(const SkMatrix* matrix)
    ConcatMatrixOp(const SkMatrix& matrix)
            : mMatrix(matrix) {}

    virtual void applyState(OpenGLRenderer& renderer, int saveCount) const {
@@ -503,13 +503,13 @@ public:
    }

    virtual void output(int level, uint32_t logFlags) const {
        OP_LOG("ConcatMatrix " SK_MATRIX_STRING, SK_MATRIX_ARGS(mMatrix));
        OP_LOG("ConcatMatrix " SK_MATRIX_STRING, SK_MATRIX_ARGS(&mMatrix));
    }

    virtual const char* name() { return "ConcatMatrix"; }

private:
    const SkMatrix* mMatrix;
    const SkMatrix mMatrix;
};

class ClipOp : public StateOp {
@@ -746,10 +746,10 @@ protected:

class DrawBitmapMatrixOp : public DrawBoundedOp {
public:
    DrawBitmapMatrixOp(const SkBitmap* bitmap, const SkMatrix* matrix, const SkPaint* paint)
    DrawBitmapMatrixOp(const SkBitmap* bitmap, const SkMatrix& matrix, const SkPaint* paint)
            : DrawBoundedOp(paint), mBitmap(bitmap), mMatrix(matrix) {
        mLocalBounds.set(0, 0, bitmap->width(), bitmap->height());
        const mat4 transform(*matrix);
        const mat4 transform(matrix);
        transform.mapRect(mLocalBounds);
    }

@@ -758,7 +758,7 @@ public:
    }

    virtual void output(int level, uint32_t logFlags) const {
        OP_LOG("Draw bitmap %p matrix " SK_MATRIX_STRING, mBitmap, SK_MATRIX_ARGS(mMatrix));
        OP_LOG("Draw bitmap %p matrix " SK_MATRIX_STRING, mBitmap, SK_MATRIX_ARGS(&mMatrix));
    }

    virtual const char* name() { return "DrawBitmapMatrix"; }
@@ -770,7 +770,7 @@ public:

private:
    const SkBitmap* mBitmap;
    const SkMatrix* mMatrix;
    const SkMatrix mMatrix;
};

class DrawBitmapRectOp : public DrawBoundedOp {
+3 −6
Original line number Diff line number Diff line
@@ -141,14 +141,12 @@ void DisplayListRenderer::skew(float sx, float sy) {
    StatefulBaseRenderer::skew(sx, sy);
}

void DisplayListRenderer::setMatrix(const SkMatrix* matrix) {
    matrix = refMatrix(matrix);
void DisplayListRenderer::setMatrix(const SkMatrix& matrix) {
    addStateOp(new (alloc()) SetMatrixOp(matrix));
    StatefulBaseRenderer::setMatrix(matrix);
}

void DisplayListRenderer::concatMatrix(const SkMatrix* matrix) {
    matrix = refMatrix(matrix);
void DisplayListRenderer::concatMatrix(const SkMatrix& matrix) {
    addStateOp(new (alloc()) ConcatMatrixOp(matrix));
    StatefulBaseRenderer::concatMatrix(matrix);
}
@@ -203,10 +201,9 @@ status_t DisplayListRenderer::drawBitmap(const SkBitmap* bitmap, float left, flo
    return DrawGlInfo::kStatusDone;
}

status_t DisplayListRenderer::drawBitmap(const SkBitmap* bitmap, const SkMatrix* matrix,
status_t DisplayListRenderer::drawBitmap(const SkBitmap* bitmap, const SkMatrix& matrix,
        const SkPaint* paint) {
    bitmap = refBitmap(bitmap);
    matrix = refMatrix(matrix);
    paint = refPaint(paint);

    addDrawOp(new (alloc()) DrawBitmapMatrixOp(bitmap, matrix, paint));
Loading