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 #include "EglPbufferSurface.h" 17 setAttrib(EGLint attrib,EGLint val)18bool EglPbufferSurface::setAttrib(EGLint attrib,EGLint val) { 19 switch(attrib) { 20 case EGL_WIDTH: 21 if(val < 0) return false; 22 m_width = val; 23 break; 24 case EGL_HEIGHT: 25 if(val < 0) return false; 26 m_height = val; 27 break; 28 case EGL_LARGEST_PBUFFER: 29 m_largest = val; 30 break; 31 case EGL_TEXTURE_FORMAT: 32 if(val != EGL_NO_TEXTURE && val != EGL_TEXTURE_RGB && val != EGL_TEXTURE_RGBA) return false; 33 m_texFormat = val; 34 break; 35 case EGL_TEXTURE_TARGET: 36 if(val != EGL_NO_TEXTURE && val != EGL_TEXTURE_2D) return false; 37 m_texTarget = val; 38 break; 39 case EGL_MIPMAP_TEXTURE: 40 m_texMipmap = val; 41 break; 42 default: 43 return false; 44 } 45 return true; 46 } 47 getAttrib(EGLint attrib,EGLint * val)48bool EglPbufferSurface::getAttrib(EGLint attrib,EGLint* val) { 49 switch(attrib) { 50 case EGL_CONFIG_ID: 51 *val = m_config->id(); 52 break; 53 case EGL_WIDTH: 54 *val = m_width; 55 break; 56 case EGL_HEIGHT: 57 *val = m_height; 58 break; 59 case EGL_LARGEST_PBUFFER: 60 *val = m_largest; 61 break; 62 case EGL_TEXTURE_FORMAT: 63 *val = m_texFormat; 64 break; 65 case EGL_TEXTURE_TARGET: 66 *val = m_texTarget; 67 break; 68 case EGL_MIPMAP_TEXTURE: 69 *val = m_texMipmap; 70 break; 71 default: 72 *val = m_config->getConfAttrib(attrib); 73 } 74 return true; 75 } 76