blob: 2a5c863cd2e9e473374de7960a5f4fd74f773d28 [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -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_PROGRAM_VERTEX_H
18#define ANDROID_RS_PROGRAM_VERTEX_H
19
20#include "rsProgram.h"
21
22// ---------------------------------------------------------------------------
23namespace android {
24namespace renderscript {
25
Jason Samscfb1d112009-08-05 13:57:03 -070026class ProgramVertexState;
Jason Sams326e0dd2009-05-22 14:03:28 -070027
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080028class ProgramVertex : public Program {
Jason Sams326e0dd2009-05-22 14:03:28 -070029public:
Jason Sams4815c0d2009-12-15 12:58:36 -080030 ProgramVertex(Context *,const char * shaderText, uint32_t shaderLength,
31 const uint32_t * params, uint32_t paramLength);
Jason Sams326e0dd2009-05-22 14:03:28 -070032 virtual ~ProgramVertex();
33
Alex Sakhartchouk383e5b12010-09-23 16:16:33 -070034 virtual void setupGL2(Context *rsc, ProgramVertexState *state, ShaderCache *sc);
Jason Sams326e0dd2009-05-22 14:03:28 -070035
Alex Sakhartchouk383e5b12010-09-23 16:16:33 -070036 void setProjectionMatrix(Context *, const rsc_Matrix *) const;
37 void getProjectionMatrix(Context *, rsc_Matrix *) const;
38 void setModelviewMatrix(Context *, const rsc_Matrix *) const;
39 void setTextureMatrix(Context *, const rsc_Matrix *) const;
Jason Sams326e0dd2009-05-22 14:03:28 -070040
Alex Sakhartchouk383e5b12010-09-23 16:16:33 -070041 void transformToScreen(Context *, float *v4out, const float *v3in) const;
Jason Sams3a97c592009-09-30 17:36:20 -070042
Jason Sams87319de2010-11-22 16:20:16 -080043 virtual void createShader(Context *);
Jason Samscd506532009-12-15 19:10:11 -080044 virtual void loadShader(Context *);
Jason Samsc460e552009-11-25 13:22:07 -080045 virtual void init(Context *);
46
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070047 virtual void serialize(OStream *stream) const;
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070048 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_VERTEX; }
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070049 static ProgramVertex *createFromStream(Context *rsc, IStream *stream);
Jason Sams326e0dd2009-05-22 14:03:28 -070050};
51
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080052class ProgramVertexState {
Jason Sams326e0dd2009-05-22 14:03:28 -070053public:
54 ProgramVertexState();
55 ~ProgramVertexState();
56
Jason Sams771565f2010-05-14 15:30:29 -070057 void init(Context *rsc);
Jason Samsf2649a92009-09-25 16:37:33 -070058 void deinit(Context *rsc);
Jason Sams771565f2010-05-14 15:30:29 -070059 void updateSize(Context *rsc);
Jason Sams8ce125b2009-06-17 16:52:59 -070060
61 ObjectBaseRef<ProgramVertex> mDefault;
Jason Samscfb1d112009-08-05 13:57:03 -070062 ObjectBaseRef<ProgramVertex> mLast;
Jason Sams8ce125b2009-06-17 16:52:59 -070063 ObjectBaseRef<Allocation> mDefaultAlloc;
Jason Sams326e0dd2009-05-22 14:03:28 -070064};
65
Jason Sams326e0dd2009-05-22 14:03:28 -070066}
67}
68#endif
69
70