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 17package android.media.effect; 18 19import android.filterfw.core.Frame; 20import android.media.effect.EffectContext; 21 22/** 23 * Effect subclass for effects based on a single Filter with output size differnet 24 * from input. Subclasses need only invoke the constructor with the correct arguments 25 * to obtain an Effect implementation. 26 * 27 * @hide 28 */ 29public class SizeChangeEffect extends SingleFilterEffect { 30 31 public SizeChangeEffect(EffectContext context, 32 String name, 33 Class filterClass, 34 String inputName, 35 String outputName, 36 Object... finalParameters) { 37 super(context, name, filterClass, inputName, outputName, finalParameters); 38 } 39 40 @Override 41 public void apply(int inputTexId, int width, int height, int outputTexId) { 42 beginGLEffect(); 43 44 Frame inputFrame = frameFromTexture(inputTexId, width, height); 45 Frame resultFrame = mFunction.executeWithArgList(mInputName, inputFrame); 46 47 int outputWidth = resultFrame.getFormat().getWidth(); 48 int outputHeight = resultFrame.getFormat().getHeight(); 49 50 Frame outputFrame = frameFromTexture(outputTexId, outputWidth, outputHeight); 51 outputFrame.setDataFromFrame(resultFrame); 52 53 inputFrame.release(); 54 outputFrame.release(); 55 resultFrame.release(); 56 57 endGLEffect(); 58 } 59} 60