Home | History | Annotate | Download | only in GLcommon
      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 <GLcommon/GLESbuffer.h>
     17 #include <string.h>
     18 
     19 bool  GLESbuffer::setBuffer(GLuint size,GLuint usage,const GLvoid* data) {
     20     m_size = size;
     21     m_usage = usage;
     22     if(m_data) {
     23         delete [] m_data;
     24         m_data = NULL;
     25     }
     26     m_data = new unsigned char[size];
     27     if(m_data) {
     28         memcpy(m_data,data,size);
     29         m_conversionManager.clear();
     30         m_conversionManager.addRange(Range(0,m_size));
     31         return true;
     32     }
     33     return false;
     34 }
     35 
     36 bool  GLESbuffer::setSubBuffer(GLint offset,GLuint size,const GLvoid* data) {
     37     if(offset + size > m_size) return false;
     38     memcpy(m_data+offset,data,size);
     39     m_conversionManager.addRange(Range(offset,size));
     40     m_conversionManager.merge();
     41     return true;
     42 }
     43 
     44 void  GLESbuffer::getConversions(const RangeList& rIn,RangeList& rOut) {
     45         m_conversionManager.delRanges(rIn,rOut);
     46         rOut.merge();
     47 }
     48 
     49 GLESbuffer::~GLESbuffer() {
     50     if(m_data) {
     51         delete [] m_data;
     52     }
     53 }
     54