rsProgramVertex.h revision c19ff0177a7a0dadfc01b1990f822354fdc95991
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_VERTEX_H
18#define ANDROID_RS_PROGRAM_VERTEX_H
19
20#include "rsProgram.h"
21
22// ---------------------------------------------------------------------------
23namespace android {
24namespace renderscript {
25
26class ProgramVertexState;
27
28class ProgramVertex : public Program {
29public:
30    ProgramVertex(Context *,const char * shaderText, uint32_t shaderLength,
31                  const uint32_t * params, uint32_t paramLength);
32    virtual ~ProgramVertex();
33
34    virtual void setup(Context *rsc, ProgramVertexState *state);
35
36    void setProjectionMatrix(Context *, const rsc_Matrix *) const;
37    void getProjectionMatrix(Context *, rsc_Matrix *) const;
38    void setModelviewMatrix(Context *, const rsc_Matrix *) const;
39    void setTextureMatrix(Context *, const rsc_Matrix *) const;
40
41    void transformToScreen(Context *, float *v4out, const float *v3in) const;
42
43    virtual void serialize(OStream *stream) const;
44    virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_VERTEX; }
45    static ProgramVertex *createFromStream(Context *rsc, IStream *stream);
46};
47
48class ProgramVertexState {
49public:
50    ProgramVertexState();
51    ~ProgramVertexState();
52
53    void init(Context *rsc);
54    void deinit(Context *rsc);
55    void updateSize(Context *rsc);
56
57    ObjectBaseRef<ProgramVertex> mDefault;
58    ObjectBaseRef<ProgramVertex> mLast;
59    ObjectBaseRef<Allocation> mDefaultAlloc;
60};
61
62}
63}
64#endif
65
66
67