Home | History | Annotate | Download | only in rs
      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 // ---------------------------------------------------------------------------
     23 namespace android {
     24 namespace renderscript {
     25 
     26 class ProgramVertexState;
     27 
     28 class ProgramVertex : public Program {
     29 public:
     30     ProgramVertex(Context *,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 ~ProgramVertex();
     34 
     35     virtual void setup(Context *rsc, ProgramVertexState *state);
     36 
     37     void setProjectionMatrix(Context *, const rsc_Matrix *) const;
     38     void getProjectionMatrix(Context *, rsc_Matrix *) const;
     39     void setModelviewMatrix(Context *, const rsc_Matrix *) const;
     40     void setTextureMatrix(Context *, const rsc_Matrix *) const;
     41 
     42     void transformToScreen(Context *, float *v4out, const float *v3in) const;
     43 
     44     virtual void serialize(Context *rsc, OStream *stream) const;
     45     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_VERTEX; }
     46     static ProgramVertex *createFromStream(Context *rsc, IStream *stream);
     47 };
     48 
     49 class ProgramVertexState {
     50 public:
     51     ProgramVertexState();
     52     ~ProgramVertexState();
     53 
     54     void init(Context *rsc);
     55     void deinit(Context *rsc);
     56     void updateSize(Context *rsc);
     57 
     58     ObjectBaseRef<ProgramVertex> mDefault;
     59     ObjectBaseRef<ProgramVertex> mLast;
     60     ObjectBaseRef<Allocation> mDefaultAlloc;
     61 };
     62 
     63 }
     64 }
     65 #endif
     66 
     67 
     68