1 /*
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_FRAGMENT_H
18 #define ANDROID_RS_PROGRAM_FRAGMENT_H
19 
20 #include "rsProgram.h"
21 
22 // ---------------------------------------------------------------------------
23 namespace android {
24 namespace renderscript {
25 
26 class ProgramFragmentState;
27 
28 class ProgramFragment : public Program {
29 public:
30     ProgramFragment(Context *rsc, const char * shaderText, size_t shaderLength,
31                     const char** textureNames, size_t textureNamesCount, const size_t *textureNamesLength,
32                     const uintptr_t * params, size_t paramLength);
33     virtual ~ProgramFragment();
34 
35     virtual void setup(Context *, ProgramFragmentState *);
36 
37     virtual void serialize(Context *rsc, OStream *stream) const;
getClassId()38     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_FRAGMENT; }
39     static ProgramFragment *createFromStream(Context *rsc, IStream *stream);
40 
41     void setConstantColor(Context *, float, float, float, float);
42 
43 protected:
44     float mConstantColor[4];
45     int32_t mTextureUniformIndexStart;
46 };
47 
48 class ProgramFragmentState {
49 public:
50     ProgramFragmentState();
51     ~ProgramFragmentState();
52 
53     ProgramFragment *mPF;
54     void init(Context *rsc);
55     void deinit(Context *rsc);
56 
57     ObjectBaseRef<ProgramFragment> mDefault;
58     Vector<ProgramFragment *> mPrograms;
59 
60     ObjectBaseRef<ProgramFragment> mLast;
61 };
62 
63 }
64 }
65 #endif
66 
67 
68 
69 
70