1/*
2 * Copyright (C) 2009 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#include "rsContext.h"
18#include "rsScriptC.h"
19
20#include "utils/Timers.h"
21
22#include <time.h>
23
24namespace android {
25namespace renderscript {
26
27
28//////////////////////////////////////////////////////////////////////////////
29// Context
30//////////////////////////////////////////////////////////////////////////////
31
32void rsrAllocationSyncAll(Context *, Script *, Allocation *);
33
34void rsrAllocationCopy1DRange(Context *, Allocation *dstAlloc,
35                              uint32_t dstOff,
36                              uint32_t dstMip,
37                              uint32_t count,
38                              Allocation *srcAlloc,
39                              uint32_t srcOff, uint32_t srcMip);
40void rsrAllocationCopy2DRange(Context *, Allocation *dstAlloc,
41                              uint32_t dstXoff, uint32_t dstYoff,
42                              uint32_t dstMip, uint32_t dstFace,
43                              uint32_t width, uint32_t height,
44                              Allocation *srcAlloc,
45                              uint32_t srcXoff, uint32_t srcYoff,
46                              uint32_t srcMip, uint32_t srcFace);
47
48//////////////////////////////////////////////////////////////////////////////
49// Time routines
50//////////////////////////////////////////////////////////////////////////////
51
52float rsrGetDt(Context *, Script *);
53time_t rsrTime(Context *, Script *, time_t *timer);
54tm* rsrLocalTime(Context *, Script *, tm *local, time_t *timer);
55int64_t rsrUptimeMillis(Context *, Script *);
56int64_t rsrUptimeNanos(Context *, Script *);
57
58//////////////////////////////////////////////////////////////////////////////
59// Message routines
60//////////////////////////////////////////////////////////////////////////////
61
62uint32_t rsrToClient(Context *, Script *, int cmdID, void *data, int len);
63uint32_t rsrToClientBlocking(Context *, Script *, int cmdID, void *data, int len);
64
65//////////////////////////////////////////////////////////////////////////////
66//
67//////////////////////////////////////////////////////////////////////////////
68
69void rsrSetObject(const Context *, const Script *, ObjectBase **dst, ObjectBase * src);
70void rsrClearObject(const Context *, const Script *, ObjectBase **dst);
71bool rsrIsObject(const Context *, const Script *, const ObjectBase *src);
72
73void rsrAllocationIncRefs(const Context *, const Allocation *, void *ptr,
74                          size_t elementCount, size_t startOffset);
75void rsrAllocationDecRefs(const Context *, const Allocation *, void *ptr,
76                          size_t elementCount, size_t startOffset);
77
78
79uint32_t rsrToClient(Context *, Script *, int cmdID, void *data, int len);
80uint32_t rsrToClientBlocking(Context *, Script *, int cmdID, void *data, int len);
81
82void rsrAllocationMarkDirty(Context *, Script *, RsAllocation a);
83void rsrAllocationSyncAll(Context *, Script *, Allocation *a, RsAllocationUsageType source);
84
85
86void rsrForEach(Context *, Script *, Script *target,
87                Allocation *in,
88                Allocation *out,
89                const void *usr,
90                 uint32_t usrBytes,
91                const RsScriptCall *call);
92
93
94//////////////////////////////////////////////////////////////////////////////
95// Heavy math functions
96//////////////////////////////////////////////////////////////////////////////
97
98
99void rsrMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
100float rsrMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
101void rsrMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
102float rsrMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
103void rsrMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
104float rsrMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
105void rsrMatrixLoadIdentity_4x4(rs_matrix4x4 *m);
106void rsrMatrixLoadIdentity_3x3(rs_matrix3x3 *m);
107void rsrMatrixLoadIdentity_2x2(rs_matrix2x2 *m);
108void rsrMatrixLoad_4x4_f(rs_matrix4x4 *m, const float *v);
109void rsrMatrixLoad_3x3_f(rs_matrix3x3 *m, const float *v);
110void rsrMatrixLoad_2x2_f(rs_matrix2x2 *m, const float *v);
111void rsrMatrixLoad_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *v);
112void rsrMatrixLoad_4x4_3x3(rs_matrix4x4 *m, const rs_matrix3x3 *v);
113void rsrMatrixLoad_4x4_2x2(rs_matrix4x4 *m, const rs_matrix2x2 *v);
114void rsrMatrixLoad_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *v);
115void rsrMatrixLoad_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *v);
116void rsrMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
117void rsrMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
118void rsrMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
119void rsrMatrixLoadMultiply_4x4_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *lhs,
120                                       const rs_matrix4x4 *rhs);
121void rsrMatrixMultiply_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
122void rsrMatrixLoadMultiply_3x3_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *lhs,
123                                       const rs_matrix3x3 *rhs);
124void rsrMatrixMultiply_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
125void rsrMatrixLoadMultiply_2x2_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *lhs,
126                                       const rs_matrix2x2 *rhs);
127void rsrMatrixMultiply_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
128void rsrMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
129void rsrMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
130void rsrMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
131void rsrMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right,
132                        float bottom, float top, float near, float far);
133void rsrMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right,
134                          float bottom, float top, float near, float far);
135void rsrMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
136
137// Returns true if the matrix was successfully inversed
138bool rsrMatrixInverse_4x4(rs_matrix4x4 *m);
139// Returns true if the matrix was successfully inversed
140bool rsrMatrixInverseTranspose_4x4(rs_matrix4x4 *m);
141
142void rsrMatrixTranspose_4x4(rs_matrix4x4 *m);
143void rsrMatrixTranspose_3x3(rs_matrix3x3 *m);
144void rsrMatrixTranspose_2x2(rs_matrix2x2 *m);
145
146}
147}
148