Search in sources :

Example 1 with TileData

use of com.test.tilebenchmark.RunData.TileData in project android_frameworks_base by ParanoidAndroid.

the class PlaybackView method setFrame.

public int setFrame(int frame) {
    if (mProfData == null || mProfData.frames.length == 0) {
        return 0;
    }
    int readyTiles = 0, unreadyTiles = 0, unplacedTiles = 0, numInvals = 0;
    mTempShapes.clear();
    mRenderStrings.clear();
    // create tile shapes (as they're drawn on bottom)
    for (TileData t : mProfData.frames[frame]) {
        if (t == mProfData.frames[frame][0]) {
            // viewport 'tile', add coords to render strings
            mRenderStrings.add(tileString(R.string.format_view_pos, t));
        } else if (t.level != INVAL_FLAG) {
            int colorId;
            if (t.isReady) {
                readyTiles++;
                colorId = R.color.ready_tile;
            } else {
                unreadyTiles++;
                colorId = R.color.unready_tile;
            }
            if (t.left < 0 || t.top < 0) {
                unplacedTiles++;
            }
            mTempShapes.add(new TileDrawable(t, colorId));
        } else {
            // inval 'tile', count and add coords to render strings
            numInvals++;
            mRenderStrings.add(tileString(R.string.format_inval_pos, t));
        }
    }
    // create invalidate shapes (drawn above tiles)
    int invalId = 0;
    for (TileData t : mProfData.frames[frame]) {
        if (t.level == INVAL_FLAG && t != mProfData.frames[frame][0]) {
            TileDrawable invalShape = new TileDrawable(t, R.color.inval_region_start);
            ValueAnimator tileAnimator = ObjectAnimator.ofInt(invalShape, "color", getResources().getColor(R.color.inval_region_start), getResources().getColor(R.color.inval_region_stop));
            tileAnimator.setDuration(numInvals * INVAL_CYCLE);
            tileAnimator.setEvaluator(new ArgbEvaluator());
            tileAnimator.setRepeatCount(ValueAnimator.INFINITE);
            tileAnimator.setRepeatMode(ValueAnimator.RESTART);
            float delay = (float) (invalId) * INVAL_CYCLE;
            tileAnimator.setStartDelay((int) delay);
            invalId++;
            tileAnimator.start();
            mTempShapes.add(invalShape);
        }
    }
    mRenderStrings.add(statString(R.string.ready_tiles, readyTiles));
    mRenderStrings.add(statString(R.string.unready_tiles, unreadyTiles));
    mRenderStrings.add(statString(R.string.unplaced_tiles, unplacedTiles));
    mRenderStrings.add(statString(R.string.number_invalidates, numInvals));
    // draw view rect (using first TileData object, on top)
    TileDrawable viewShape = new TileDrawable(mProfData.frames[frame][0], R.color.view);
    mTempShapes.add(viewShape);
    this.invalidate();
    return frame;
}
Also used : TileData(com.test.tilebenchmark.RunData.TileData) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator) Paint(android.graphics.Paint)

Example 2 with TileData

use of com.test.tilebenchmark.RunData.TileData in project android_frameworks_base by ParanoidAndroid.

the class ProfiledWebView method stopScrollTest.

/*
     * Called once the page has stopped scrolling
     */
public void stopScrollTest() {
    getWebViewClassic().tileProfilingStop();
    mIsTesting = false;
    if (mCallback == null) {
        getWebViewClassic().tileProfilingClear();
        return;
    }
    RunData data = new RunData(getWebViewClassic().tileProfilingNumFrames());
    // record the time spent (before scrolling) rendering the page
    data.singleStats.put(getResources().getString(R.string.render_millis), (double) mContentInvalMillis);
    // record framerate
    double framerate = animFramerate();
    Log.d(LOGTAG, "anim framerate was " + framerate);
    data.singleStats.put(getResources().getString(R.string.animation_framerate), framerate);
    for (int frame = 0; frame < data.frames.length; frame++) {
        data.frames[frame] = new TileData[getWebViewClassic().tileProfilingNumTilesInFrame(frame)];
        for (int tile = 0; tile < data.frames[frame].length; tile++) {
            int left = getWebViewClassic().tileProfilingGetInt(frame, tile, "left");
            int top = getWebViewClassic().tileProfilingGetInt(frame, tile, "top");
            int right = getWebViewClassic().tileProfilingGetInt(frame, tile, "right");
            int bottom = getWebViewClassic().tileProfilingGetInt(frame, tile, "bottom");
            boolean isReady = getWebViewClassic().tileProfilingGetInt(frame, tile, "isReady") == 1;
            int level = getWebViewClassic().tileProfilingGetInt(frame, tile, "level");
            float scale = getWebViewClassic().tileProfilingGetFloat(frame, tile, "scale");
            data.frames[frame][tile] = data.new TileData(left, top, right, bottom, isReady, level, scale);
        }
    }
    getWebViewClassic().tileProfilingClear();
    mCallback.profileCallback(data);
}
Also used : TileData(com.test.tilebenchmark.RunData.TileData)

Example 3 with TileData

use of com.test.tilebenchmark.RunData.TileData in project android_frameworks_base by ParanoidAndroid.

the class PlaybackGraphs method gatherFrameMetric.

private void gatherFrameMetric(int metricIndex, double[] metricValues, RunData data) {
    // create graph out of rectangles, one per frame
    int lastBar = 0;
    for (int frameIndex = 0; frameIndex < data.frames.length; frameIndex++) {
        TileData[] frame = data.frames[frameIndex];
        int newBar = (int) ((frame[0].top + frame[0].bottom) * frame[0].scale / 2.0f);
        MetricGen s = Metrics[metricIndex];
        double absoluteValue = s.getValue(frame);
        double relativeValue = absoluteValue / s.getMax();
        relativeValue = Math.min(1, relativeValue);
        relativeValue = Math.max(0, relativeValue);
        int rightPos = (int) (-BAR_WIDTH * metricIndex);
        int leftPos = (int) (-BAR_WIDTH * (metricIndex + relativeValue));
        ShapeDrawable graphBar = new ShapeDrawable();
        graphBar.getPaint().setColor(Color.BLUE);
        graphBar.setBounds(leftPos, lastBar, rightPos, newBar);
        mShapes.add(graphBar);
        metricValues[frameIndex] = absoluteValue;
        lastBar = newBar;
    }
}
Also used : TileData(com.test.tilebenchmark.RunData.TileData) ShapeDrawable(android.graphics.drawable.ShapeDrawable) Paint(android.graphics.Paint)

Aggregations

TileData (com.test.tilebenchmark.RunData.TileData)3 Paint (android.graphics.Paint)2 ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 ShapeDrawable (android.graphics.drawable.ShapeDrawable)1