blob: 54d1e40cfd2f3fcfe97f848faab497674d687346 [file] [log] [blame]
Jason Sams170dc842012-02-23 17:14:39 -08001/*
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
26class Type;
27class Element;
28class Allocation;
29
30class Script : public BaseObj {
31protected:
32 Script(void *id, RenderScript *rs);
33 void forEach(uint32_t slot, const Allocation *in, const Allocation *out, const void *v, size_t);
34 void bindAllocation(const Allocation *va, uint32_t slot);
35 void setVar(uint32_t index, const void *, size_t len);
36 void setVar(uint32_t index, const BaseObj *o);
37 void invoke(uint32_t slot, const void *v, size_t len);
38
39
40 void invoke(uint32_t slot) {
41 invoke(slot, NULL, 0);
42 }
43 void setVar(uint32_t index, float v) {
44 setVar(index, &v, sizeof(v));
45 }
46 void setVar(uint32_t index, double v) {
47 setVar(index, &v, sizeof(v));
48 }
49 void setVar(uint32_t index, int32_t v) {
50 setVar(index, &v, sizeof(v));
51 }
52 void setVar(uint32_t index, int64_t v) {
53 setVar(index, &v, sizeof(v));
54 }
55 void setVar(uint32_t index, bool v) {
56 setVar(index, &v, sizeof(v));
57 }
58
59public:
60 class FieldBase {
61 protected:
62 const Element *mElement;
63 Allocation *mAllocation;
64
65 void init(RenderScript *rs, uint32_t dimx, uint32_t usages = 0);
66
67 public:
68 const Element *getElement() {
69 return mElement;
70 }
71
72 const Type *getType() {
73 return mAllocation->getType();
74 }
75
76 const Allocation *getAllocation() {
77 return mAllocation;
78 }
79
80 //void updateAllocation();
81 };
82};
83
84#endif