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

Commit 7c7d1357 authored by Xia Wang's avatar Xia Wang
Browse files

Fill in opengl benchmark test:

 - display a list view

Change-Id: I72ac8e4c84ae497f2297ed3c803a62db2600ef08
parent cb040a06
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,8 @@ public class RsBenchRS {


    private static final String TAG = "RsBenchRS";
    private static final String TAG = "RsBenchRS";
    private static final String SAMPLE_TEXT = "Bench Test";
    private static final String SAMPLE_TEXT = "Bench Test";
    private static final String LIST_TEXT =
      "This is a sample list of text to show in the list view";


    int mWidth;
    int mWidth;
    int mHeight;
    int mHeight;
@@ -128,6 +130,7 @@ public class RsBenchRS {


    private ScriptField_ListAllocs_s mTextureAllocs;
    private ScriptField_ListAllocs_s mTextureAllocs;
    private ScriptField_ListAllocs_s mSampleTextAllocs;
    private ScriptField_ListAllocs_s mSampleTextAllocs;
    private ScriptField_ListAllocs_s mSampleListViewAllocs;


    private ScriptC_rsbench mScript;
    private ScriptC_rsbench mScript;


@@ -567,6 +570,15 @@ public class RsBenchRS {
        mSampleTextAllocs.copyAll();
        mSampleTextAllocs.copyAll();
        mScript.bind_gSampleTextList100(mSampleTextAllocs);
        mScript.bind_gSampleTextList100(mSampleTextAllocs);


        mSampleListViewAllocs = new ScriptField_ListAllocs_s(mRS, 1000);
        for (int i = 0; i < 1000; i++) {
            ScriptField_ListAllocs_s.Item textElem = new ScriptField_ListAllocs_s.Item();
            textElem.item = Allocation.createFromString(mRS, LIST_TEXT, Allocation.USAGE_SCRIPT);
            mSampleListViewAllocs.set(textElem, i, false);
        }
        mSampleListViewAllocs.copyAll();
        mScript.bind_gListViewText(mSampleListViewAllocs);

        mRS.bindRootScript(mScript);
        mRS.bindRootScript(mScript);
    }
    }
}
}
+39 −9
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@
const int RS_MSG_TEST_DONE = 100;
const int RS_MSG_TEST_DONE = 100;
const int RS_MSG_RESULTS_READY = 101;
const int RS_MSG_RESULTS_READY = 101;


const int gMaxModes = 29;
const int gMaxModes = 30;
int gMaxLoops;
int gMaxLoops;


// Allocation to send test names back to java
// Allocation to send test names back to java
@@ -52,6 +52,7 @@ typedef struct ListAllocs_s {


ListAllocs *gTexList100;
ListAllocs *gTexList100;
ListAllocs *gSampleTextList100;
ListAllocs *gSampleTextList100;
ListAllocs *gListViewText;


rs_mesh g10by10Mesh;
rs_mesh g10by10Mesh;
rs_mesh g100by100Mesh;
rs_mesh g100by100Mesh;
@@ -303,6 +304,35 @@ static void displayImageWithText(int wResolution, int hResolution, int meshMode)
    }
    }
}
}


// Display a list of text as the list view
static void displayListView() {
    // set text color
    rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
    rsgBindFont(gFontSans);

    // get the size of the list
    rs_allocation textAlloc;
    textAlloc = rsGetAllocation(gListViewText);
    int allocSize = rsAllocationGetDimX(textAlloc);

    int listItemHeight = 80;
    int yOffset = listItemHeight;

    // set the color for the list divider
    rsgBindProgramFragment(gProgFragmentColor);
    rsgProgramFragmentConstantColor(gProgFragmentColor, 1.0, 1.0, 1.0, 1);

    // draw the list with divider
    for (int i = 0; i < allocSize; i++) {
        if (yOffset - listItemHeight > gRenderSurfaceH) {
            break;
        }
        rsgDrawRect(0, yOffset - 1, gRenderSurfaceW, yOffset, 0);
        rsgDrawText(gListViewText[i].item, 20, yOffset - 10);
        yOffset += listItemHeight;
    }
}

static float gTorusRotation = 0;
static float gTorusRotation = 0;
static void updateModelMatrix(rs_matrix4x4 *matrix, void *buffer) {
static void updateModelMatrix(rs_matrix4x4 *matrix, void *buffer) {
    if (buffer == 0) {
    if (buffer == 0) {
@@ -602,14 +632,11 @@ static const char *testNames[] = {
    "Geo test 25.6k heavy fragment heavy vertex",
    "Geo test 25.6k heavy fragment heavy vertex",
    "Geo test 51.2k heavy fragment heavy vertex",
    "Geo test 51.2k heavy fragment heavy vertex",
    "Geo test 204.8k small tries heavy fragment heavy vertex",
    "Geo test 204.8k small tries heavy fragment heavy vertex",
    "UI test with icon display 10 by 10",     // 25
    "UI test with icon display 10 by 10",
    "UI test with icon display 100 by 100",   // 26
    "UI test with icon display 100 by 100",
    "UI test with image and text display 3 pages",  // 27
    "UI test with image and text display 3 pages",
    "UI test with image and text display 5 pages",  // 28
    "UI test with image and text display 5 pages",
    "UI test with list view",                       // 29
    "UI test with list view",
//    "UI test with live wallpaper",                  // 30
//    "Mesh with 10 by 10 texture",
//    "Mesh with 100 by 100 texture",
};
};


void getTestName(int testIndex) {
void getTestName(int testIndex) {
@@ -714,6 +741,9 @@ static void runTest(int index) {
    case 28:
    case 28:
        displayImageWithText(7, 5, 1);
        displayImageWithText(7, 5, 1);
        break;
        break;
    case 29:
        displayListView();
        break;
    }
    }
}
}