1326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams/*
2326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * Copyright (C) 2009 The Android Open Source Project
3326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
4326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * Licensed under the Apache License, Version 2.0 (the "License");
5326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * you may not use this file except in compliance with the License.
6326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * You may obtain a copy of the License at
7326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
8326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *      http://www.apache.org/licenses/LICENSE-2.0
9326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
10326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * Unless required by applicable law or agreed to in writing, software
11326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * distributed under the License is distributed on an "AS IS" BASIS,
12326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * See the License for the specific language governing permissions and
14326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * limitations under the License.
15326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams */
16326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
17326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#ifndef ANDROID_RS_PROGRAM_FRAGMENT_H
18326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#define ANDROID_RS_PROGRAM_FRAGMENT_H
19326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
20326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsProgram.h"
21326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
22326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams// ---------------------------------------------------------------------------
23326e0ddf89e8df2837752fbfd7a014814b32082cJason Samsnamespace android {
24326e0ddf89e8df2837752fbfd7a014814b32082cJason Samsnamespace renderscript {
25326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
26cfb1d11ce6826fce7241d316d8b7dcab661f63a6Jason Samsclass ProgramFragmentState;
27326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
28afb743aca56c18beb7ab924e75cb6e070ef3e55aAlex Sakhartchoukclass ProgramFragment : public Program {
29326e0ddf89e8df2837752fbfd7a014814b32082cJason Samspublic:
30748eb07e805b93c2bf79340d4937963ab739d17cAlex Sakhartchouk    ProgramFragment(Context *rsc, const char * shaderText, size_t shaderLength,
31748eb07e805b93c2bf79340d4937963ab739d17cAlex Sakhartchouk                    const char** textureNames, size_t textureNamesCount, const size_t *textureNamesLength,
32f8852d0494a260c583795a96a2a06c49b86a9b10Ian Rogers                    const uintptr_t * params, size_t paramLength);
33326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    virtual ~ProgramFragment();
34326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
35c19ff0177a7a0dadfc01b1990f822354fdc95991Alex Sakhartchouk    virtual void setup(Context *, ProgramFragmentState *);
36326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
37e3150cfb3edb028407669e4a65e087eae77e718cJason Sams    virtual void serialize(Context *rsc, OStream *stream) const;
38b825f67adb5d1e1751fe108e6dbf9c6f2555c283Alex Sakhartchouk    virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_FRAGMENT; }
39fb6b614bcea88a587a7ea4530be45ff0ffa0210eAlex Sakhartchouk    static ProgramFragment *createFromStream(Context *rsc, IStream *stream);
40326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
41383e5b1f68c321a77bfd7466fa1171a9bfab4a6fAlex Sakhartchouk    void setConstantColor(Context *, float, float, float, float);
426445e5210c6d7f8689e94be9026153d017c9545bJason Sams
43326e0ddf89e8df2837752fbfd7a014814b32082cJason Samsprotected:
446445e5210c6d7f8689e94be9026153d017c9545bJason Sams    float mConstantColor[4];
45660ccc77fbceda1f0a4b0b811fbb82a5b006ec9bAlex Sakhartchouk    int32_t mTextureUniformIndexStart;
46326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams};
47326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
48afb743aca56c18beb7ab924e75cb6e070ef3e55aAlex Sakhartchoukclass ProgramFragmentState {
49326e0ddf89e8df2837752fbfd7a014814b32082cJason Samspublic:
50326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ProgramFragmentState();
51326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ~ProgramFragmentState();
52326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
53326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ProgramFragment *mPF;
54771565f47fc44608444c00aa8fa3bda769ceaeceJason Sams    void init(Context *rsc);
55f2649a961db2995e9e24a6c98f8a419f1496c1b7Jason Sams    void deinit(Context *rsc);
56326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
578ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams    ObjectBaseRef<ProgramFragment> mDefault;
58a0a1b6fbece2eb8d72d788422ab3e5f58d5a9216Jason Sams    Vector<ProgramFragment *> mPrograms;
59cfb1d11ce6826fce7241d316d8b7dcab661f63a6Jason Sams
60cfb1d11ce6826fce7241d316d8b7dcab661f63a6Jason Sams    ObjectBaseRef<ProgramFragment> mLast;
61326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams};
62326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
63326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams}
64326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams}
65326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#endif
66326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
67326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
68326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
69326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
70