blob: 60341c208e03f932c98ca8d20a8cb461f3cf7cce [file] [log] [blame]
Tim Murray84bf2b82012-10-31 16:03:16 -07001/*
Tim Murray89daad62013-07-29 14:30:02 -07002 * Copyright (C) 2013 The Android Open Source Project
Tim Murray84bf2b82012-10-31 16:03:16 -07003 *
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_RSCPPSTRUCTS_H
18#define ANDROID_RSCPPSTRUCTS_H
19
Tim Murray89daad62013-07-29 14:30:02 -070020#include "rsDefines.h"
Tim Murray89daad62013-07-29 14:30:02 -070021#include "util/RefBase.h"
Tim Murraya4230962013-07-17 16:50:10 -070022#include "rsDispatch.h"
23
Tim Murray89daad62013-07-29 14:30:02 -070024#include <vector>
Tim Murrayab716362013-08-12 12:37:18 -070025#include <string>
Tim Murray89daad62013-07-29 14:30:02 -070026
Tim Murray96267c22013-02-12 11:25:12 -080027// Every row in an RS allocation is guaranteed to be aligned by this amount
28// Every row in a user-backed allocation must be aligned by this amount
29#define RS_CPU_ALLOCATION_ALIGNMENT 16
30
Tim Murray84bf2b82012-10-31 16:03:16 -070031namespace android {
Tim Murray9eb7f4b2012-11-16 14:02:18 -080032namespace RSC {
Tim Murray84bf2b82012-10-31 16:03:16 -070033
34typedef void (*ErrorHandlerFunc_t)(uint32_t errorNum, const char *errorText);
35typedef void (*MessageHandlerFunc_t)(uint32_t msgNum, const void *msgData, size_t msgLen);
36
37class RS;
38class BaseObj;
39class Element;
40class Type;
41class Allocation;
42class Script;
43class ScriptC;
Tim Murray729b6fe2013-07-23 16:20:42 -070044class Sampler;
Tim Murray84bf2b82012-10-31 16:03:16 -070045
Tim Murray21fa7a02013-08-15 16:25:03 -070046 enum RSError {
47 RS_SUCCESS = 0,
48 RS_ERROR_INVALID_PARAMETER = 1,
49 RS_ERROR_RUNTIME_ERROR = 2,
Tim Murray10913a52013-08-20 17:19:47 -070050 RS_ERROR_INVALID_ELEMENT = 3,
Tim Murray21fa7a02013-08-15 16:25:03 -070051 RS_ERROR_MAX = 9999
52
53 };
54
Tim Murrayeb4426d2013-08-27 15:30:16 -070055 enum RSYuvFormat {
56 RS_YUV_NONE = 0,
57 RS_YUV_YV12 = 1,
58 RS_YUV_NV21 = 2,
59 RS_YUV_MAX = 3
60 };
61
Tim Murray84e3dea2013-09-09 16:12:51 -070062 enum RSInitFlags {
63 RS_INIT_SYNCHRONOUS = 1,
64 RS_INIT_LOW_LATENCY = 2,
65 RS_INIT_MAX = 4
66 };
67
68
Tim Murray89daad62013-07-29 14:30:02 -070069 class RS : public android::RSC::LightRefBase<RS> {
Tim Murray84bf2b82012-10-31 16:03:16 -070070
71 public:
72 RS();
73 virtual ~RS();
74
Tim Murray4c4bec12013-09-09 17:21:36 -070075 bool init(uint32_t flags = 0);
Tim Murray84bf2b82012-10-31 16:03:16 -070076
77 void setErrorHandler(ErrorHandlerFunc_t func);
78 ErrorHandlerFunc_t getErrorHandler() { return mErrorFunc; }
79
80 void setMessageHandler(MessageHandlerFunc_t func);
81 MessageHandlerFunc_t getMessageHandler() { return mMessageFunc; }
82
Tim Murray21fa7a02013-08-15 16:25:03 -070083 void throwError(RSError error, const char *errMsg);
Tim Murray10913a52013-08-20 17:19:47 -070084 RSError getError();
Tim Murray84bf2b82012-10-31 16:03:16 -070085
86 RsContext getContext() { return mContext; }
87
Tim Murraybaca6c32012-11-14 16:51:46 -080088 void finish();
89
Tim Murraya4230962013-07-17 16:50:10 -070090 static dispatchTable* dispatch;
91
Tim Murray84bf2b82012-10-31 16:03:16 -070092 private:
Tim Murray4a92d122013-07-22 10:56:18 -070093 static bool usingNative;
Tim Murraya4230962013-07-17 16:50:10 -070094 static bool initDispatch(int targetApi);
95
Tim Murray84e3dea2013-09-09 16:12:51 -070096 bool init(int targetApi, uint32_t flags);
Tim Murray84bf2b82012-10-31 16:03:16 -070097 static void * threadProc(void *);
98
99 static bool gInitialized;
100 static pthread_mutex_t gInitMutex;
101
102 pthread_t mMessageThreadId;
103 pid_t mNativeMessageThreadId;
104 bool mMessageRun;
105
106 RsDevice mDev;
107 RsContext mContext;
Tim Murray21fa7a02013-08-15 16:25:03 -0700108 RSError mCurrentError;
Tim Murray84bf2b82012-10-31 16:03:16 -0700109
110 ErrorHandlerFunc_t mErrorFunc;
111 MessageHandlerFunc_t mMessageFunc;
Tim Murraya4230962013-07-17 16:50:10 -0700112 bool mInit;
Tim Murray84bf2b82012-10-31 16:03:16 -0700113
114 struct {
Tim Murray89daad62013-07-29 14:30:02 -0700115 sp<const Element> U8;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700116 sp<const Element> U8_2;
117 sp<const Element> U8_3;
118 sp<const Element> U8_4;
Tim Murray89daad62013-07-29 14:30:02 -0700119 sp<const Element> I8;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700120 sp<const Element> I8_2;
121 sp<const Element> I8_3;
122 sp<const Element> I8_4;
Tim Murray89daad62013-07-29 14:30:02 -0700123 sp<const Element> U16;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700124 sp<const Element> U16_2;
125 sp<const Element> U16_3;
126 sp<const Element> U16_4;
Tim Murray89daad62013-07-29 14:30:02 -0700127 sp<const Element> I16;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700128 sp<const Element> I16_2;
129 sp<const Element> I16_3;
130 sp<const Element> I16_4;
Tim Murray89daad62013-07-29 14:30:02 -0700131 sp<const Element> U32;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700132 sp<const Element> U32_2;
133 sp<const Element> U32_3;
134 sp<const Element> U32_4;
Tim Murray89daad62013-07-29 14:30:02 -0700135 sp<const Element> I32;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700136 sp<const Element> I32_2;
137 sp<const Element> I32_3;
138 sp<const Element> I32_4;
Tim Murray89daad62013-07-29 14:30:02 -0700139 sp<const Element> U64;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700140 sp<const Element> U64_2;
141 sp<const Element> U64_3;
142 sp<const Element> U64_4;
Tim Murray89daad62013-07-29 14:30:02 -0700143 sp<const Element> I64;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700144 sp<const Element> I64_2;
145 sp<const Element> I64_3;
146 sp<const Element> I64_4;
Tim Murray89daad62013-07-29 14:30:02 -0700147 sp<const Element> F32;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700148 sp<const Element> F32_2;
149 sp<const Element> F32_3;
150 sp<const Element> F32_4;
Tim Murray89daad62013-07-29 14:30:02 -0700151 sp<const Element> F64;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700152 sp<const Element> F64_2;
153 sp<const Element> F64_3;
154 sp<const Element> F64_4;
Tim Murray89daad62013-07-29 14:30:02 -0700155 sp<const Element> BOOLEAN;
Tim Murray84bf2b82012-10-31 16:03:16 -0700156
Tim Murray89daad62013-07-29 14:30:02 -0700157 sp<const Element> ELEMENT;
158 sp<const Element> TYPE;
159 sp<const Element> ALLOCATION;
160 sp<const Element> SAMPLER;
161 sp<const Element> SCRIPT;
162 sp<const Element> MESH;
163 sp<const Element> PROGRAM_FRAGMENT;
164 sp<const Element> PROGRAM_VERTEX;
165 sp<const Element> PROGRAM_RASTER;
166 sp<const Element> PROGRAM_STORE;
Tim Murray84bf2b82012-10-31 16:03:16 -0700167
Tim Murray89daad62013-07-29 14:30:02 -0700168 sp<const Element> A_8;
169 sp<const Element> RGB_565;
170 sp<const Element> RGB_888;
171 sp<const Element> RGBA_5551;
172 sp<const Element> RGBA_4444;
173 sp<const Element> RGBA_8888;
Tim Murray84bf2b82012-10-31 16:03:16 -0700174
Tim Murrayeb4426d2013-08-27 15:30:16 -0700175 sp<const Element> YUV;
Tim Murray84bf2b82012-10-31 16:03:16 -0700176
Tim Murray89daad62013-07-29 14:30:02 -0700177 sp<const Element> MATRIX_4X4;
178 sp<const Element> MATRIX_3X3;
179 sp<const Element> MATRIX_2X2;
Tim Murray84bf2b82012-10-31 16:03:16 -0700180 } mElements;
181
Tim Murray729b6fe2013-07-23 16:20:42 -0700182 struct {
Tim Murray89daad62013-07-29 14:30:02 -0700183 sp<const Sampler> CLAMP_NEAREST;
184 sp<const Sampler> CLAMP_LINEAR;
185 sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR;
186 sp<const Sampler> WRAP_NEAREST;
187 sp<const Sampler> WRAP_LINEAR;
188 sp<const Sampler> WRAP_LINEAR_MIP_LINEAR;
189 sp<const Sampler> MIRRORED_REPEAT_NEAREST;
190 sp<const Sampler> MIRRORED_REPEAT_LINEAR;
191 sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
Tim Murray729b6fe2013-07-23 16:20:42 -0700192 } mSamplers;
193 friend class Sampler;
194 friend class Element;
Tim Murray84bf2b82012-10-31 16:03:16 -0700195};
196
Tim Murray89daad62013-07-29 14:30:02 -0700197class BaseObj : public android::RSC::LightRefBase<BaseObj> {
198public:
199 void * getID() const;
200 virtual ~BaseObj();
201 virtual void updateFromNative();
202 virtual bool equals(sp<const BaseObj> obj);
203
Tim Murray84bf2b82012-10-31 16:03:16 -0700204protected:
205 void *mID;
206 sp<RS> mRS;
Tim Murrayab716362013-08-12 12:37:18 -0700207 std::string mName;
Tim Murray84bf2b82012-10-31 16:03:16 -0700208
209 BaseObj(void *id, sp<RS> rs);
210 void checkValid();
211
212 static void * getObjID(sp<const BaseObj> o);
213
Tim Murray84bf2b82012-10-31 16:03:16 -0700214};
215
216
217class Allocation : public BaseObj {
218protected:
Tim Murray89daad62013-07-29 14:30:02 -0700219 sp<const Type> mType;
Tim Murray84bf2b82012-10-31 16:03:16 -0700220 uint32_t mUsage;
Tim Murray89daad62013-07-29 14:30:02 -0700221 sp<Allocation> mAdaptedAllocation;
Tim Murray84bf2b82012-10-31 16:03:16 -0700222
223 bool mConstrainedLOD;
224 bool mConstrainedFace;
225 bool mConstrainedY;
226 bool mConstrainedZ;
227 bool mReadAllowed;
228 bool mWriteAllowed;
229 uint32_t mSelectedY;
230 uint32_t mSelectedZ;
231 uint32_t mSelectedLOD;
232 RsAllocationCubemapFace mSelectedFace;
233
234 uint32_t mCurrentDimX;
235 uint32_t mCurrentDimY;
236 uint32_t mCurrentDimZ;
237 uint32_t mCurrentCount;
238
239 void * getIDSafe() const;
240 void updateCacheInfo(sp<const Type> t);
241
242 Allocation(void *id, sp<RS> rs, sp<const Type> t, uint32_t usage);
243
244 void validateIsInt32();
245 void validateIsInt16();
246 void validateIsInt8();
247 void validateIsFloat32();
248 void validateIsObject();
249
250 virtual void updateFromNative();
251
252 void validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h);
Tim Murray9d24ae62013-08-30 12:17:14 -0700253 void validate3DRange(uint32_t xoff, uint32_t yoff, uint32_t zoff,
254 uint32_t w, uint32_t h, uint32_t d);
Tim Murray84bf2b82012-10-31 16:03:16 -0700255
256public:
Stephen Hinesa180b7d2013-08-21 12:42:13 -0700257 sp<const Type> getType() const {
Tim Murray84bf2b82012-10-31 16:03:16 -0700258 return mType;
259 }
260
261 void syncAll(RsAllocationUsageType srcLocation);
262 void ioSendOutput();
263 void ioGetInput();
264
265 void generateMipmaps();
Tim Murray509ea5c2012-11-13 11:56:40 -0800266
Tim Murray0b93e302012-11-15 14:56:54 -0800267 void copy1DRangeFrom(uint32_t off, size_t count, const void *data);
Tim Murraya4cbc2b2012-11-14 17:18:08 -0800268 void copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data, uint32_t dataOff);
Tim Murray84bf2b82012-10-31 16:03:16 -0700269
Tim Murray0b93e302012-11-15 14:56:54 -0800270 void copy1DRangeTo(uint32_t off, size_t count, void *data);
271
272 void copy1DFrom(const void* data);
273 void copy1DTo(void* data);
Tim Murraya4cbc2b2012-11-14 17:18:08 -0800274
Tim Murray84bf2b82012-10-31 16:03:16 -0700275 void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
Tim Murray0b93e302012-11-15 14:56:54 -0800276 const void *data);
Tim Murray7b3e3092012-11-16 13:32:24 -0800277
278 void copy2DRangeTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
279 void *data);
280
Tim Murray0b93e302012-11-15 14:56:54 -0800281 void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
282 sp<const Allocation> data, uint32_t dataXoff, uint32_t dataYoff);
Tim Murray84bf2b82012-10-31 16:03:16 -0700283
Tim Murray358747a2012-11-26 13:52:04 -0800284 void copy2DStridedFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
285 const void *data, size_t stride);
286 void copy2DStridedFrom(const void *data, size_t stride);
287
288 void copy2DStridedTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
289 void *data, size_t stride);
290 void copy2DStridedTo(void *data, size_t stride);
291
Tim Murray9d24ae62013-08-30 12:17:14 -0700292 void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t w,
293 uint32_t h, uint32_t d, const void* data);
294
295 void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff,
296 uint32_t w, uint32_t h, uint32_t d,
297 sp<const Allocation> data,
298 uint32_t dataXoff, uint32_t dataYoff, uint32_t dataZoff);
Tim Murray84bf2b82012-10-31 16:03:16 -0700299
300 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
301 RsAllocationMipmapControl mips, uint32_t usage);
302 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
303 RsAllocationMipmapControl mips, uint32_t usage, void * pointer);
304
305 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
306 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
307 static sp<Allocation> createSized(sp<RS> rs, sp<const Element> e, size_t count,
308 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
Tim Murray684726c2012-11-14 11:57:42 -0800309 static sp<Allocation> createSized2D(sp<RS> rs, sp<const Element> e,
310 size_t x, size_t y,
311 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
312
Tim Murray84bf2b82012-10-31 16:03:16 -0700313
314};
315
316class Element : public BaseObj {
317public:
318 bool isComplex();
319 size_t getSubElementCount() {
320 return mVisibleElementMap.size();
321 }
322
323 sp<const Element> getSubElement(uint32_t index);
324 const char * getSubElementName(uint32_t index);
325 size_t getSubElementArraySize(uint32_t index);
326 uint32_t getSubElementOffsetBytes(uint32_t index);
327 RsDataType getDataType() const {
328 return mType;
329 }
330
331 RsDataKind getDataKind() const {
332 return mKind;
333 }
334
335 size_t getSizeBytes() const {
336 return mSizeBytes;
337 }
338
Tim Murray10913a52013-08-20 17:19:47 -0700339 uint32_t getVectorSize() const {
340 return mVectorSize;
341 }
342
Tim Murray84bf2b82012-10-31 16:03:16 -0700343 static sp<const Element> BOOLEAN(sp<RS> rs);
344 static sp<const Element> U8(sp<RS> rs);
345 static sp<const Element> I8(sp<RS> rs);
346 static sp<const Element> U16(sp<RS> rs);
347 static sp<const Element> I16(sp<RS> rs);
348 static sp<const Element> U32(sp<RS> rs);
349 static sp<const Element> I32(sp<RS> rs);
350 static sp<const Element> U64(sp<RS> rs);
351 static sp<const Element> I64(sp<RS> rs);
352 static sp<const Element> F32(sp<RS> rs);
353 static sp<const Element> F64(sp<RS> rs);
354 static sp<const Element> ELEMENT(sp<RS> rs);
355 static sp<const Element> TYPE(sp<RS> rs);
356 static sp<const Element> ALLOCATION(sp<RS> rs);
357 static sp<const Element> SAMPLER(sp<RS> rs);
358 static sp<const Element> SCRIPT(sp<RS> rs);
359 static sp<const Element> MESH(sp<RS> rs);
360 static sp<const Element> PROGRAM_FRAGMENT(sp<RS> rs);
361 static sp<const Element> PROGRAM_VERTEX(sp<RS> rs);
362 static sp<const Element> PROGRAM_RASTER(sp<RS> rs);
363 static sp<const Element> PROGRAM_STORE(sp<RS> rs);
364
365 static sp<const Element> A_8(sp<RS> rs);
366 static sp<const Element> RGB_565(sp<RS> rs);
367 static sp<const Element> RGB_888(sp<RS> rs);
368 static sp<const Element> RGBA_5551(sp<RS> rs);
369 static sp<const Element> RGBA_4444(sp<RS> rs);
370 static sp<const Element> RGBA_8888(sp<RS> rs);
371
372 static sp<const Element> F32_2(sp<RS> rs);
373 static sp<const Element> F32_3(sp<RS> rs);
374 static sp<const Element> F32_4(sp<RS> rs);
375 static sp<const Element> F64_2(sp<RS> rs);
376 static sp<const Element> F64_3(sp<RS> rs);
377 static sp<const Element> F64_4(sp<RS> rs);
378 static sp<const Element> U8_2(sp<RS> rs);
379 static sp<const Element> U8_3(sp<RS> rs);
380 static sp<const Element> U8_4(sp<RS> rs);
381 static sp<const Element> I8_2(sp<RS> rs);
382 static sp<const Element> I8_3(sp<RS> rs);
383 static sp<const Element> I8_4(sp<RS> rs);
384 static sp<const Element> U16_2(sp<RS> rs);
385 static sp<const Element> U16_3(sp<RS> rs);
386 static sp<const Element> U16_4(sp<RS> rs);
387 static sp<const Element> I16_2(sp<RS> rs);
388 static sp<const Element> I16_3(sp<RS> rs);
389 static sp<const Element> I16_4(sp<RS> rs);
390 static sp<const Element> U32_2(sp<RS> rs);
391 static sp<const Element> U32_3(sp<RS> rs);
392 static sp<const Element> U32_4(sp<RS> rs);
393 static sp<const Element> I32_2(sp<RS> rs);
394 static sp<const Element> I32_3(sp<RS> rs);
395 static sp<const Element> I32_4(sp<RS> rs);
396 static sp<const Element> U64_2(sp<RS> rs);
397 static sp<const Element> U64_3(sp<RS> rs);
398 static sp<const Element> U64_4(sp<RS> rs);
399 static sp<const Element> I64_2(sp<RS> rs);
400 static sp<const Element> I64_3(sp<RS> rs);
401 static sp<const Element> I64_4(sp<RS> rs);
Tim Murrayeb4426d2013-08-27 15:30:16 -0700402 static sp<const Element> YUV(sp<RS> rs);
Tim Murray84bf2b82012-10-31 16:03:16 -0700403 static sp<const Element> MATRIX_4X4(sp<RS> rs);
404 static sp<const Element> MATRIX_3X3(sp<RS> rs);
405 static sp<const Element> MATRIX_2X2(sp<RS> rs);
406
Tim Murray84bf2b82012-10-31 16:03:16 -0700407 void updateFromNative();
408 static sp<const Element> createUser(sp<RS> rs, RsDataType dt);
409 static sp<const Element> createVector(sp<RS> rs, RsDataType dt, uint32_t size);
410 static sp<const Element> createPixel(sp<RS> rs, RsDataType dt, RsDataKind dk);
Tim Murray10913a52013-08-20 17:19:47 -0700411 bool isCompatible(sp<const Element>e) const;
Tim Murray84bf2b82012-10-31 16:03:16 -0700412
413 class Builder {
414 private:
415 sp<RS> mRS;
Tim Murray89daad62013-07-29 14:30:02 -0700416 std::vector<sp<Element> > mElements;
Tim Murrayab716362013-08-12 12:37:18 -0700417 std::vector<std::string> mElementNames;
Tim Murray89daad62013-07-29 14:30:02 -0700418 std::vector<uint32_t> mArraySizes;
Tim Murray84bf2b82012-10-31 16:03:16 -0700419 bool mSkipPadding;
420
421 public:
422 Builder(sp<RS> rs);
423 ~Builder();
Tim Murrayab716362013-08-12 12:37:18 -0700424 void add(sp<Element> e, std::string &name, uint32_t arraySize = 1);
Tim Murray84bf2b82012-10-31 16:03:16 -0700425 sp<const Element> create();
426 };
427
Stephen Hines7d1b7572013-08-22 01:24:06 -0700428protected:
429 Element(void *id, sp<RS> rs,
430 std::vector<sp<Element> > &elements,
431 std::vector<std::string> &elementNames,
432 std::vector<uint32_t> &arraySizes);
433 Element(void *id, sp<RS> rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size);
434 Element(sp<RS> rs);
435 virtual ~Element();
436
Tim Murray84bf2b82012-10-31 16:03:16 -0700437private:
438 void updateVisibleSubElements();
439
Tim Murray89daad62013-07-29 14:30:02 -0700440 std::vector<sp<Element> > mElements;
Tim Murrayab716362013-08-12 12:37:18 -0700441 std::vector<std::string> mElementNames;
Tim Murray89daad62013-07-29 14:30:02 -0700442 std::vector<uint32_t> mArraySizes;
443 std::vector<uint32_t> mVisibleElementMap;
444 std::vector<uint32_t> mOffsetInBytes;
Tim Murray84bf2b82012-10-31 16:03:16 -0700445
446 RsDataType mType;
447 RsDataKind mKind;
448 bool mNormalized;
449 size_t mSizeBytes;
450 size_t mVectorSize;
451};
452
Stephen Hines2c7206e2012-11-14 19:47:01 -0800453class FieldPacker {
454protected:
455 unsigned char* mData;
456 size_t mPos;
457 size_t mLen;
458
459public:
460 FieldPacker(size_t len)
Tim Murray89daad62013-07-29 14:30:02 -0700461 : mPos(0), mLen(len) {
462 mData = new unsigned char[len];
463 }
Stephen Hines2c7206e2012-11-14 19:47:01 -0800464
465 virtual ~FieldPacker() {
466 delete [] mData;
467 }
468
469 void align(size_t v) {
470 if ((v & (v - 1)) != 0) {
Tim Murrayab716362013-08-12 12:37:18 -0700471 // ALOGE("Non-power-of-two alignment: %zu", v);
Stephen Hines2c7206e2012-11-14 19:47:01 -0800472 return;
473 }
474
475 while ((mPos & (v - 1)) != 0) {
476 mData[mPos++] = 0;
477 }
478 }
479
480 void reset() {
481 mPos = 0;
482 }
483
484 void reset(size_t i) {
485 if (i >= mLen) {
Tim Murrayab716362013-08-12 12:37:18 -0700486 // ALOGE("Out of bounds: i (%zu) >= len (%zu)", i, mLen);
Stephen Hines2c7206e2012-11-14 19:47:01 -0800487 return;
488 }
489 mPos = i;
490 }
491
492 void skip(size_t i) {
493 size_t res = mPos + i;
494 if (res > mLen) {
Tim Murrayab716362013-08-12 12:37:18 -0700495 // ALOGE("Exceeded buffer length: i (%zu) > len (%zu)", i, mLen);
Stephen Hines2c7206e2012-11-14 19:47:01 -0800496 return;
497 }
498 mPos = res;
499 }
500
501 void* getData() const {
502 return mData;
503 }
504
505 size_t getLength() const {
506 return mLen;
507 }
508
509 template <typename T>
Tim Murray89daad62013-07-29 14:30:02 -0700510 void add(T t) {
Stephen Hines2c7206e2012-11-14 19:47:01 -0800511 align(sizeof(t));
512 if (mPos + sizeof(t) <= mLen) {
513 memcpy(&mData[mPos], &t, sizeof(t));
514 mPos += sizeof(t);
515 }
516 }
Stephen Hines43514cd2012-11-16 14:33:47 -0800517
518 /*
Tim Murray89daad62013-07-29 14:30:02 -0700519 void add(rs_matrix4x4 m) {
520 for (size_t i = 0; i < 16; i++) {
521 add(m.m[i]);
522 }
523 }
Stephen Hines43514cd2012-11-16 14:33:47 -0800524
Tim Murray89daad62013-07-29 14:30:02 -0700525 void add(rs_matrix3x3 m) {
526 for (size_t i = 0; i < 9; i++) {
527 add(m.m[i]);
528 }
529 }
Stephen Hines43514cd2012-11-16 14:33:47 -0800530
Tim Murray89daad62013-07-29 14:30:02 -0700531 void add(rs_matrix2x2 m) {
532 for (size_t i = 0; i < 4; i++) {
533 add(m.m[i]);
534 }
535 }
Stephen Hines43514cd2012-11-16 14:33:47 -0800536 */
537
Tim Murray89daad62013-07-29 14:30:02 -0700538 void add(sp<BaseObj> obj) {
Stephen Hines43514cd2012-11-16 14:33:47 -0800539 if (obj != NULL) {
540 add((uint32_t) (uintptr_t) obj->getID());
541 } else {
542 add((uint32_t) 0);
543 }
544 }
Stephen Hines2c7206e2012-11-14 19:47:01 -0800545};
546
Tim Murray89daad62013-07-29 14:30:02 -0700547
Tim Murray84bf2b82012-10-31 16:03:16 -0700548class Type : public BaseObj {
549protected:
550 friend class Allocation;
551
552 uint32_t mDimX;
553 uint32_t mDimY;
554 uint32_t mDimZ;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700555 RSYuvFormat mYuvFormat;
Tim Murray84bf2b82012-10-31 16:03:16 -0700556 bool mDimMipmaps;
557 bool mDimFaces;
558 size_t mElementCount;
559 sp<const Element> mElement;
560
Stephen Hines7d1b7572013-08-22 01:24:06 -0700561 Type(void *id, sp<RS> rs);
562
Tim Murray84bf2b82012-10-31 16:03:16 -0700563 void calcElementCount();
564 virtual void updateFromNative();
565
566public:
567
Tim Murrayeb4426d2013-08-27 15:30:16 -0700568 RSYuvFormat getYuvFormat() const {
569 return mYuvFormat;
570 }
571
Tim Murray84bf2b82012-10-31 16:03:16 -0700572 sp<const Element> getElement() const {
573 return mElement;
574 }
575
576 uint32_t getX() const {
577 return mDimX;
578 }
579
580 uint32_t getY() const {
581 return mDimY;
582 }
583
584 uint32_t getZ() const {
585 return mDimZ;
586 }
587
588 bool hasMipmaps() const {
589 return mDimMipmaps;
590 }
591
592 bool hasFaces() const {
593 return mDimFaces;
594 }
595
596 size_t getCount() const {
597 return mElementCount;
598 }
599
600 size_t getSizeBytes() const {
601 return mElementCount * mElement->getSizeBytes();
602 }
603
Tim Murray96267c22013-02-12 11:25:12 -0800604 static sp<const Type> create(sp<RS> rs, sp<const Element> e, uint32_t dimX, uint32_t dimY, uint32_t dimZ);
Tim Murray84bf2b82012-10-31 16:03:16 -0700605
606 class Builder {
607 protected:
608 sp<RS> mRS;
609 uint32_t mDimX;
610 uint32_t mDimY;
611 uint32_t mDimZ;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700612 RSYuvFormat mYuvFormat;
Tim Murray84bf2b82012-10-31 16:03:16 -0700613 bool mDimMipmaps;
614 bool mDimFaces;
615 sp<const Element> mElement;
616
617 public:
618 Builder(sp<RS> rs, sp<const Element> e);
619
620 void setX(uint32_t value);
Stephen Hines7d1b7572013-08-22 01:24:06 -0700621 void setY(uint32_t value);
Tim Murrayeb4426d2013-08-27 15:30:16 -0700622 void setZ(uint32_t value);
623 void setYuvFormat(RSYuvFormat format);
Tim Murray84bf2b82012-10-31 16:03:16 -0700624 void setMipmaps(bool value);
625 void setFaces(bool value);
626 sp<const Type> create();
627 };
628
629};
630
631class Script : public BaseObj {
632private:
633
634protected:
635 Script(void *id, sp<RS> rs);
636 void forEach(uint32_t slot, sp<const Allocation> in, sp<const Allocation> out,
637 const void *v, size_t) const;
638 void bindAllocation(sp<Allocation> va, uint32_t slot) const;
639 void setVar(uint32_t index, const void *, size_t len) const;
640 void setVar(uint32_t index, sp<const BaseObj> o) const;
641 void invoke(uint32_t slot, const void *v, size_t len) const;
642
643
644 void invoke(uint32_t slot) const {
645 invoke(slot, NULL, 0);
646 }
647 void setVar(uint32_t index, float v) const {
648 setVar(index, &v, sizeof(v));
649 }
650 void setVar(uint32_t index, double v) const {
651 setVar(index, &v, sizeof(v));
652 }
653 void setVar(uint32_t index, int32_t v) const {
654 setVar(index, &v, sizeof(v));
655 }
656 void setVar(uint32_t index, int64_t v) const {
657 setVar(index, &v, sizeof(v));
658 }
659 void setVar(uint32_t index, bool v) const {
660 setVar(index, &v, sizeof(v));
661 }
662
663public:
664 class FieldBase {
665 protected:
666 sp<const Element> mElement;
667 sp<Allocation> mAllocation;
668
669 void init(sp<RS> rs, uint32_t dimx, uint32_t usages = 0);
670
671 public:
672 sp<const Element> getElement() {
673 return mElement;
674 }
675
676 sp<const Type> getType() {
677 return mAllocation->getType();
678 }
679
680 sp<const Allocation> getAllocation() {
681 return mAllocation;
682 }
683
684 //void updateAllocation();
685 };
686};
687
688class ScriptC : public Script {
689protected:
690 ScriptC(sp<RS> rs,
691 const void *codeTxt, size_t codeLength,
692 const char *cachedName, size_t cachedNameLength,
693 const char *cacheDir, size_t cacheDirLength);
694
695};
696
Tim Murray7f0d5682012-11-08 16:35:24 -0800697class ScriptIntrinsic : public Script {
698 protected:
Tim Murray10913a52013-08-20 17:19:47 -0700699 sp<const Element> mElement;
Tim Murray3cd44af2012-11-14 11:25:27 -0800700 ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e);
Tim Murrayb27b1812013-08-05 14:00:40 -0700701 virtual ~ScriptIntrinsic();
Tim Murray7f0d5682012-11-08 16:35:24 -0800702};
703
Tim Murray89daad62013-07-29 14:30:02 -0700704class ScriptIntrinsic3DLUT : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700705 private:
Tim Murray89daad62013-07-29 14:30:02 -0700706 ScriptIntrinsic3DLUT(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700707 public:
708 static sp<ScriptIntrinsic3DLUT> create(sp<RS> rs, sp<const Element> e);
Tim Murray89daad62013-07-29 14:30:02 -0700709 void forEach(sp<Allocation> ain, sp<Allocation> aout);
710 void setLUT(sp<Allocation> lut);
711};
712
Tim Murray7f0d5682012-11-08 16:35:24 -0800713class ScriptIntrinsicBlend : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700714 private:
Tim Murray89daad62013-07-29 14:30:02 -0700715 ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700716 public:
717 static sp<ScriptIntrinsicBlend> create(sp<RS> rs, sp<const Element> e);
Tim Murray7f0d5682012-11-08 16:35:24 -0800718 void blendClear(sp<Allocation> in, sp<Allocation> out);
719 void blendSrc(sp<Allocation> in, sp<Allocation> out);
720 void blendDst(sp<Allocation> in, sp<Allocation> out);
721 void blendSrcOver(sp<Allocation> in, sp<Allocation> out);
722 void blendDstOver(sp<Allocation> in, sp<Allocation> out);
723 void blendSrcIn(sp<Allocation> in, sp<Allocation> out);
724 void blendDstIn(sp<Allocation> in, sp<Allocation> out);
725 void blendSrcOut(sp<Allocation> in, sp<Allocation> out);
726 void blendDstOut(sp<Allocation> in, sp<Allocation> out);
727 void blendSrcAtop(sp<Allocation> in, sp<Allocation> out);
728 void blendDstAtop(sp<Allocation> in, sp<Allocation> out);
729 void blendXor(sp<Allocation> in, sp<Allocation> out);
730 void blendMultiply(sp<Allocation> in, sp<Allocation> out);
731 void blendAdd(sp<Allocation> in, sp<Allocation> out);
732 void blendSubtract(sp<Allocation> in, sp<Allocation> out);
733};
Tim Murray84bf2b82012-10-31 16:03:16 -0700734
Tim Murray8f1e60c2012-11-13 12:25:11 -0800735class ScriptIntrinsicBlur : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700736 private:
Tim Murray89daad62013-07-29 14:30:02 -0700737 ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700738 public:
739 static sp<ScriptIntrinsicBlur> create(sp<RS> rs, sp<const Element> e);
740 void setInput(sp<Allocation> in);
741 void forEach(sp<Allocation> out);
Tim Murray8f1e60c2012-11-13 12:25:11 -0800742 void setRadius(float radius);
743};
744
Tim Murray89daad62013-07-29 14:30:02 -0700745class ScriptIntrinsicColorMatrix : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700746 private:
Tim Murray89daad62013-07-29 14:30:02 -0700747 ScriptIntrinsicColorMatrix(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700748 public:
Tim Murrayaae73c92013-09-03 17:05:46 -0700749 static sp<ScriptIntrinsicColorMatrix> create(sp<RS> rs);
Tim Murray89daad62013-07-29 14:30:02 -0700750 void forEach(sp<Allocation> in, sp<Allocation> out);
Tim Murray10913a52013-08-20 17:19:47 -0700751 void setAdd(float* add);
Tim Murray89daad62013-07-29 14:30:02 -0700752 void setColorMatrix3(float* m);
753 void setColorMatrix4(float* m);
754 void setGreyscale();
755 void setRGBtoYUV();
756 void setYUVtoRGB();
757};
758
759class ScriptIntrinsicConvolve3x3 : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700760 private:
Tim Murray89daad62013-07-29 14:30:02 -0700761 ScriptIntrinsicConvolve3x3(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700762 public:
763 static sp<ScriptIntrinsicConvolve3x3> create(sp<RS> rs, sp<const Element> e);
Tim Murray89daad62013-07-29 14:30:02 -0700764 void setInput(sp<Allocation> in);
765 void forEach(sp<Allocation> out);
766 void setCoefficients(float* v);
767};
768
769class ScriptIntrinsicConvolve5x5 : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700770 private:
Tim Murray89daad62013-07-29 14:30:02 -0700771 ScriptIntrinsicConvolve5x5(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700772 public:
773 static sp<ScriptIntrinsicConvolve5x5> create(sp<RS> rs, sp<const Element> e);
Tim Murray89daad62013-07-29 14:30:02 -0700774 void setInput(sp<Allocation> in);
775 void forEach(sp<Allocation> out);
776 void setCoefficients(float* v);
777};
778
Tim Murrayb27b1812013-08-05 14:00:40 -0700779class ScriptIntrinsicHistogram : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700780 private:
Tim Murrayb27b1812013-08-05 14:00:40 -0700781 ScriptIntrinsicHistogram(sp<RS> rs, sp<const Element> e);
Tim Murray10913a52013-08-20 17:19:47 -0700782 sp<Allocation> mOut;
Tim Murray21fa7a02013-08-15 16:25:03 -0700783 public:
Tim Murray10913a52013-08-20 17:19:47 -0700784 static sp<ScriptIntrinsicHistogram> create(sp<RS> rs);
Tim Murrayb27b1812013-08-05 14:00:40 -0700785 void setOutput(sp<Allocation> aout);
786 void setDotCoefficients(float r, float g, float b, float a);
787 void forEach(sp<Allocation> ain);
788 void forEach_dot(sp<Allocation> ain);
789};
790
791class ScriptIntrinsicLUT : public ScriptIntrinsic {
792 private:
793 sp<Allocation> LUT;
794 bool mDirty;
795 unsigned char mCache[1024];
Tim Murray2acce992013-08-28 14:23:31 -0700796 void setTable(unsigned int offset, unsigned char base, unsigned int length, unsigned char* lutValues);
Tim Murray21fa7a02013-08-15 16:25:03 -0700797 ScriptIntrinsicLUT(sp<RS> rs, sp<const Element> e);
Tim Murrayb27b1812013-08-05 14:00:40 -0700798
Tim Murray89daad62013-07-29 14:30:02 -0700799 public:
Tim Murray21fa7a02013-08-15 16:25:03 -0700800 static sp<ScriptIntrinsicLUT> create(sp<RS> rs, sp<const Element> e);
Tim Murray89daad62013-07-29 14:30:02 -0700801 void forEach(sp<Allocation> ain, sp<Allocation> aout);
Tim Murray2acce992013-08-28 14:23:31 -0700802 void setRed(unsigned char base, unsigned int length, unsigned char* lutValues);
803 void setGreen(unsigned char base, unsigned int length, unsigned char* lutValues);
804 void setBlue(unsigned char base, unsigned int length, unsigned char* lutValues);
805 void setAlpha(unsigned char base, unsigned int length, unsigned char* lutValues);
Tim Murrayb27b1812013-08-05 14:00:40 -0700806 virtual ~ScriptIntrinsicLUT();
807};
808
Tim Murray89daad62013-07-29 14:30:02 -0700809class ScriptIntrinsicYuvToRGB : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700810 private:
Tim Murrayb27b1812013-08-05 14:00:40 -0700811 ScriptIntrinsicYuvToRGB(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700812 public:
813 static sp<ScriptIntrinsicYuvToRGB> create(sp<RS> rs, sp<const Element> e);
Tim Murrayb27b1812013-08-05 14:00:40 -0700814 void setInput(sp<Allocation> in);
815 void forEach(sp<Allocation> out);
Tim Murray89daad62013-07-29 14:30:02 -0700816
817};
Tim Murrayb27b1812013-08-05 14:00:40 -0700818
Tim Murray89daad62013-07-29 14:30:02 -0700819
Tim Murray729b6fe2013-07-23 16:20:42 -0700820 class Sampler : public BaseObj {
821 private:
822 Sampler(sp<RS> rs, void* id);
823 RsSamplerValue mMin;
824 RsSamplerValue mMag;
825 RsSamplerValue mWrapS;
826 RsSamplerValue mWrapT;
827 RsSamplerValue mWrapR;
828 float mAniso;
829
830 public:
831 static sp<Sampler> create(sp<RS> rs, RsSamplerValue min, RsSamplerValue mag, RsSamplerValue wrapS, RsSamplerValue wrapT, float anisotropy);
832
833 RsSamplerValue getMinification();
834 RsSamplerValue getMagnification();
835 RsSamplerValue getWrapS();
836 RsSamplerValue getWrapT();
837 float getAnisotropy();
838
839 sp<const Sampler> CLAMP_NEAREST(sp<RS> rs);
840 sp<const Sampler> CLAMP_LINEAR(sp<RS> rs);
841 sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR(sp<RS> rs);
842 sp<const Sampler> WRAP_NEAREST(sp<RS> rs);
843 sp<const Sampler> WRAP_LINEAR(sp<RS> rs);
844 sp<const Sampler> WRAP_LINEAR_MIP_LINEAR(sp<RS> rs);
845 sp<const Sampler> MIRRORED_REPEAT_NEAREST(sp<RS> rs);
846 sp<const Sampler> MIRRORED_REPEAT_LINEAR(sp<RS> rs);
847 sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR(sp<RS> rs);
848
849};
850
Stephen Hinesd10412f2013-08-29 18:27:21 -0700851class Byte2 {
852 public:
853 int8_t x, y;
854
855 Byte2(int8_t initX, int8_t initY)
856 : x(initX), y(initY) {}
857 Byte2() : x(0), y(0) {}
858};
859
860class Byte3 {
861 public:
862 int8_t x, y, z;
863
864 Byte3(int8_t initX, int8_t initY, int8_t initZ)
865 : x(initX), y(initY), z(initZ) {}
866 Byte3() : x(0), y(0), z(0) {}
867};
868
869class Byte4 {
870 public:
871 int8_t x, y, z, w;
872
873 Byte4(int8_t initX, int8_t initY, int8_t initZ, int8_t initW)
874 : x(initX), y(initY), z(initZ), w(initW) {}
875 Byte4() : x(0), y(0), z(0), w(0) {}
876};
877
878class UByte2 {
879 public:
880 uint8_t x, y;
881
882 UByte2(uint8_t initX, uint8_t initY)
883 : x(initX), y(initY) {}
884 UByte2() : x(0), y(0) {}
885};
886
887class UByte3 {
888 public:
889 uint8_t x, y, z;
890
891 UByte3(uint8_t initX, uint8_t initY, uint8_t initZ)
892 : x(initX), y(initY), z(initZ) {}
893 UByte3() : x(0), y(0), z(0) {}
894};
895
896class UByte4 {
897 public:
898 uint8_t x, y, z, w;
899
900 UByte4(uint8_t initX, uint8_t initY, uint8_t initZ, uint8_t initW)
901 : x(initX), y(initY), z(initZ), w(initW) {}
902 UByte4() : x(0), y(0), z(0), w(0) {}
903};
904
905class Short2 {
906 public:
907 short x, y;
908
909 Short2(short initX, short initY)
910 : x(initX), y(initY) {}
911 Short2() : x(0), y(0) {}
912};
913
914class Short3 {
915 public:
916 short x, y, z;
917
918 Short3(short initX, short initY, short initZ)
919 : x(initX), y(initY), z(initZ) {}
920 Short3() : x(0), y(0), z(0) {}
921};
922
923class Short4 {
924 public:
925 short x, y, z, w;
926
927 Short4(short initX, short initY, short initZ, short initW)
928 : x(initX), y(initY), z(initZ), w(initW) {}
929 Short4() : x(0), y(0), z(0), w(0) {}
930};
931
932class UShort2 {
933 public:
934 uint16_t x, y;
935
936 UShort2(uint16_t initX, uint16_t initY)
937 : x(initX), y(initY) {}
938 UShort2() : x(0), y(0) {}
939};
940
941class UShort3 {
942 public:
943 uint16_t x, y, z;
944
945 UShort3(uint16_t initX, uint16_t initY, uint16_t initZ)
946 : x(initX), y(initY), z(initZ) {}
947 UShort3() : x(0), y(0), z(0) {}
948};
949
950class UShort4 {
951 public:
952 uint16_t x, y, z, w;
953
954 UShort4(uint16_t initX, uint16_t initY, uint16_t initZ, uint16_t initW)
955 : x(initX), y(initY), z(initZ), w(initW) {}
956 UShort4() : x(0), y(0), z(0), w(0) {}
957};
958
959class Int2 {
960 public:
961 int x, y;
962
963 Int2(int initX, int initY)
964 : x(initX), y(initY) {}
965 Int2() : x(0), y(0) {}
966};
967
968class Int3 {
969 public:
970 int x, y, z;
971
972 Int3(int initX, int initY, int initZ)
973 : x(initX), y(initY), z(initZ) {}
974 Int3() : x(0), y(0), z(0) {}
975};
976
977class Int4 {
978 public:
979 int x, y, z, w;
980
981 Int4(int initX, int initY, int initZ, int initW)
982 : x(initX), y(initY), z(initZ), w(initW) {}
983 Int4() : x(0), y(0), z(0), w(0) {}
984};
985
986class UInt2 {
987 public:
988 uint32_t x, y;
989
990 UInt2(uint32_t initX, uint32_t initY)
991 : x(initX), y(initY) {}
992 UInt2() : x(0), y(0) {}
993};
994
995class UInt3 {
996 public:
997 uint32_t x, y, z;
998
999 UInt3(uint32_t initX, uint32_t initY, uint32_t initZ)
1000 : x(initX), y(initY), z(initZ) {}
1001 UInt3() : x(0), y(0), z(0) {}
1002};
1003
1004class UInt4 {
1005 public:
1006 uint32_t x, y, z, w;
1007
1008 UInt4(uint32_t initX, uint32_t initY, uint32_t initZ, uint32_t initW)
1009 : x(initX), y(initY), z(initZ), w(initW) {}
1010 UInt4() : x(0), y(0), z(0), w(0) {}
1011};
1012
1013class Long2 {
1014 public:
1015 int64_t x, y;
1016
1017 Long2(int64_t initX, int64_t initY)
1018 : x(initX), y(initY) {}
1019 Long2() : x(0), y(0) {}
1020};
1021
1022class Long3 {
1023 public:
1024 int64_t x, y, z;
1025
1026 Long3(int64_t initX, int64_t initY, int64_t initZ)
1027 : x(initX), y(initY), z(initZ) {}
1028 Long3() : x(0), y(0), z(0) {}
1029};
1030
1031class Long4 {
1032 public:
1033 int64_t x, y, z, w;
1034
1035 Long4(int64_t initX, int64_t initY, int64_t initZ, int64_t initW)
1036 : x(initX), y(initY), z(initZ), w(initW) {}
1037 Long4() : x(0), y(0), z(0), w(0) {}
1038};
1039
1040class ULong2 {
1041 public:
1042 uint64_t x, y;
1043
1044 ULong2(uint64_t initX, uint64_t initY)
1045 : x(initX), y(initY) {}
1046 ULong2() : x(0), y(0) {}
1047};
1048
1049class ULong3 {
1050 public:
1051 uint64_t x, y, z;
1052
1053 ULong3(uint64_t initX, uint64_t initY, uint64_t initZ)
1054 : x(initX), y(initY), z(initZ) {}
1055 ULong3() : x(0), y(0), z(0) {}
1056};
1057
1058class ULong4 {
1059 public:
1060 uint64_t x, y, z, w;
1061
1062 ULong4(uint64_t initX, uint64_t initY, uint64_t initZ, uint64_t initW)
1063 : x(initX), y(initY), z(initZ), w(initW) {}
1064 ULong4() : x(0), y(0), z(0), w(0) {}
1065};
1066
1067class Float2 {
1068 public:
1069 float x, y;
1070
1071 Float2(float initX, float initY)
1072 : x(initX), y(initY) {}
1073 Float2() : x(0), y(0) {}
1074};
1075
1076class Float3 {
1077 public:
1078 float x, y, z;
1079
1080 Float3(float initX, float initY, float initZ)
1081 : x(initX), y(initY), z(initZ) {}
1082 Float3() : x(0.f), y(0.f), z(0.f) {}
1083};
1084
1085class Float4 {
1086 public:
1087 float x, y, z, w;
1088
1089 Float4(float initX, float initY, float initZ, float initW)
1090 : x(initX), y(initY), z(initZ), w(initW) {}
1091 Float4() : x(0.f), y(0.f), z(0.f), w(0.f) {}
1092};
1093
1094class Double2 {
1095 public:
1096 double x, y;
1097
1098 Double2(double initX, double initY)
1099 : x(initX), y(initY) {}
1100 Double2() : x(0), y(0) {}
1101};
1102
1103class Double3 {
1104 public:
1105 double x, y, z;
1106
1107 Double3(double initX, double initY, double initZ)
1108 : x(initX), y(initY), z(initZ) {}
1109 Double3() : x(0), y(0), z(0) {}
1110};
1111
1112class Double4 {
1113 public:
1114 double x, y, z, w;
1115
1116 Double4(double initX, double initY, double initZ, double initW)
1117 : x(initX), y(initY), z(initZ), w(initW) {}
1118 Double4() : x(0), y(0), z(0), w(0) {}
1119};
1120
Tim Murray84bf2b82012-10-31 16:03:16 -07001121}
Tim Murray7f0d5682012-11-08 16:35:24 -08001122
Tim Murray84bf2b82012-10-31 16:03:16 -07001123}
1124
1125#endif