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 /** 20 * The Java interface to JNI calls regarding mosaic preview rendering. 21 * 22 */ 23 public class MosaicRenderer 24 { 25 static 26 { 27 System.loadLibrary("jni_legacymosaic"); 28 } 29 30 /** 31 * Function to be called in onSurfaceCreated() to initialize 32 * the GL context, load and link the shaders and create the 33 * program. Returns a texture ID to be used for SurfaceTexture. 34 * 35 * @return textureID the texture ID of the newly generated texture to 36 * be assigned to the SurfaceTexture object. 37 */ init()38 public static native int init(); 39 40 /** 41 * Pass the drawing surface's width and height to initialize the 42 * renderer viewports and FBO dimensions. 43 * 44 * @param width width of the drawing surface in pixels. 45 * @param height height of the drawing surface in pixels. 46 * @param isLandscapeOrientation is the orientation of the activity layout in landscape. 47 */ reset(int width, int height, boolean isLandscapeOrientation)48 public static native void reset(int width, int height, boolean isLandscapeOrientation); 49 50 /** 51 * Calling this function will render the SurfaceTexture to a new 2D texture 52 * using the provided STMatrix. 53 * 54 * @param stMatrix texture coordinate transform matrix obtained from the 55 * Surface texture 56 */ preprocess(float[] stMatrix)57 public static native void preprocess(float[] stMatrix); 58 59 /** 60 * This function calls glReadPixels to transfer both the low-res and high-res 61 * data from the GPU memory to the CPU memory for further processing by the 62 * mosaicing library. 63 */ transferGPUtoCPU()64 public static native void transferGPUtoCPU(); 65 66 /** 67 * Function to be called in onDrawFrame() to update the screen with 68 * the new frame data. 69 */ step()70 public static native void step(); 71 72 /** 73 * Call this function when a new low-res frame has been processed by 74 * the mosaicing library. This will tell the renderer library to 75 * update its texture and warping transformation. Any calls to step() 76 * after this call will use the new image frame and transformation data. 77 */ ready()78 public static native void ready(); 79 80 /** 81 * This function allows toggling between showing the input image data 82 * (without applying any warp) and the warped image data. For running 83 * the renderer as a viewfinder, we set the flag to false. To see the 84 * preview mosaic, we set the flag to true. 85 * 86 * @param flag boolean flag to set the warping to true or false. 87 */ setWarping(boolean flag)88 public static native void setWarping(boolean flag); 89 } 90