blob: d5802524fb35b9c4fa2bc13f05056583800deafc [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_FRAGMENT_H
18#define ANDROID_RS_PROGRAM_FRAGMENT_H
19
20#include "rsProgram.h"
21
22// ---------------------------------------------------------------------------
23namespace android {
24namespace renderscript {
25
Jason Samscfb1d112009-08-05 13:57:03 -070026class ProgramFragmentState;
Jason Sams326e0dd2009-05-22 14:03:28 -070027
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080028class ProgramFragment : public Program {
Jason Sams326e0dd2009-05-22 14:03:28 -070029public:
Alex Sakhartchouk748eb072012-02-15 16:21:46 -080030 ProgramFragment(Context *rsc, const char * shaderText, size_t shaderLength,
31 const char** textureNames, size_t textureNamesCount, const size_t *textureNamesLength,
32 const uint32_t * params, size_t paramLength);
Jason Sams326e0dd2009-05-22 14:03:28 -070033 virtual ~ProgramFragment();
34
Alex Sakhartchoukc19ff012011-05-06 14:59:45 -070035 virtual void setup(Context *, ProgramFragmentState *);
Jason Sams326e0dd2009-05-22 14:03:28 -070036
Jason Samse3150cf2012-07-24 18:10:20 -070037 virtual void serialize(Context *rsc, OStream *stream) const;
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070038 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_FRAGMENT; }
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070039 static ProgramFragment *createFromStream(Context *rsc, IStream *stream);
Jason Sams326e0dd2009-05-22 14:03:28 -070040
Alex Sakhartchouk383e5b12010-09-23 16:16:33 -070041 void setConstantColor(Context *, float, float, float, float);
Jason Sams6445e522010-08-04 17:50:20 -070042
Jason Sams326e0dd2009-05-22 14:03:28 -070043protected:
Jason Sams6445e522010-08-04 17:50:20 -070044 float mConstantColor[4];
Alex Sakhartchouk660ccc72010-09-02 18:43:24 -070045 int32_t mTextureUniformIndexStart;
Jason Sams326e0dd2009-05-22 14:03:28 -070046};
47
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080048class ProgramFragmentState {
Jason Sams326e0dd2009-05-22 14:03:28 -070049public:
50 ProgramFragmentState();
51 ~ProgramFragmentState();
52
53 ProgramFragment *mPF;
Jason Sams771565f2010-05-14 15:30:29 -070054 void init(Context *rsc);
Jason Samsf2649a92009-09-25 16:37:33 -070055 void deinit(Context *rsc);
Jason Sams326e0dd2009-05-22 14:03:28 -070056
Jason Sams8ce125b2009-06-17 16:52:59 -070057 ObjectBaseRef<ProgramFragment> mDefault;
Jason Samsa0a1b6f2009-06-10 15:04:38 -070058 Vector<ProgramFragment *> mPrograms;
Jason Samscfb1d112009-08-05 13:57:03 -070059
60 ObjectBaseRef<ProgramFragment> mLast;
Jason Sams326e0dd2009-05-22 14:03:28 -070061};
62
Jason Sams326e0dd2009-05-22 14:03:28 -070063}
64}
65#endif
66
67
68
69