2009-05-22 14:03:28 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_RS_PROGRAM_FRAGMENT_H
|
|
|
|
#define ANDROID_RS_PROGRAM_FRAGMENT_H
|
|
|
|
|
|
|
|
#include "rsProgram.h"
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
namespace android {
|
|
|
|
namespace renderscript {
|
|
|
|
|
2009-08-05 13:57:03 -07:00
|
|
|
class ProgramFragmentState;
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
class ProgramFragment : public Program {
|
2009-05-22 14:03:28 -07:00
|
|
|
public:
|
2009-12-15 13:27:04 -08:00
|
|
|
ProgramFragment(Context *rsc, const char * shaderText,
|
|
|
|
uint32_t shaderLength, const uint32_t * params,
|
|
|
|
uint32_t paramLength);
|
2009-05-22 14:03:28 -07:00
|
|
|
virtual ~ProgramFragment();
|
|
|
|
|
2010-09-23 16:16:33 -07:00
|
|
|
virtual void setupGL2(Context *, ProgramFragmentState *, ShaderCache *sc);
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2009-11-25 13:22:07 -08:00
|
|
|
virtual void createShader();
|
2009-12-15 19:10:11 -08:00
|
|
|
virtual void loadShader(Context *rsc);
|
2009-11-25 13:22:07 -08:00
|
|
|
virtual void init(Context *rsc);
|
2010-05-21 12:53:13 -07:00
|
|
|
virtual void serialize(OStream *stream) const;
|
2010-06-04 10:06:50 -07:00
|
|
|
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_FRAGMENT; }
|
2010-05-21 12:53:13 -07:00
|
|
|
static ProgramFragment *createFromStream(Context *rsc, IStream *stream);
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2010-09-23 16:16:33 -07:00
|
|
|
void setConstantColor(Context *, float, float, float, float);
|
2010-08-04 17:50:20 -07:00
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
protected:
|
2010-08-04 17:50:20 -07:00
|
|
|
float mConstantColor[4];
|
2010-09-02 18:43:24 -07:00
|
|
|
int32_t mTextureUniformIndexStart;
|
2009-05-22 14:03:28 -07:00
|
|
|
};
|
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
class ProgramFragmentState {
|
2009-05-22 14:03:28 -07:00
|
|
|
public:
|
|
|
|
ProgramFragmentState();
|
|
|
|
~ProgramFragmentState();
|
|
|
|
|
|
|
|
ProgramFragment *mPF;
|
2010-05-14 15:30:29 -07:00
|
|
|
void init(Context *rsc);
|
2009-09-25 16:37:33 -07:00
|
|
|
void deinit(Context *rsc);
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2009-06-17 16:52:59 -07:00
|
|
|
ObjectBaseRef<ProgramFragment> mDefault;
|
2009-06-10 15:04:38 -07:00
|
|
|
Vector<ProgramFragment *> mPrograms;
|
2009-08-05 13:57:03 -07:00
|
|
|
|
|
|
|
ObjectBaseRef<ProgramFragment> mLast;
|
2009-05-22 14:03:28 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|