Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | #ifndef ANDROID_RS_FILE_A3D_H |
| 18 | #define ANDROID_RS_FILE_A3D_H |
| 19 | |
| 20 | #include "RenderScript.h" |
| 21 | #include "rsFileA3DDecls.h" |
| 22 | #include "rsMesh.h" |
| 23 | |
| 24 | #include <utils/String8.h> |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame^] | 25 | #include "rsStream.h" |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 26 | #include <stdio.h> |
| 27 | |
| 28 | // --------------------------------------------------------------------------- |
| 29 | namespace android { |
| 30 | namespace renderscript { |
| 31 | |
| 32 | class FileA3D |
| 33 | { |
| 34 | public: |
| 35 | FileA3D(); |
| 36 | ~FileA3D(); |
| 37 | |
| 38 | uint32_t mMajorVersion; |
| 39 | uint32_t mMinorVersion; |
| 40 | uint64_t mIndexOffset; |
| 41 | uint64_t mStringTableOffset; |
| 42 | bool mUse64BitOffsets; |
| 43 | |
| 44 | struct A3DIndexEntry { |
| 45 | String8 mID; |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame^] | 46 | A3DClassID mType; |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 47 | uint64_t mOffset; |
| 48 | void * mRsObj; |
| 49 | }; |
| 50 | |
| 51 | bool load(Context *rsc, FILE *f); |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame^] | 52 | size_t getNumLoadedEntries() const; |
| 53 | const A3DIndexEntry* getLoadedEntry(size_t index) const; |
| 54 | ObjectBase *initializeFromEntry(const A3DIndexEntry *entry); |
| 55 | |
| 56 | void appendToFile(ObjectBase *obj); |
| 57 | bool writeFile(const char *filename); |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 58 | |
| 59 | protected: |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 60 | |
| 61 | const uint8_t * mData; |
| 62 | void * mAlloc; |
| 63 | uint64_t mDataSize; |
| 64 | Context * mRsc; |
| 65 | |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame^] | 66 | OStream *mWriteStream; |
| 67 | Vector<A3DIndexEntry*> mWriteIndex; |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 68 | |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame^] | 69 | IStream *mReadStream; |
| 70 | Vector<A3DIndexEntry*> mIndex; |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | |
| 74 | } |
| 75 | } |
| 76 | #endif //ANDROID_RS_FILE_A3D_H |
| 77 | |
| 78 | |