blob: 235560a42db17e0b5b9d8ac9e302963df6b22bc6 [file] [log] [blame]
Jason Samsb2e3dc52012-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
Jason Sams69cccdf2012-04-02 19:11:49 -070026namespace android {
27namespace renderscriptCpp {
28
29
Jason Samsb2e3dc52012-02-23 17:14:39 -080030class Type;
31class Element;
32class Allocation;
33
34class Script : public BaseObj {
Jason Sams69cccdf2012-04-02 19:11:49 -070035private:
36
Jason Samsb2e3dc52012-02-23 17:14:39 -080037protected:
38 Script(void *id, RenderScript *rs);
Jason Sams69cccdf2012-04-02 19:11:49 -070039 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;
Jason Sams1fc02012012-03-14 15:36:02 -070042 void setVar(uint32_t index, const void *, size_t len) const;
Jason Sams69cccdf2012-04-02 19:11:49 -070043 void setVar(uint32_t index, sp<const BaseObj> o) const;
Jason Sams1fc02012012-03-14 15:36:02 -070044 void invoke(uint32_t slot, const void *v, size_t len) const;
Jason Samsb2e3dc52012-02-23 17:14:39 -080045
46
Jason Sams1fc02012012-03-14 15:36:02 -070047 void invoke(uint32_t slot) const {
Jason Samsb2e3dc52012-02-23 17:14:39 -080048 invoke(slot, NULL, 0);
49 }
Jason Sams1fc02012012-03-14 15:36:02 -070050 void setVar(uint32_t index, float v) const {
Jason Samsb2e3dc52012-02-23 17:14:39 -080051 setVar(index, &v, sizeof(v));
52 }
Jason Sams1fc02012012-03-14 15:36:02 -070053 void setVar(uint32_t index, double v) const {
Jason Samsb2e3dc52012-02-23 17:14:39 -080054 setVar(index, &v, sizeof(v));
55 }
Jason Sams1fc02012012-03-14 15:36:02 -070056 void setVar(uint32_t index, int32_t v) const {
Jason Samsb2e3dc52012-02-23 17:14:39 -080057 setVar(index, &v, sizeof(v));
58 }
Jason Sams1fc02012012-03-14 15:36:02 -070059 void setVar(uint32_t index, int64_t v) const {
Jason Samsb2e3dc52012-02-23 17:14:39 -080060 setVar(index, &v, sizeof(v));
61 }
Jason Sams1fc02012012-03-14 15:36:02 -070062 void setVar(uint32_t index, bool v) const {
Jason Samsb2e3dc52012-02-23 17:14:39 -080063 setVar(index, &v, sizeof(v));
64 }
65
66public:
67 class FieldBase {
68 protected:
Jason Sams69cccdf2012-04-02 19:11:49 -070069 sp<const Element> mElement;
70 sp<Allocation> mAllocation;
Jason Samsb2e3dc52012-02-23 17:14:39 -080071
72 void init(RenderScript *rs, uint32_t dimx, uint32_t usages = 0);
73
74 public:
Jason Sams69cccdf2012-04-02 19:11:49 -070075 sp<const Element> getElement() {
Jason Samsb2e3dc52012-02-23 17:14:39 -080076 return mElement;
77 }
78
Jason Sams69cccdf2012-04-02 19:11:49 -070079 sp<const Type> getType() {
Jason Samsb2e3dc52012-02-23 17:14:39 -080080 return mAllocation->getType();
81 }
82
Jason Sams69cccdf2012-04-02 19:11:49 -070083 sp<const Allocation> getAllocation() {
Jason Samsb2e3dc52012-02-23 17:14:39 -080084 return mAllocation;
85 }
86
87 //void updateAllocation();
88 };
89};
90
Jason Sams69cccdf2012-04-02 19:11:49 -070091}
92}
Jason Samsb2e3dc52012-02-23 17:14:39 -080093#endif