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 17 package com.android.camera.panorama; 18 19 import android.opengl.GLSurfaceView; 20 import android.util.Log; 21 22 import javax.microedition.khronos.egl.EGLConfig; 23 import javax.microedition.khronos.opengles.GL10; 24 25 public class MosaicRendererSurfaceViewRenderer implements GLSurfaceView.Renderer 26 { 27 private static final String TAG = "MosaicRendererSurfaceViewRenderer"; 28 29 private MosaicSurfaceCreateListener mSurfaceCreateListener; 30 31 /** A callback to be called when the surface is created */ 32 public interface MosaicSurfaceCreateListener { 33 public void onMosaicSurfaceCreated(final int surface); 34 public void onMosaicSurfaceChanged(); 35 } 36 37 @Override 38 public void onDrawFrame(GL10 gl) { 39 MosaicRenderer.step(); 40 } 41 42 @Override 43 public void onSurfaceChanged(GL10 gl, int width, int height) { 44 MosaicRenderer.reset(width, height); 45 Log.i(TAG, "Renderer: onSurfaceChanged"); 46 if (mSurfaceCreateListener != null) { 47 mSurfaceCreateListener.onMosaicSurfaceChanged(); 48 } 49 } 50 51 @Override 52 public void onSurfaceCreated(GL10 gl, EGLConfig config) { 53 Log.i(TAG, "onSurfaceCreated"); 54 if (mSurfaceCreateListener != null) { 55 mSurfaceCreateListener.onMosaicSurfaceCreated(MosaicRenderer.init()); 56 } 57 } 58 59 public void setMosaicSurfaceCreateListener(MosaicSurfaceCreateListener listener) { 60 mSurfaceCreateListener = listener; 61 } 62 63 public void setReady() { 64 MosaicRenderer.ready(); 65 } 66 67 public void preprocess(float[] transformMatrix) { 68 MosaicRenderer.preprocess(transformMatrix); 69 } 70 71 public void transferGPUtoCPU() { 72 MosaicRenderer.transferGPUtoCPU(); 73 } 74 75 public void setWarping(boolean flag) { 76 MosaicRenderer.setWarping(flag); 77 } 78 } 79