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 #ifndef GLES_BUFFER_H
17 #define GLES_BUFFER_H
18 
19 #include "aemu/base/files/Stream.h"
20 #include <stdio.h>
21 #include <GLES/gl.h>
22 #include <GLcommon/ObjectData.h>
23 #include <GLcommon/RangeManip.h>
24 
25 class GLESbuffer: public ObjectData {
26 public:
GLESbuffer()27    GLESbuffer():ObjectData(BUFFER_DATA) {}
28    GLESbuffer(android::base::Stream* stream);
29    void onSave(android::base::Stream* stream,
30                unsigned int globalName) const override;
31    void restore(ObjectLocalName localName,
32                 const getGlobalName_t& getGlobalName) override;
getSize()33    GLuint getSize(){return m_size;};
getUsage()34    GLuint getUsage(){return m_usage;};
getData()35    GLvoid* getData(){ return m_data;}
36    bool  setBuffer(GLuint size,GLuint usage,const GLvoid* data);
37    bool  setSubBuffer(GLuint offset, GLuint size, const GLvoid* data);
38    void  getConversions(const RangeList& rIn,RangeList& rOut);
fullyConverted()39    bool  fullyConverted(){return m_conversionManager.size() == 0;};
setBinded()40    void  setBinded(){m_wasBound = true;};
wasBinded()41    bool  wasBinded(){return m_wasBound;};
42    ~GLESbuffer();
43 
44 private:
45     GLuint         m_size = 0;
46     GLuint         m_usage = GL_STATIC_DRAW;
47     unsigned char* m_data = nullptr;
48     RangeList      m_conversionManager;
49     bool           m_wasBound = false;
50 };
51 
52 #endif
53