• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 package android.opengl.cts;
17 
18 import android.app.Activity;
19 import android.content.res.Resources;
20 import android.graphics.Bitmap;
21 import android.graphics.BitmapFactory;
22 import android.os.Bundle;
23 import android.util.Log;
24 
25 public class CompressedTextureCtsActivity extends Activity {
26 
27     private static final String TAG = "CompressedTextureCtsActivity";
28 
29     private Resources mResources;
30 
31     private CompressedTextureSurfaceView mCompressedTextureView = null;
32 
33     @Override
onCreate(Bundle savedInstanceState)34     protected void onCreate(Bundle savedInstanceState) {
35         super.onCreate(savedInstanceState);
36 
37         Bundle extras = getIntent().getExtras();
38         String formatTest = extras.getString("TextureFormat", null);
39 
40         Log.i(TAG, "Testing format " + formatTest);
41 
42         mResources = getResources();
43 
44         CompressedTextureLoader.Texture compressed = null;
45 
46         BitmapFactory.Options optionsRGB = new BitmapFactory.Options();
47         optionsRGB.inPreferredConfig = Bitmap.Config.RGB_565;
48         optionsRGB.inScaled = false;
49         Bitmap bitmap = BitmapFactory.decodeResource(mResources, R.raw.basetex, optionsRGB);
50 
51         if (formatTest.equals(CompressedTextureLoader.TEXTURE_ETC1)) {
52             compressed = CompressedTextureLoader.createFromUncompressedETC1(bitmap);
53         } else if (formatTest.equals(CompressedTextureLoader.TEXTURE_S3TC)) {
54             compressed = CompressedTextureLoader.loadTextureDXT(mResources, R.raw.ddstex);
55         } else if (formatTest.equals(CompressedTextureLoader.TEXTURE_ATC)) {
56             compressed = CompressedTextureLoader.loadTextureATC(mResources, 0); //cts for now
57         } else if (formatTest.equals(CompressedTextureLoader.TEXTURE_PVRTC)) {
58             compressed = CompressedTextureLoader.loadTexturePVRTC(mResources, R.raw.pvrtex);
59         }
60 
61         mCompressedTextureView = new CompressedTextureSurfaceView(this, bitmap, compressed);
62         setContentView(mCompressedTextureView);
63     }
64 
65     @Override
onPause()66     protected void onPause() {
67         mCompressedTextureView.onPause();
68         super.onPause();
69     }
70 
71     @Override
onResume()72     protected void onResume() {
73         super.onResume();
74         mCompressedTextureView.onResume();
75     }
76 
getPassed()77     public boolean getPassed() throws InterruptedException {
78         return mCompressedTextureView.getTestPassed();
79     }
80 }
81