blob: 8c63d82632acce8885c71c232b6da9793f644e5d [file] [log] [blame]
Jason Samsd19f10d2009-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 Sams9bee51c2009-08-05 13:57:03 -070026class ProgramVertexState;
Jason Samsd19f10d2009-05-22 14:03:28 -070027
28class ProgramVertex : public Program
29{
30public:
Jason Samsee411122009-07-21 12:20:54 -070031 const static uint32_t MAX_LIGHTS = 8;
Jason Samsd19f10d2009-05-22 14:03:28 -070032
Jason Sams0011bcf2009-12-15 12:58:36 -080033 ProgramVertex(Context *,const char * shaderText, uint32_t shaderLength,
34 const uint32_t * params, uint32_t paramLength);
35 ProgramVertex(Context *, bool texMat);
Jason Samsd19f10d2009-05-22 14:03:28 -070036 virtual ~ProgramVertex();
37
Jason Samsb13ada52009-08-25 11:34:49 -070038 virtual void setupGL(const Context *rsc, ProgramVertexState *state);
Jason Samsbb51c402009-11-25 13:22:07 -080039 virtual void setupGL2(const Context *rsc, ProgramVertexState *state, ShaderCache *sc);
Jason Samsd19f10d2009-05-22 14:03:28 -070040
41
Jason Samsd19f10d2009-05-22 14:03:28 -070042 void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;}
Jason Samsee411122009-07-21 12:20:54 -070043 void addLight(const Light *);
Jason Samsd19f10d2009-05-22 14:03:28 -070044
Jason Samsb0ec1b42009-07-28 12:02:16 -070045 void setProjectionMatrix(const rsc_Matrix *) const;
46 void setModelviewMatrix(const rsc_Matrix *) const;
47 void setTextureMatrix(const rsc_Matrix *) const;
48
Jason Samse9ad9a72009-09-30 17:36:20 -070049 void transformToScreen(const Context *, float *v4out, const float *v3in) const;
50
Jason Samsbb51c402009-11-25 13:22:07 -080051 virtual void createShader();
Jason Sams5dad8b42009-12-15 19:10:11 -080052 virtual void loadShader(Context *);
Jason Samsbb51c402009-11-25 13:22:07 -080053 virtual void init(Context *);
54
Jason Samse9ad9a72009-09-30 17:36:20 -070055
Jason Samsd19f10d2009-05-22 14:03:28 -070056protected:
Jason Samsee411122009-07-21 12:20:54 -070057 uint32_t mLightCount;
Jason Samsee411122009-07-21 12:20:54 -070058 ObjectBaseRef<const Light> mLights[MAX_LIGHTS];
59
Jason Samsd19f10d2009-05-22 14:03:28 -070060 // Hacks to create a program for now
61 bool mTextureMatrixEnable;
Jason Samsd19f10d2009-05-22 14:03:28 -070062};
63
64
Jason Sams9bee51c2009-08-05 13:57:03 -070065class ProgramVertexState
Jason Samsd19f10d2009-05-22 14:03:28 -070066{
67public:
68 ProgramVertexState();
69 ~ProgramVertexState();
70
Jason Sams9c54bdb2009-06-17 16:52:59 -070071 void init(Context *rsc, int32_t w, int32_t h);
Jason Sams61f08d62009-09-25 16:37:33 -070072 void deinit(Context *rsc);
Jason Samseb4b0312009-11-12 16:09:45 -080073 void updateSize(Context *rsc, int32_t w, int32_t h);
Jason Sams9c54bdb2009-06-17 16:52:59 -070074
75 ObjectBaseRef<ProgramVertex> mDefault;
Jason Sams9bee51c2009-08-05 13:57:03 -070076 ObjectBaseRef<ProgramVertex> mLast;
Jason Sams9c54bdb2009-06-17 16:52:59 -070077 ObjectBaseRef<Allocation> mDefaultAlloc;
Jason Sams9bee51c2009-08-05 13:57:03 -070078
Jason Sams61f08d62009-09-25 16:37:33 -070079 ObjectBaseRef<Type> mAllocType;
Jason Sams9c54bdb2009-06-17 16:52:59 -070080
Jason Samsd19f10d2009-05-22 14:03:28 -070081
Jason Samsce9adcc2009-12-16 14:13:06 -080082 float color[4];
Jason Samsd19f10d2009-05-22 14:03:28 -070083};
84
85
86}
87}
88#endif
89
90