Home | History | Annotate | Download | only in core
      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 #ifndef ANDROID_FILTERFW_CORE_GL_BUFFER_INTERFACE_H
     18 #define ANDROID_FILTERFW_CORE_GL_BUFFER_INTERFACE_H
     19 
     20 #include <GLES2/gl2.h>
     21 
     22 namespace android {
     23 namespace filterfw {
     24 
     25 class GLTextureHandle {
     26   public:
     27     virtual ~GLTextureHandle() { }
     28 
     29     // Returns the held texture id.
     30     virtual GLuint GetTextureId() const = 0;
     31 
     32     // Binds the held texture. This may result in creating the texture if it
     33     // is not yet available.
     34     virtual bool FocusTexture() = 0;
     35 
     36     // Generates the mipmap chain of the held texture. Returns true, iff
     37     // generating was successful.
     38     virtual bool GenerateMipMap() = 0;
     39 
     40     // Set a texture parameter (see glTextureParameter documentation). Returns
     41     // true iff the parameter was set successfully.
     42     virtual bool SetTextureParameter(GLenum pname, GLint value) = 0;
     43 
     44     // Returns the texture target used.
     45     // Texture Target should be: GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES.
     46     virtual GLuint GetTextureTarget() const = 0;
     47 };
     48 
     49 class GLFrameBufferHandle {
     50   public:
     51     virtual ~GLFrameBufferHandle() { }
     52 
     53     // Returns the held FBO id.
     54     virtual GLuint GetFboId() const = 0;
     55 
     56     // Binds the held FBO. This may result in creating the FBO if it
     57     // is not yet available.
     58     virtual bool FocusFrameBuffer() = 0;
     59 };
     60 
     61 // Interface to instances that hold GL textures and frame-buffer-objects.
     62 // The GLFrame class implements this interface.
     63 class GLBufferHandle : public GLTextureHandle, public GLFrameBufferHandle {
     64   public:
     65     virtual ~GLBufferHandle() { }
     66 };
     67 
     68 } // namespace filterfw
     69 } // namespace android
     70 
     71 #endif  // ANDROID_FILTERFW_CORE_GL_BUFFER_INTERFACE_H
     72