Home | History | Annotate | Download | only in rs
      1 /*
      2  * Copyright (C) 2012 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_SCRIPT_GROUP_H
     18 #define ANDROID_RS_SCRIPT_GROUP_H
     19 
     20 #include "rsAllocation.h"
     21 #include "rsScript.h"
     22 
     23 
     24 // ---------------------------------------------------------------------------
     25 namespace android {
     26 namespace renderscript {
     27 
     28 class ProgramVertex;
     29 class ProgramFragment;
     30 class ProgramRaster;
     31 class ProgramStore;
     32 
     33 class ScriptGroup : public ObjectBase {
     34 public:
     35     Vector<ObjectBaseRef<ScriptKernelID> > mKernels;
     36 
     37     class Link {
     38     public:
     39         ObjectBaseRef<const ScriptKernelID> mSource;
     40         ObjectBaseRef<const ScriptKernelID> mDstKernel;
     41         ObjectBaseRef<const ScriptFieldID> mDstField;
     42         ObjectBaseRef<const Type> mType;
     43         ObjectBaseRef<Allocation> mAlloc;
     44         Link();
     45         ~Link();
     46     };
     47 
     48     class Node {
     49     public:
     50         Node(Script *);
     51 
     52         Vector<const ScriptKernelID *> mKernels;
     53         Vector<Link *> mOutputs;
     54         Vector<Link *> mInputs;
     55         bool mSeen;
     56         int mOrder;
     57         Script *mScript;
     58     };
     59 
     60     class IO {
     61     public:
     62         IO(const ScriptKernelID *);
     63 
     64         const ScriptKernelID *mKernel;
     65         ObjectBaseRef<Allocation> mAlloc;
     66     };
     67 
     68     Vector<Link *> mLinks;
     69     Vector<Node *> mNodes;
     70     Vector<IO *> mInputs;
     71     Vector<IO *> mOutputs;
     72 
     73     struct Hal {
     74         void * drv;
     75 
     76         struct DriverInfo {
     77         };
     78         DriverInfo info;
     79     };
     80     Hal mHal;
     81 
     82     static ScriptGroup * create(Context *rsc,
     83                            ScriptKernelID ** kernels, size_t kernelsSize,
     84                            ScriptKernelID ** src, size_t srcSize,
     85                            ScriptKernelID ** dstK, size_t dstKSize,
     86                            ScriptFieldID ** dstF, size_t dstFSize,
     87                            const Type ** type, size_t typeSize);
     88 
     89     virtual void serialize(Context *rsc, OStream *stream) const;
     90     virtual RsA3DClassID getClassId() const;
     91 
     92     void execute(Context *rsc);
     93     void setInput(Context *rsc, ScriptKernelID *kid, Allocation *a);
     94     void setOutput(Context *rsc, ScriptKernelID *kid, Allocation *a);
     95 
     96 
     97 protected:
     98     virtual ~ScriptGroup();
     99     bool mInitialized;
    100 
    101 
    102 private:
    103     bool calcOrderRecurse(Node *n, int depth);
    104     bool calcOrder();
    105     Node * findNode(Script *s) const;
    106 
    107     ScriptGroup(Context *);
    108 };
    109 
    110 
    111 }
    112 }
    113 #endif
    114 
    115