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