Home | History | Annotate | Download | only in EGL
      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 "EglPixmapSurface.h"
     17 #include "EglOsApi.h"
     18 
     19 std::set<EGLNativePixmapType> EglPixmapSurface::s_associatedPixmaps;
     20 
     21 bool EglPixmapSurface::alreadyAssociatedWithConfig(EGLNativePixmapType pix) {
     22     return s_associatedPixmaps.find(pix) != s_associatedPixmaps.end();
     23 
     24 }
     25 
     26 EglPixmapSurface::EglPixmapSurface(EglDisplay *dpy,
     27                                    EGLNativePixmapType pix,
     28                                    EglConfig* config) :
     29            EglSurface(dpy, PIXMAP,config,0,0),
     30            m_pixmap(pix)
     31 {
     32     s_associatedPixmaps.insert(pix);
     33     m_native = EglOS::createPixmapSurface(pix);
     34 }
     35 
     36 EglPixmapSurface::~EglPixmapSurface() {
     37     s_associatedPixmaps.erase(m_pixmap);
     38 }
     39 
     40 bool EglPixmapSurface::getAttrib(EGLint attrib,EGLint* val) {
     41     switch(attrib) {
     42     case EGL_CONFIG_ID:
     43         *val = m_config->id();
     44         break;
     45     case EGL_WIDTH:
     46         *val = m_width;
     47         break;
     48     case EGL_HEIGHT:
     49         *val = m_height;
     50         break;
     51     case EGL_LARGEST_PBUFFER:
     52     case EGL_TEXTURE_FORMAT:
     53     case EGL_TEXTURE_TARGET:
     54     case EGL_MIPMAP_TEXTURE:
     55         break;
     56     default:
     57         return false;
     58     }
     59     return true;
     60 }
     61