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 18 package android.filterfw.core; 19 20 import android.filterfw.core.Frame; 21 import android.filterfw.core.FrameFormat; 22 import android.filterfw.core.MutableFrameFormat; 23 24 /** 25 * @hide 26 */ 27 public abstract class FrameManager { 28 29 private FilterContext mContext; 30 31 public abstract Frame newFrame(FrameFormat format); 32 33 public abstract Frame newBoundFrame(FrameFormat format, int bindingType, long bindingId); 34 35 public Frame duplicateFrame(Frame frame) { 36 Frame result = newFrame(frame.getFormat()); 37 result.setDataFromFrame(frame); 38 return result; 39 } 40 41 public Frame duplicateFrameToTarget(Frame frame, int newTarget) { 42 MutableFrameFormat newFormat = frame.getFormat().mutableCopy(); 43 newFormat.setTarget(newTarget); 44 Frame result = newFrame(newFormat); 45 result.setDataFromFrame(frame); 46 return result; 47 } 48 49 public abstract Frame retainFrame(Frame frame); 50 51 public abstract Frame releaseFrame(Frame frame); 52 53 public FilterContext getContext() { 54 return mContext; 55 } 56 57 public GLEnvironment getGLEnvironment() { 58 return mContext != null ? mContext.getGLEnvironment() : null; 59 } 60 61 public void tearDown() { 62 } 63 64 void setContext(FilterContext context) { 65 mContext = context; 66 } 67 } 68