blob: ee7e50837d0b171a88dc9d1f9234a81c54d0d2c0 [file] [log] [blame]
Alex Sakhartchouk6b5222d2010-12-13 14:48:21 -08001/*
2 * Copyright (C) 2008 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
Alex Sakhartchoukc29a4442011-02-22 10:30:32 -080017package com.android.perftest;
Alex Sakhartchouk6b5222d2010-12-13 14:48:21 -080018
19import java.io.Writer;
20import java.util.ArrayList;
21import java.util.concurrent.Semaphore;
22
23import android.renderscript.RSSurfaceView;
24import android.renderscript.RenderScript;
25import android.renderscript.RenderScriptGL;
26
27import android.content.Context;
28import android.content.res.Resources;
29import android.graphics.Bitmap;
30import android.graphics.drawable.BitmapDrawable;
31import android.graphics.drawable.Drawable;
32import android.os.Handler;
33import android.os.Message;
34import android.util.AttributeSet;
35import android.util.Log;
36import android.view.Surface;
37import android.view.SurfaceHolder;
38import android.view.SurfaceView;
39import android.view.KeyEvent;
40import android.view.MotionEvent;
41
42public class RsBenchView extends RSSurfaceView {
43
44 public RsBenchView(Context context) {
45 super(context);
Alex Sakhartchouk6b5222d2010-12-13 14:48:21 -080046 }
47
48 private RenderScriptGL mRS;
49 private RsBenchRS mRender;
50
51
52 public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
53 super.surfaceChanged(holder, format, w, h);
54 if (mRS == null) {
55 RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
56 sc.setDepth(16, 24);
57 mRS = createRenderScriptGL(sc);
58 mRS.setSurface(holder, w, h);
59 mRender = new RsBenchRS();
60 mRender.init(mRS, getResources(), w, h);
61 }
62 }
63
64 @Override
65 protected void onDetachedFromWindow() {
66 if (mRS != null) {
67 mRS = null;
68 destroyRenderScriptGL();
69 }
70 }
71
72 @Override
Alex Sakhartchouk08571962010-12-15 09:59:58 -080073 public boolean onKeyDown(int keyCode, KeyEvent event) {
Alex Sakhartchouk6b5222d2010-12-13 14:48:21 -080074 return super.onKeyDown(keyCode, event);
75 }
76
77
78 @Override
Alex Sakhartchouk08571962010-12-15 09:59:58 -080079 public boolean onTouchEvent(MotionEvent ev) {
Alex Sakhartchouk6b5222d2010-12-13 14:48:21 -080080 boolean ret = false;
81 int act = ev.getAction();
82 if (act == ev.ACTION_DOWN) {
83 mRender.onActionDown((int)ev.getX(), (int)ev.getY());
84 ret = true;
85 }
86
87 return ret;
88 }
89}
90
91