blob: e7442916bd2540e72042b634ca81bb8bfd5be532 [file] [log] [blame]
Jason Samsa5597fc2009-07-08 18:01:53 -07001/*
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 Sakhartchoukfb6b6142010-05-21 12:53:13 -070025#include "rsStream.h"
Jason Samsa5597fc2009-07-08 18:01:53 -070026#include <stdio.h>
27
28// ---------------------------------------------------------------------------
29namespace android {
30namespace renderscript {
31
32class FileA3D
33{
34public:
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 Sakhartchoukfb6b6142010-05-21 12:53:13 -070046 A3DClassID mType;
Jason Samsa5597fc2009-07-08 18:01:53 -070047 uint64_t mOffset;
48 void * mRsObj;
49 };
50
51 bool load(Context *rsc, FILE *f);
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070052 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 Samsa5597fc2009-07-08 18:01:53 -070058
59protected:
Jason Samsa5597fc2009-07-08 18:01:53 -070060
61 const uint8_t * mData;
62 void * mAlloc;
63 uint64_t mDataSize;
64 Context * mRsc;
65
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070066 OStream *mWriteStream;
67 Vector<A3DIndexEntry*> mWriteIndex;
Jason Samsa5597fc2009-07-08 18:01:53 -070068
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070069 IStream *mReadStream;
70 Vector<A3DIndexEntry*> mIndex;
Jason Samsa5597fc2009-07-08 18:01:53 -070071};
72
73
74}
75}
76#endif //ANDROID_RS_FILE_A3D_H
77
78