• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008-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_SCRIPT_H__
18 #define __ANDROID_SCRIPT_H__
19 
20 #include <pthread.h>
21 #include <rs.h>
22 
23 #include "RenderScript.h"
24 #include "Allocation.h"
25 
26 namespace android {
27 namespace renderscriptCpp {
28 
29 
30 class Type;
31 class Element;
32 class Allocation;
33 
34 class Script : public BaseObj {
35 private:
36 
37 protected:
38     Script(void *id, RenderScript *rs);
39     void forEach(uint32_t slot, sp<const Allocation> in, sp<const Allocation> out,
40             const void *v, size_t) const;
41     void bindAllocation(sp<Allocation> va, uint32_t slot) const;
42     void setVar(uint32_t index, const void *, size_t len) const;
43     void setVar(uint32_t index, sp<const BaseObj> o) const;
44     void invoke(uint32_t slot, const void *v, size_t len) const;
45 
46 
invoke(uint32_t slot)47     void invoke(uint32_t slot) const {
48         invoke(slot, NULL, 0);
49     }
setVar(uint32_t index,float v)50     void setVar(uint32_t index, float v) const {
51         setVar(index, &v, sizeof(v));
52     }
setVar(uint32_t index,double v)53     void setVar(uint32_t index, double v) const {
54         setVar(index, &v, sizeof(v));
55     }
setVar(uint32_t index,int32_t v)56     void setVar(uint32_t index, int32_t v) const {
57         setVar(index, &v, sizeof(v));
58     }
setVar(uint32_t index,int64_t v)59     void setVar(uint32_t index, int64_t v) const {
60         setVar(index, &v, sizeof(v));
61     }
setVar(uint32_t index,bool v)62     void setVar(uint32_t index, bool v) const {
63         setVar(index, &v, sizeof(v));
64     }
65 
66 public:
67     class FieldBase {
68     protected:
69         sp<const Element> mElement;
70         sp<Allocation> mAllocation;
71 
72         void init(RenderScript *rs, uint32_t dimx, uint32_t usages = 0);
73 
74     public:
getElement()75         sp<const Element> getElement() {
76             return mElement;
77         }
78 
getType()79         sp<const Type> getType() {
80             return mAllocation->getType();
81         }
82 
getAllocation()83         sp<const Allocation> getAllocation() {
84             return mAllocation;
85         }
86 
87         //void updateAllocation();
88     };
89 };
90 
91 }
92 }
93 #endif
94