1 /* 2 * Copyright (C) 2016 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 17 #include "GLcommon/ObjectData.h" 18 ObjectDataType2NamedObjectType(ObjectDataType objDataType)19NamedObjectType ObjectDataType2NamedObjectType(ObjectDataType objDataType) { 20 switch (objDataType) { 21 case SHADER_DATA: 22 case PROGRAM_DATA: 23 return NamedObjectType::SHADER_OR_PROGRAM; 24 case TEXTURE_DATA: 25 return NamedObjectType::TEXTURE; 26 case BUFFER_DATA: 27 return NamedObjectType::VERTEXBUFFER; 28 case RENDERBUFFER_DATA: 29 return NamedObjectType::RENDERBUFFER; 30 case FRAMEBUFFER_DATA: 31 return NamedObjectType::FRAMEBUFFER; 32 case SAMPLER_DATA: 33 return NamedObjectType::SAMPLER; 34 case TRANSFORMFEEDBACK_DATA: 35 return NamedObjectType::TRANSFORM_FEEDBACK; 36 default: 37 return NamedObjectType::NULLTYPE; 38 } 39 } 40 ObjectData(android::base::Stream * stream)41ObjectData::ObjectData(android::base::Stream* stream) { 42 m_dataType = (ObjectDataType)stream->getBe32(); 43 m_needRestore = true; 44 } 45 onSave(android::base::Stream * stream,unsigned int globalName) const46void ObjectData::onSave(android::base::Stream* stream, unsigned int globalName) const { 47 stream->putBe32(m_dataType); 48 } 49 postLoad(const getObjDataPtr_t & getObjDataPtr)50void ObjectData::postLoad(const getObjDataPtr_t& getObjDataPtr) { 51 (void)getObjDataPtr; 52 } 53 restore(ObjectLocalName localName,const getGlobalName_t & getGlobalName)54void ObjectData::restore(ObjectLocalName localName, 55 const getGlobalName_t& getGlobalName) { 56 (void)localName; 57 (void)getGlobalName; 58 m_needRestore = false; 59 } 60 needRestore() const61bool ObjectData::needRestore() const { 62 return m_needRestore; 63 } 64 getGenNameInfo() const65GenNameInfo ObjectData::getGenNameInfo() const { 66 return GenNameInfo(ObjectDataType2NamedObjectType(m_dataType)); 67 } 68