• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright (C) 2009-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_H
18  #define ANDROID_RS_SCRIPT_H
19  
20  #include "rsAllocation.h"
21  
22  
23  // ---------------------------------------------------------------------------
24  namespace android {
25  namespace renderscript {
26  
27  class ProgramVertex;
28  class ProgramFragment;
29  class ProgramRaster;
30  class ProgramStore;
31  
32  class Script : public ObjectBase {
33  public:
34      struct Hal {
35          void * drv;
36  
37          struct DriverInfo {
38              int mVersionMajor;
39              int mVersionMinor;
40  
41              size_t exportedVariableCount;
42              size_t exportedFunctionCount;
43              size_t exportedPragmaCount;
44              char const **exportedPragmaKeyList;
45              char const **exportedPragmaValueList;
46  
47              int (* root)();
48              bool isThreadable;
49          };
50          DriverInfo info;
51      };
52      Hal mHal;
53  
54      typedef void (* InvokeFunc_t)(void);
55  
56      Script(Context *);
57      virtual ~Script();
58  
59      struct Enviroment_t {
60          int64_t mStartTimeMillis;
61          int64_t mLastDtTime;
62  
63          ObjectBaseRef<ProgramVertex> mVertex;
64          ObjectBaseRef<ProgramFragment> mFragment;
65          ObjectBaseRef<ProgramRaster> mRaster;
66          ObjectBaseRef<ProgramStore> mFragmentStore;
67      };
68      Enviroment_t mEnviroment;
69  
70      void setSlot(uint32_t slot, Allocation *a);
71      void setVar(uint32_t slot, const void *val, size_t len);
72      void setVar(uint32_t slot, const void *val, size_t len, Element *e,
73                  const size_t *dims, size_t dimLen);
74      void setVarObj(uint32_t slot, ObjectBase *val);
75  
76      virtual bool freeChildren();
77  
78      virtual void runForEach(Context *rsc,
79                              uint32_t slot,
80                              const Allocation * ain,
81                              Allocation * aout,
82                              const void * usr,
83                              size_t usrBytes,
84                              const RsScriptCall *sc = NULL) = 0;
85  
86      virtual void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) = 0;
87      virtual void setupScript(Context *rsc) = 0;
88      virtual uint32_t run(Context *) = 0;
89  protected:
90      bool mInitialized;
91      ObjectBaseRef<Allocation> *mSlots;
92      ObjectBaseRef<const Type> *mTypes;
93  
94  };
95  
96  
97  }
98  }
99  #endif
100  
101