blob: 28554cc813d6cf5088ff7344340b01350ca9ae58 [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
28class ProgramVertex : public Program
29{
30public:
Jason Samsb5909ce2009-07-21 12:20:54 -070031 const static uint32_t MAX_LIGHTS = 8;
Jason Sams326e0dd2009-05-22 14:03:28 -070032
Jason Sams4815c0d2009-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 Sams326e0dd2009-05-22 14:03:28 -070036 virtual ~ProgramVertex();
37
Jason Samsafcb25c2009-08-25 11:34:49 -070038 virtual void setupGL(const Context *rsc, ProgramVertexState *state);
Jason Samsc460e552009-11-25 13:22:07 -080039 virtual void setupGL2(const Context *rsc, ProgramVertexState *state, ShaderCache *sc);
Jason Sams326e0dd2009-05-22 14:03:28 -070040
41
Jason Sams326e0dd2009-05-22 14:03:28 -070042 void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;}
Jason Samsb5909ce2009-07-21 12:20:54 -070043 void addLight(const Light *);
Jason Sams326e0dd2009-05-22 14:03:28 -070044
Jason Samsc9d43db2009-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 Sams3a97c592009-09-30 17:36:20 -070049 void transformToScreen(const Context *, float *v4out, const float *v3in) const;
50
Jason Samsc460e552009-11-25 13:22:07 -080051 virtual void createShader();
Jason Samscd506532009-12-15 19:10:11 -080052 virtual void loadShader(Context *);
Jason Samsc460e552009-11-25 13:22:07 -080053 virtual void init(Context *);
54
Jason Sams3a97c592009-09-30 17:36:20 -070055
Jason Sams326e0dd2009-05-22 14:03:28 -070056protected:
Jason Samsb5909ce2009-07-21 12:20:54 -070057 uint32_t mLightCount;
Jason Samsb5909ce2009-07-21 12:20:54 -070058 ObjectBaseRef<const Light> mLights[MAX_LIGHTS];
59
Jason Sams326e0dd2009-05-22 14:03:28 -070060 // Hacks to create a program for now
61 bool mTextureMatrixEnable;
Jason Sams433eca32010-01-06 11:57:52 -080062
63private:
Jason Sams9ebb0c42010-01-12 12:12:28 -080064 void initAddUserElement(const Element *e, String8 *names, uint32_t *count, const char *prefix);
Jason Sams326e0dd2009-05-22 14:03:28 -070065};
66
67
Jason Samscfb1d112009-08-05 13:57:03 -070068class ProgramVertexState
Jason Sams326e0dd2009-05-22 14:03:28 -070069{
70public:
71 ProgramVertexState();
72 ~ProgramVertexState();
73
Jason Sams8ce125b2009-06-17 16:52:59 -070074 void init(Context *rsc, int32_t w, int32_t h);
Jason Samsf2649a92009-09-25 16:37:33 -070075 void deinit(Context *rsc);
Jason Samse18844a2009-11-12 16:09:45 -080076 void updateSize(Context *rsc, int32_t w, int32_t h);
Jason Sams8ce125b2009-06-17 16:52:59 -070077
78 ObjectBaseRef<ProgramVertex> mDefault;
Jason Samscfb1d112009-08-05 13:57:03 -070079 ObjectBaseRef<ProgramVertex> mLast;
Jason Sams8ce125b2009-06-17 16:52:59 -070080 ObjectBaseRef<Allocation> mDefaultAlloc;
Jason Samscfb1d112009-08-05 13:57:03 -070081
Jason Samsf2649a92009-09-25 16:37:33 -070082 ObjectBaseRef<Type> mAllocType;
Jason Sams8ce125b2009-06-17 16:52:59 -070083
Jason Sams326e0dd2009-05-22 14:03:28 -070084
Jason Samse9ed6cc2009-12-16 14:13:06 -080085 float color[4];
Jason Sams326e0dd2009-05-22 14:03:28 -070086};
87
88
89}
90}
91#endif
92
93