blob: 0700898f6b65a45e8854d4ed60349c90e2466baa [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);
Jason Samsd1c8c122012-03-14 15:36:02 -070033 void forEach(uint32_t slot, const Allocation *in, const Allocation *out, const void *v, size_t) const;
34 void bindAllocation(const Allocation *va, uint32_t slot) const;
35 void setVar(uint32_t index, const void *, size_t len) const;
36 void setVar(uint32_t index, const BaseObj *o) const;
37 void invoke(uint32_t slot, const void *v, size_t len) const;
Jason Sams170dc842012-02-23 17:14:39 -080038
39
Jason Samsd1c8c122012-03-14 15:36:02 -070040 void invoke(uint32_t slot) const {
Jason Sams170dc842012-02-23 17:14:39 -080041 invoke(slot, NULL, 0);
42 }
Jason Samsd1c8c122012-03-14 15:36:02 -070043 void setVar(uint32_t index, float v) const {
Jason Sams170dc842012-02-23 17:14:39 -080044 setVar(index, &v, sizeof(v));
45 }
Jason Samsd1c8c122012-03-14 15:36:02 -070046 void setVar(uint32_t index, double v) const {
Jason Sams170dc842012-02-23 17:14:39 -080047 setVar(index, &v, sizeof(v));
48 }
Jason Samsd1c8c122012-03-14 15:36:02 -070049 void setVar(uint32_t index, int32_t v) const {
Jason Sams170dc842012-02-23 17:14:39 -080050 setVar(index, &v, sizeof(v));
51 }
Jason Samsd1c8c122012-03-14 15:36:02 -070052 void setVar(uint32_t index, int64_t v) const {
Jason Sams170dc842012-02-23 17:14:39 -080053 setVar(index, &v, sizeof(v));
54 }
Jason Samsd1c8c122012-03-14 15:36:02 -070055 void setVar(uint32_t index, bool v) const {
Jason Sams170dc842012-02-23 17:14:39 -080056 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