blob: b3115a301f625aebda99ba48ee07f612bb5b5bf2 [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();
52 virtual void loadShader();
53 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 Sams326e0dd2009-05-22 14:03:28 -070062};
63
64
Jason Samscfb1d112009-08-05 13:57:03 -070065class ProgramVertexState
Jason Sams326e0dd2009-05-22 14:03:28 -070066{
67public:
68 ProgramVertexState();
69 ~ProgramVertexState();
70
Jason Sams8ce125b2009-06-17 16:52:59 -070071 void init(Context *rsc, int32_t w, int32_t h);
Jason Samsf2649a92009-09-25 16:37:33 -070072 void deinit(Context *rsc);
Jason Samse18844a2009-11-12 16:09:45 -080073 void updateSize(Context *rsc, int32_t w, int32_t h);
Jason Sams8ce125b2009-06-17 16:52:59 -070074
75 ObjectBaseRef<ProgramVertex> mDefault;
Jason Samscfb1d112009-08-05 13:57:03 -070076 ObjectBaseRef<ProgramVertex> mLast;
Jason Sams8ce125b2009-06-17 16:52:59 -070077 ObjectBaseRef<Allocation> mDefaultAlloc;
Jason Samscfb1d112009-08-05 13:57:03 -070078
Jason Samsf2649a92009-09-25 16:37:33 -070079 ObjectBaseRef<Type> mAllocType;
Jason Sams8ce125b2009-06-17 16:52:59 -070080
Jason Sams326e0dd2009-05-22 14:03:28 -070081
82};
83
84
85}
86}
87#endif
88
89