TestBase.java revision 572a5031a5d8602db0bec0b253428a034bd4dd59
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.rs.image2;
18
19import android.app.Activity;
20import android.content.Context;
21import android.os.Bundle;
22import android.graphics.BitmapFactory;
23import android.graphics.Bitmap;
24import android.graphics.Canvas;
25import android.support.v8.renderscript.*;
26import android.view.SurfaceView;
27import android.view.SurfaceHolder;
28import android.widget.ImageView;
29import android.widget.SeekBar;
30import android.widget.TextView;
31import android.view.View;
32import android.util.Log;
33import java.lang.Math;
34import android.widget.Spinner;
35
36public class TestBase  {
37    protected final String TAG = "Img";
38
39    protected RenderScript mRS;
40    protected Allocation mInPixelsAllocation;
41    protected Allocation mInPixelsAllocation2;
42    protected Allocation mOutPixelsAllocation;
43
44    protected ImageProcessingActivity2 act;
45
46    // Override to use UI elements
47    public void onBar1Changed(int progress) {
48    }
49    public void onBar2Changed(int progress) {
50    }
51    public void onBar3Changed(int progress) {
52    }
53    public void onBar4Changed(int progress) {
54    }
55    public void onBar5Changed(int progress) {
56    }
57
58    // Override to use UI elements
59    // Unused bars will be hidden.
60    public boolean onBar1Setup(SeekBar b, TextView t) {
61        b.setVisibility(View.INVISIBLE);
62        t.setVisibility(View.INVISIBLE);
63        return false;
64    }
65    public boolean onBar2Setup(SeekBar b, TextView t) {
66        b.setVisibility(View.INVISIBLE);
67        t.setVisibility(View.INVISIBLE);
68        return false;
69    }
70    public boolean onBar3Setup(SeekBar b, TextView t) {
71        b.setVisibility(View.INVISIBLE);
72        t.setVisibility(View.INVISIBLE);
73        return false;
74    }
75    public boolean onBar4Setup(SeekBar b, TextView t) {
76        b.setVisibility(View.INVISIBLE);
77        t.setVisibility(View.INVISIBLE);
78        return false;
79    }
80    public boolean onBar5Setup(SeekBar b, TextView t) {
81        b.setVisibility(View.INVISIBLE);
82        t.setVisibility(View.INVISIBLE);
83        return false;
84    }
85
86    public boolean onSpinner1Setup(Spinner s) {
87        s.setVisibility(View.INVISIBLE);
88        return false;
89    }
90
91    public final void createBaseTest(ImageProcessingActivity2 ipact, Bitmap b, Bitmap b2, Bitmap outb) {
92        act = ipact;
93        mRS = ipact.mRS;
94
95        mInPixelsAllocation = ipact.mInPixelsAllocation;
96        mInPixelsAllocation2 = ipact.mInPixelsAllocation2;
97        mOutPixelsAllocation = ipact.mOutPixelsAllocation;
98
99        createTest(act.getResources());
100    }
101
102    // Must override
103    public void createTest(android.content.res.Resources res) {
104    }
105
106    // Must override
107    public void runTest() {
108    }
109
110    public void finish() {
111        mRS.finish();
112    }
113
114    public void destroy() {
115    }
116
117    public void updateBitmap(Bitmap b) {
118        mOutPixelsAllocation.copyTo(b);
119    }
120
121    // Override to configure specific benchmark config.
122    public void setupBenchmark() {
123    }
124
125    // Override to reset after benchmark.
126    public void exitBenchmark() {
127    }
128}
129