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 "EglWindowSurface.h" 17 #include "EglOsApi.h" 18 19 std::set<EGLNativeWindowType> EglWindowSurface::s_associatedWins; 20 21 bool EglWindowSurface::alreadyAssociatedWithConfig(EGLNativeWindowType win) { 22 return s_associatedWins.find(win) != s_associatedWins.end(); 23 24 } 25 26 EglWindowSurface::EglWindowSurface(EglDisplay *dpy, 27 EGLNativeWindowType win, 28 EglConfig* config, 29 unsigned int width,unsigned int height) : 30 EglSurface(dpy, WINDOW,config,width,height), 31 m_win(win) 32 { 33 s_associatedWins.insert(win); 34 m_native = EglOS::createWindowSurface(win); 35 } 36 37 EglWindowSurface:: ~EglWindowSurface() { 38 s_associatedWins.erase(m_win); 39 } 40 41 bool EglWindowSurface::getAttrib(EGLint attrib,EGLint* val) { 42 switch(attrib) { 43 case EGL_CONFIG_ID: 44 *val = m_config->id(); 45 break; 46 case EGL_WIDTH: 47 *val = m_width; 48 break; 49 case EGL_HEIGHT: 50 *val = m_height; 51 break; 52 case EGL_LARGEST_PBUFFER: 53 case EGL_TEXTURE_FORMAT: 54 case EGL_TEXTURE_TARGET: 55 case EGL_MIPMAP_TEXTURE: 56 break; 57 default: 58 return false; 59 } 60 return true; 61 } 62