blob: 9ec80767fbc83c18469b34afa6c78a89771cbdf7 [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 Murray89daad62013-07-29 14:30:02 -070062 class RS : public android::RSC::LightRefBase<RS> {
Tim Murray84bf2b82012-10-31 16:03:16 -070063
64 public:
65 RS();
66 virtual ~RS();
67
Tim Murray4d252d62012-11-29 14:37:59 -080068 bool init(bool forceCpu = false, bool synchronous = false);
Tim Murray84bf2b82012-10-31 16:03:16 -070069
70 void setErrorHandler(ErrorHandlerFunc_t func);
71 ErrorHandlerFunc_t getErrorHandler() { return mErrorFunc; }
72
73 void setMessageHandler(MessageHandlerFunc_t func);
74 MessageHandlerFunc_t getMessageHandler() { return mMessageFunc; }
75
Tim Murray21fa7a02013-08-15 16:25:03 -070076 void throwError(RSError error, const char *errMsg);
Tim Murray10913a52013-08-20 17:19:47 -070077 RSError getError();
Tim Murray84bf2b82012-10-31 16:03:16 -070078
79 RsContext getContext() { return mContext; }
80
Tim Murraybaca6c32012-11-14 16:51:46 -080081 void finish();
82
Tim Murraya4230962013-07-17 16:50:10 -070083 static dispatchTable* dispatch;
84
Tim Murray84bf2b82012-10-31 16:03:16 -070085 private:
Tim Murray4a92d122013-07-22 10:56:18 -070086 static bool usingNative;
Tim Murraya4230962013-07-17 16:50:10 -070087 static bool initDispatch(int targetApi);
88
Tim Murray4d252d62012-11-29 14:37:59 -080089 bool init(int targetApi, bool forceCpu, bool synchronous);
Tim Murray84bf2b82012-10-31 16:03:16 -070090 static void * threadProc(void *);
91
92 static bool gInitialized;
93 static pthread_mutex_t gInitMutex;
94
95 pthread_t mMessageThreadId;
96 pid_t mNativeMessageThreadId;
97 bool mMessageRun;
98
99 RsDevice mDev;
100 RsContext mContext;
Tim Murray21fa7a02013-08-15 16:25:03 -0700101 RSError mCurrentError;
Tim Murray84bf2b82012-10-31 16:03:16 -0700102
103 ErrorHandlerFunc_t mErrorFunc;
104 MessageHandlerFunc_t mMessageFunc;
Tim Murraya4230962013-07-17 16:50:10 -0700105 bool mInit;
Tim Murray84bf2b82012-10-31 16:03:16 -0700106
107 struct {
Tim Murray89daad62013-07-29 14:30:02 -0700108 sp<const Element> U8;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700109 sp<const Element> U8_2;
110 sp<const Element> U8_3;
111 sp<const Element> U8_4;
Tim Murray89daad62013-07-29 14:30:02 -0700112 sp<const Element> I8;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700113 sp<const Element> I8_2;
114 sp<const Element> I8_3;
115 sp<const Element> I8_4;
Tim Murray89daad62013-07-29 14:30:02 -0700116 sp<const Element> U16;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700117 sp<const Element> U16_2;
118 sp<const Element> U16_3;
119 sp<const Element> U16_4;
Tim Murray89daad62013-07-29 14:30:02 -0700120 sp<const Element> I16;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700121 sp<const Element> I16_2;
122 sp<const Element> I16_3;
123 sp<const Element> I16_4;
Tim Murray89daad62013-07-29 14:30:02 -0700124 sp<const Element> U32;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700125 sp<const Element> U32_2;
126 sp<const Element> U32_3;
127 sp<const Element> U32_4;
Tim Murray89daad62013-07-29 14:30:02 -0700128 sp<const Element> I32;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700129 sp<const Element> I32_2;
130 sp<const Element> I32_3;
131 sp<const Element> I32_4;
Tim Murray89daad62013-07-29 14:30:02 -0700132 sp<const Element> U64;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700133 sp<const Element> U64_2;
134 sp<const Element> U64_3;
135 sp<const Element> U64_4;
Tim Murray89daad62013-07-29 14:30:02 -0700136 sp<const Element> I64;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700137 sp<const Element> I64_2;
138 sp<const Element> I64_3;
139 sp<const Element> I64_4;
Tim Murray89daad62013-07-29 14:30:02 -0700140 sp<const Element> F32;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700141 sp<const Element> F32_2;
142 sp<const Element> F32_3;
143 sp<const Element> F32_4;
Tim Murray89daad62013-07-29 14:30:02 -0700144 sp<const Element> F64;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700145 sp<const Element> F64_2;
146 sp<const Element> F64_3;
147 sp<const Element> F64_4;
Tim Murray89daad62013-07-29 14:30:02 -0700148 sp<const Element> BOOLEAN;
Tim Murray84bf2b82012-10-31 16:03:16 -0700149
Tim Murray89daad62013-07-29 14:30:02 -0700150 sp<const Element> ELEMENT;
151 sp<const Element> TYPE;
152 sp<const Element> ALLOCATION;
153 sp<const Element> SAMPLER;
154 sp<const Element> SCRIPT;
155 sp<const Element> MESH;
156 sp<const Element> PROGRAM_FRAGMENT;
157 sp<const Element> PROGRAM_VERTEX;
158 sp<const Element> PROGRAM_RASTER;
159 sp<const Element> PROGRAM_STORE;
Tim Murray84bf2b82012-10-31 16:03:16 -0700160
Tim Murray89daad62013-07-29 14:30:02 -0700161 sp<const Element> A_8;
162 sp<const Element> RGB_565;
163 sp<const Element> RGB_888;
164 sp<const Element> RGBA_5551;
165 sp<const Element> RGBA_4444;
166 sp<const Element> RGBA_8888;
Tim Murray84bf2b82012-10-31 16:03:16 -0700167
Tim Murrayeb4426d2013-08-27 15:30:16 -0700168 sp<const Element> YUV;
Tim Murray84bf2b82012-10-31 16:03:16 -0700169
Tim Murray89daad62013-07-29 14:30:02 -0700170 sp<const Element> MATRIX_4X4;
171 sp<const Element> MATRIX_3X3;
172 sp<const Element> MATRIX_2X2;
Tim Murray84bf2b82012-10-31 16:03:16 -0700173 } mElements;
174
Tim Murray729b6fe2013-07-23 16:20:42 -0700175 struct {
Tim Murray89daad62013-07-29 14:30:02 -0700176 sp<const Sampler> CLAMP_NEAREST;
177 sp<const Sampler> CLAMP_LINEAR;
178 sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR;
179 sp<const Sampler> WRAP_NEAREST;
180 sp<const Sampler> WRAP_LINEAR;
181 sp<const Sampler> WRAP_LINEAR_MIP_LINEAR;
182 sp<const Sampler> MIRRORED_REPEAT_NEAREST;
183 sp<const Sampler> MIRRORED_REPEAT_LINEAR;
184 sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
Tim Murray729b6fe2013-07-23 16:20:42 -0700185 } mSamplers;
186 friend class Sampler;
187 friend class Element;
Tim Murray84bf2b82012-10-31 16:03:16 -0700188};
189
Tim Murray89daad62013-07-29 14:30:02 -0700190class BaseObj : public android::RSC::LightRefBase<BaseObj> {
191public:
192 void * getID() const;
193 virtual ~BaseObj();
194 virtual void updateFromNative();
195 virtual bool equals(sp<const BaseObj> obj);
196
Tim Murray84bf2b82012-10-31 16:03:16 -0700197protected:
198 void *mID;
199 sp<RS> mRS;
Tim Murrayab716362013-08-12 12:37:18 -0700200 std::string mName;
Tim Murray84bf2b82012-10-31 16:03:16 -0700201
202 BaseObj(void *id, sp<RS> rs);
203 void checkValid();
204
205 static void * getObjID(sp<const BaseObj> o);
206
Tim Murray84bf2b82012-10-31 16:03:16 -0700207};
208
209
210class Allocation : public BaseObj {
211protected:
Tim Murray89daad62013-07-29 14:30:02 -0700212 sp<const Type> mType;
Tim Murray84bf2b82012-10-31 16:03:16 -0700213 uint32_t mUsage;
Tim Murray89daad62013-07-29 14:30:02 -0700214 sp<Allocation> mAdaptedAllocation;
Tim Murray84bf2b82012-10-31 16:03:16 -0700215
216 bool mConstrainedLOD;
217 bool mConstrainedFace;
218 bool mConstrainedY;
219 bool mConstrainedZ;
220 bool mReadAllowed;
221 bool mWriteAllowed;
222 uint32_t mSelectedY;
223 uint32_t mSelectedZ;
224 uint32_t mSelectedLOD;
225 RsAllocationCubemapFace mSelectedFace;
226
227 uint32_t mCurrentDimX;
228 uint32_t mCurrentDimY;
229 uint32_t mCurrentDimZ;
230 uint32_t mCurrentCount;
231
232 void * getIDSafe() const;
233 void updateCacheInfo(sp<const Type> t);
234
235 Allocation(void *id, sp<RS> rs, sp<const Type> t, uint32_t usage);
236
237 void validateIsInt32();
238 void validateIsInt16();
239 void validateIsInt8();
240 void validateIsFloat32();
241 void validateIsObject();
242
243 virtual void updateFromNative();
244
245 void validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h);
Tim Murray9d24ae62013-08-30 12:17:14 -0700246 void validate3DRange(uint32_t xoff, uint32_t yoff, uint32_t zoff,
247 uint32_t w, uint32_t h, uint32_t d);
Tim Murray84bf2b82012-10-31 16:03:16 -0700248
249public:
Stephen Hinesa180b7d2013-08-21 12:42:13 -0700250 sp<const Type> getType() const {
Tim Murray84bf2b82012-10-31 16:03:16 -0700251 return mType;
252 }
253
254 void syncAll(RsAllocationUsageType srcLocation);
255 void ioSendOutput();
256 void ioGetInput();
257
258 void generateMipmaps();
Tim Murray509ea5c2012-11-13 11:56:40 -0800259
Tim Murray0b93e302012-11-15 14:56:54 -0800260 void copy1DRangeFrom(uint32_t off, size_t count, const void *data);
Tim Murraya4cbc2b2012-11-14 17:18:08 -0800261 void copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data, uint32_t dataOff);
Tim Murray84bf2b82012-10-31 16:03:16 -0700262
Tim Murray0b93e302012-11-15 14:56:54 -0800263 void copy1DRangeTo(uint32_t off, size_t count, void *data);
264
265 void copy1DFrom(const void* data);
266 void copy1DTo(void* data);
Tim Murraya4cbc2b2012-11-14 17:18:08 -0800267
Tim Murray84bf2b82012-10-31 16:03:16 -0700268 void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
Tim Murray0b93e302012-11-15 14:56:54 -0800269 const void *data);
Tim Murray7b3e3092012-11-16 13:32:24 -0800270
271 void copy2DRangeTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
272 void *data);
273
Tim Murray0b93e302012-11-15 14:56:54 -0800274 void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
275 sp<const Allocation> data, uint32_t dataXoff, uint32_t dataYoff);
Tim Murray84bf2b82012-10-31 16:03:16 -0700276
Tim Murray358747a2012-11-26 13:52:04 -0800277 void copy2DStridedFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
278 const void *data, size_t stride);
279 void copy2DStridedFrom(const void *data, size_t stride);
280
281 void copy2DStridedTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
282 void *data, size_t stride);
283 void copy2DStridedTo(void *data, size_t stride);
284
Tim Murray9d24ae62013-08-30 12:17:14 -0700285 void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t w,
286 uint32_t h, uint32_t d, const void* data);
287
288 void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff,
289 uint32_t w, uint32_t h, uint32_t d,
290 sp<const Allocation> data,
291 uint32_t dataXoff, uint32_t dataYoff, uint32_t dataZoff);
Tim Murray84bf2b82012-10-31 16:03:16 -0700292
293 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
294 RsAllocationMipmapControl mips, uint32_t usage);
295 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
296 RsAllocationMipmapControl mips, uint32_t usage, void * pointer);
297
298 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
299 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
300 static sp<Allocation> createSized(sp<RS> rs, sp<const Element> e, size_t count,
301 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
Tim Murray684726c2012-11-14 11:57:42 -0800302 static sp<Allocation> createSized2D(sp<RS> rs, sp<const Element> e,
303 size_t x, size_t y,
304 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
305
Tim Murray84bf2b82012-10-31 16:03:16 -0700306
307};
308
309class Element : public BaseObj {
310public:
311 bool isComplex();
312 size_t getSubElementCount() {
313 return mVisibleElementMap.size();
314 }
315
316 sp<const Element> getSubElement(uint32_t index);
317 const char * getSubElementName(uint32_t index);
318 size_t getSubElementArraySize(uint32_t index);
319 uint32_t getSubElementOffsetBytes(uint32_t index);
320 RsDataType getDataType() const {
321 return mType;
322 }
323
324 RsDataKind getDataKind() const {
325 return mKind;
326 }
327
328 size_t getSizeBytes() const {
329 return mSizeBytes;
330 }
331
Tim Murray10913a52013-08-20 17:19:47 -0700332 uint32_t getVectorSize() const {
333 return mVectorSize;
334 }
335
Tim Murray84bf2b82012-10-31 16:03:16 -0700336 static sp<const Element> BOOLEAN(sp<RS> rs);
337 static sp<const Element> U8(sp<RS> rs);
338 static sp<const Element> I8(sp<RS> rs);
339 static sp<const Element> U16(sp<RS> rs);
340 static sp<const Element> I16(sp<RS> rs);
341 static sp<const Element> U32(sp<RS> rs);
342 static sp<const Element> I32(sp<RS> rs);
343 static sp<const Element> U64(sp<RS> rs);
344 static sp<const Element> I64(sp<RS> rs);
345 static sp<const Element> F32(sp<RS> rs);
346 static sp<const Element> F64(sp<RS> rs);
347 static sp<const Element> ELEMENT(sp<RS> rs);
348 static sp<const Element> TYPE(sp<RS> rs);
349 static sp<const Element> ALLOCATION(sp<RS> rs);
350 static sp<const Element> SAMPLER(sp<RS> rs);
351 static sp<const Element> SCRIPT(sp<RS> rs);
352 static sp<const Element> MESH(sp<RS> rs);
353 static sp<const Element> PROGRAM_FRAGMENT(sp<RS> rs);
354 static sp<const Element> PROGRAM_VERTEX(sp<RS> rs);
355 static sp<const Element> PROGRAM_RASTER(sp<RS> rs);
356 static sp<const Element> PROGRAM_STORE(sp<RS> rs);
357
358 static sp<const Element> A_8(sp<RS> rs);
359 static sp<const Element> RGB_565(sp<RS> rs);
360 static sp<const Element> RGB_888(sp<RS> rs);
361 static sp<const Element> RGBA_5551(sp<RS> rs);
362 static sp<const Element> RGBA_4444(sp<RS> rs);
363 static sp<const Element> RGBA_8888(sp<RS> rs);
364
365 static sp<const Element> F32_2(sp<RS> rs);
366 static sp<const Element> F32_3(sp<RS> rs);
367 static sp<const Element> F32_4(sp<RS> rs);
368 static sp<const Element> F64_2(sp<RS> rs);
369 static sp<const Element> F64_3(sp<RS> rs);
370 static sp<const Element> F64_4(sp<RS> rs);
371 static sp<const Element> U8_2(sp<RS> rs);
372 static sp<const Element> U8_3(sp<RS> rs);
373 static sp<const Element> U8_4(sp<RS> rs);
374 static sp<const Element> I8_2(sp<RS> rs);
375 static sp<const Element> I8_3(sp<RS> rs);
376 static sp<const Element> I8_4(sp<RS> rs);
377 static sp<const Element> U16_2(sp<RS> rs);
378 static sp<const Element> U16_3(sp<RS> rs);
379 static sp<const Element> U16_4(sp<RS> rs);
380 static sp<const Element> I16_2(sp<RS> rs);
381 static sp<const Element> I16_3(sp<RS> rs);
382 static sp<const Element> I16_4(sp<RS> rs);
383 static sp<const Element> U32_2(sp<RS> rs);
384 static sp<const Element> U32_3(sp<RS> rs);
385 static sp<const Element> U32_4(sp<RS> rs);
386 static sp<const Element> I32_2(sp<RS> rs);
387 static sp<const Element> I32_3(sp<RS> rs);
388 static sp<const Element> I32_4(sp<RS> rs);
389 static sp<const Element> U64_2(sp<RS> rs);
390 static sp<const Element> U64_3(sp<RS> rs);
391 static sp<const Element> U64_4(sp<RS> rs);
392 static sp<const Element> I64_2(sp<RS> rs);
393 static sp<const Element> I64_3(sp<RS> rs);
394 static sp<const Element> I64_4(sp<RS> rs);
Tim Murrayeb4426d2013-08-27 15:30:16 -0700395 static sp<const Element> YUV(sp<RS> rs);
Tim Murray84bf2b82012-10-31 16:03:16 -0700396 static sp<const Element> MATRIX_4X4(sp<RS> rs);
397 static sp<const Element> MATRIX_3X3(sp<RS> rs);
398 static sp<const Element> MATRIX_2X2(sp<RS> rs);
399
Tim Murray84bf2b82012-10-31 16:03:16 -0700400 void updateFromNative();
401 static sp<const Element> createUser(sp<RS> rs, RsDataType dt);
402 static sp<const Element> createVector(sp<RS> rs, RsDataType dt, uint32_t size);
403 static sp<const Element> createPixel(sp<RS> rs, RsDataType dt, RsDataKind dk);
Tim Murray10913a52013-08-20 17:19:47 -0700404 bool isCompatible(sp<const Element>e) const;
Tim Murray84bf2b82012-10-31 16:03:16 -0700405
406 class Builder {
407 private:
408 sp<RS> mRS;
Tim Murray89daad62013-07-29 14:30:02 -0700409 std::vector<sp<Element> > mElements;
Tim Murrayab716362013-08-12 12:37:18 -0700410 std::vector<std::string> mElementNames;
Tim Murray89daad62013-07-29 14:30:02 -0700411 std::vector<uint32_t> mArraySizes;
Tim Murray84bf2b82012-10-31 16:03:16 -0700412 bool mSkipPadding;
413
414 public:
415 Builder(sp<RS> rs);
416 ~Builder();
Tim Murrayab716362013-08-12 12:37:18 -0700417 void add(sp<Element> e, std::string &name, uint32_t arraySize = 1);
Tim Murray84bf2b82012-10-31 16:03:16 -0700418 sp<const Element> create();
419 };
420
Stephen Hines7d1b7572013-08-22 01:24:06 -0700421protected:
422 Element(void *id, sp<RS> rs,
423 std::vector<sp<Element> > &elements,
424 std::vector<std::string> &elementNames,
425 std::vector<uint32_t> &arraySizes);
426 Element(void *id, sp<RS> rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size);
427 Element(sp<RS> rs);
428 virtual ~Element();
429
Tim Murray84bf2b82012-10-31 16:03:16 -0700430private:
431 void updateVisibleSubElements();
432
Tim Murray89daad62013-07-29 14:30:02 -0700433 std::vector<sp<Element> > mElements;
Tim Murrayab716362013-08-12 12:37:18 -0700434 std::vector<std::string> mElementNames;
Tim Murray89daad62013-07-29 14:30:02 -0700435 std::vector<uint32_t> mArraySizes;
436 std::vector<uint32_t> mVisibleElementMap;
437 std::vector<uint32_t> mOffsetInBytes;
Tim Murray84bf2b82012-10-31 16:03:16 -0700438
439 RsDataType mType;
440 RsDataKind mKind;
441 bool mNormalized;
442 size_t mSizeBytes;
443 size_t mVectorSize;
444};
445
Stephen Hines2c7206e2012-11-14 19:47:01 -0800446class FieldPacker {
447protected:
448 unsigned char* mData;
449 size_t mPos;
450 size_t mLen;
451
452public:
453 FieldPacker(size_t len)
Tim Murray89daad62013-07-29 14:30:02 -0700454 : mPos(0), mLen(len) {
455 mData = new unsigned char[len];
456 }
Stephen Hines2c7206e2012-11-14 19:47:01 -0800457
458 virtual ~FieldPacker() {
459 delete [] mData;
460 }
461
462 void align(size_t v) {
463 if ((v & (v - 1)) != 0) {
Tim Murrayab716362013-08-12 12:37:18 -0700464 // ALOGE("Non-power-of-two alignment: %zu", v);
Stephen Hines2c7206e2012-11-14 19:47:01 -0800465 return;
466 }
467
468 while ((mPos & (v - 1)) != 0) {
469 mData[mPos++] = 0;
470 }
471 }
472
473 void reset() {
474 mPos = 0;
475 }
476
477 void reset(size_t i) {
478 if (i >= mLen) {
Tim Murrayab716362013-08-12 12:37:18 -0700479 // ALOGE("Out of bounds: i (%zu) >= len (%zu)", i, mLen);
Stephen Hines2c7206e2012-11-14 19:47:01 -0800480 return;
481 }
482 mPos = i;
483 }
484
485 void skip(size_t i) {
486 size_t res = mPos + i;
487 if (res > mLen) {
Tim Murrayab716362013-08-12 12:37:18 -0700488 // ALOGE("Exceeded buffer length: i (%zu) > len (%zu)", i, mLen);
Stephen Hines2c7206e2012-11-14 19:47:01 -0800489 return;
490 }
491 mPos = res;
492 }
493
494 void* getData() const {
495 return mData;
496 }
497
498 size_t getLength() const {
499 return mLen;
500 }
501
502 template <typename T>
Tim Murray89daad62013-07-29 14:30:02 -0700503 void add(T t) {
Stephen Hines2c7206e2012-11-14 19:47:01 -0800504 align(sizeof(t));
505 if (mPos + sizeof(t) <= mLen) {
506 memcpy(&mData[mPos], &t, sizeof(t));
507 mPos += sizeof(t);
508 }
509 }
Stephen Hines43514cd2012-11-16 14:33:47 -0800510
511 /*
Tim Murray89daad62013-07-29 14:30:02 -0700512 void add(rs_matrix4x4 m) {
513 for (size_t i = 0; i < 16; i++) {
514 add(m.m[i]);
515 }
516 }
Stephen Hines43514cd2012-11-16 14:33:47 -0800517
Tim Murray89daad62013-07-29 14:30:02 -0700518 void add(rs_matrix3x3 m) {
519 for (size_t i = 0; i < 9; i++) {
520 add(m.m[i]);
521 }
522 }
Stephen Hines43514cd2012-11-16 14:33:47 -0800523
Tim Murray89daad62013-07-29 14:30:02 -0700524 void add(rs_matrix2x2 m) {
525 for (size_t i = 0; i < 4; i++) {
526 add(m.m[i]);
527 }
528 }
Stephen Hines43514cd2012-11-16 14:33:47 -0800529 */
530
Tim Murray89daad62013-07-29 14:30:02 -0700531 void add(sp<BaseObj> obj) {
Stephen Hines43514cd2012-11-16 14:33:47 -0800532 if (obj != NULL) {
533 add((uint32_t) (uintptr_t) obj->getID());
534 } else {
535 add((uint32_t) 0);
536 }
537 }
Stephen Hines2c7206e2012-11-14 19:47:01 -0800538};
539
Tim Murray89daad62013-07-29 14:30:02 -0700540
Tim Murray84bf2b82012-10-31 16:03:16 -0700541class Type : public BaseObj {
542protected:
543 friend class Allocation;
544
545 uint32_t mDimX;
546 uint32_t mDimY;
547 uint32_t mDimZ;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700548 RSYuvFormat mYuvFormat;
Tim Murray84bf2b82012-10-31 16:03:16 -0700549 bool mDimMipmaps;
550 bool mDimFaces;
551 size_t mElementCount;
552 sp<const Element> mElement;
553
Stephen Hines7d1b7572013-08-22 01:24:06 -0700554 Type(void *id, sp<RS> rs);
555
Tim Murray84bf2b82012-10-31 16:03:16 -0700556 void calcElementCount();
557 virtual void updateFromNative();
558
559public:
560
Tim Murrayeb4426d2013-08-27 15:30:16 -0700561 RSYuvFormat getYuvFormat() const {
562 return mYuvFormat;
563 }
564
Tim Murray84bf2b82012-10-31 16:03:16 -0700565 sp<const Element> getElement() const {
566 return mElement;
567 }
568
569 uint32_t getX() const {
570 return mDimX;
571 }
572
573 uint32_t getY() const {
574 return mDimY;
575 }
576
577 uint32_t getZ() const {
578 return mDimZ;
579 }
580
581 bool hasMipmaps() const {
582 return mDimMipmaps;
583 }
584
585 bool hasFaces() const {
586 return mDimFaces;
587 }
588
589 size_t getCount() const {
590 return mElementCount;
591 }
592
593 size_t getSizeBytes() const {
594 return mElementCount * mElement->getSizeBytes();
595 }
596
Tim Murray96267c22013-02-12 11:25:12 -0800597 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 -0700598
599 class Builder {
600 protected:
601 sp<RS> mRS;
602 uint32_t mDimX;
603 uint32_t mDimY;
604 uint32_t mDimZ;
Tim Murrayeb4426d2013-08-27 15:30:16 -0700605 RSYuvFormat mYuvFormat;
Tim Murray84bf2b82012-10-31 16:03:16 -0700606 bool mDimMipmaps;
607 bool mDimFaces;
608 sp<const Element> mElement;
609
610 public:
611 Builder(sp<RS> rs, sp<const Element> e);
612
613 void setX(uint32_t value);
Stephen Hines7d1b7572013-08-22 01:24:06 -0700614 void setY(uint32_t value);
Tim Murrayeb4426d2013-08-27 15:30:16 -0700615 void setZ(uint32_t value);
616 void setYuvFormat(RSYuvFormat format);
Tim Murray84bf2b82012-10-31 16:03:16 -0700617 void setMipmaps(bool value);
618 void setFaces(bool value);
619 sp<const Type> create();
620 };
621
622};
623
624class Script : public BaseObj {
625private:
626
627protected:
628 Script(void *id, sp<RS> rs);
629 void forEach(uint32_t slot, sp<const Allocation> in, sp<const Allocation> out,
630 const void *v, size_t) const;
631 void bindAllocation(sp<Allocation> va, uint32_t slot) const;
632 void setVar(uint32_t index, const void *, size_t len) const;
633 void setVar(uint32_t index, sp<const BaseObj> o) const;
634 void invoke(uint32_t slot, const void *v, size_t len) const;
635
636
637 void invoke(uint32_t slot) const {
638 invoke(slot, NULL, 0);
639 }
640 void setVar(uint32_t index, float v) const {
641 setVar(index, &v, sizeof(v));
642 }
643 void setVar(uint32_t index, double v) const {
644 setVar(index, &v, sizeof(v));
645 }
646 void setVar(uint32_t index, int32_t v) const {
647 setVar(index, &v, sizeof(v));
648 }
649 void setVar(uint32_t index, int64_t v) const {
650 setVar(index, &v, sizeof(v));
651 }
652 void setVar(uint32_t index, bool v) const {
653 setVar(index, &v, sizeof(v));
654 }
655
656public:
657 class FieldBase {
658 protected:
659 sp<const Element> mElement;
660 sp<Allocation> mAllocation;
661
662 void init(sp<RS> rs, uint32_t dimx, uint32_t usages = 0);
663
664 public:
665 sp<const Element> getElement() {
666 return mElement;
667 }
668
669 sp<const Type> getType() {
670 return mAllocation->getType();
671 }
672
673 sp<const Allocation> getAllocation() {
674 return mAllocation;
675 }
676
677 //void updateAllocation();
678 };
679};
680
681class ScriptC : public Script {
682protected:
683 ScriptC(sp<RS> rs,
684 const void *codeTxt, size_t codeLength,
685 const char *cachedName, size_t cachedNameLength,
686 const char *cacheDir, size_t cacheDirLength);
687
688};
689
Tim Murray7f0d5682012-11-08 16:35:24 -0800690class ScriptIntrinsic : public Script {
691 protected:
Tim Murray10913a52013-08-20 17:19:47 -0700692 sp<const Element> mElement;
Tim Murray3cd44af2012-11-14 11:25:27 -0800693 ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e);
Tim Murrayb27b1812013-08-05 14:00:40 -0700694 virtual ~ScriptIntrinsic();
Tim Murray7f0d5682012-11-08 16:35:24 -0800695};
696
Tim Murray89daad62013-07-29 14:30:02 -0700697class ScriptIntrinsic3DLUT : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700698 private:
Tim Murray89daad62013-07-29 14:30:02 -0700699 ScriptIntrinsic3DLUT(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700700 public:
701 static sp<ScriptIntrinsic3DLUT> create(sp<RS> rs, sp<const Element> e);
Tim Murray89daad62013-07-29 14:30:02 -0700702 void forEach(sp<Allocation> ain, sp<Allocation> aout);
703 void setLUT(sp<Allocation> lut);
704};
705
Tim Murray7f0d5682012-11-08 16:35:24 -0800706class ScriptIntrinsicBlend : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700707 private:
Tim Murray89daad62013-07-29 14:30:02 -0700708 ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700709 public:
710 static sp<ScriptIntrinsicBlend> create(sp<RS> rs, sp<const Element> e);
Tim Murray7f0d5682012-11-08 16:35:24 -0800711 void blendClear(sp<Allocation> in, sp<Allocation> out);
712 void blendSrc(sp<Allocation> in, sp<Allocation> out);
713 void blendDst(sp<Allocation> in, sp<Allocation> out);
714 void blendSrcOver(sp<Allocation> in, sp<Allocation> out);
715 void blendDstOver(sp<Allocation> in, sp<Allocation> out);
716 void blendSrcIn(sp<Allocation> in, sp<Allocation> out);
717 void blendDstIn(sp<Allocation> in, sp<Allocation> out);
718 void blendSrcOut(sp<Allocation> in, sp<Allocation> out);
719 void blendDstOut(sp<Allocation> in, sp<Allocation> out);
720 void blendSrcAtop(sp<Allocation> in, sp<Allocation> out);
721 void blendDstAtop(sp<Allocation> in, sp<Allocation> out);
722 void blendXor(sp<Allocation> in, sp<Allocation> out);
723 void blendMultiply(sp<Allocation> in, sp<Allocation> out);
724 void blendAdd(sp<Allocation> in, sp<Allocation> out);
725 void blendSubtract(sp<Allocation> in, sp<Allocation> out);
726};
Tim Murray84bf2b82012-10-31 16:03:16 -0700727
Tim Murray8f1e60c2012-11-13 12:25:11 -0800728class ScriptIntrinsicBlur : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700729 private:
Tim Murray89daad62013-07-29 14:30:02 -0700730 ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700731 public:
732 static sp<ScriptIntrinsicBlur> create(sp<RS> rs, sp<const Element> e);
733 void setInput(sp<Allocation> in);
734 void forEach(sp<Allocation> out);
Tim Murray8f1e60c2012-11-13 12:25:11 -0800735 void setRadius(float radius);
736};
737
Tim Murray89daad62013-07-29 14:30:02 -0700738class ScriptIntrinsicColorMatrix : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700739 private:
Tim Murray89daad62013-07-29 14:30:02 -0700740 ScriptIntrinsicColorMatrix(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700741 public:
Tim Murrayaae73c92013-09-03 17:05:46 -0700742 static sp<ScriptIntrinsicColorMatrix> create(sp<RS> rs);
Tim Murray89daad62013-07-29 14:30:02 -0700743 void forEach(sp<Allocation> in, sp<Allocation> out);
Tim Murray10913a52013-08-20 17:19:47 -0700744 void setAdd(float* add);
Tim Murray89daad62013-07-29 14:30:02 -0700745 void setColorMatrix3(float* m);
746 void setColorMatrix4(float* m);
747 void setGreyscale();
748 void setRGBtoYUV();
749 void setYUVtoRGB();
750};
751
752class ScriptIntrinsicConvolve3x3 : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700753 private:
Tim Murray89daad62013-07-29 14:30:02 -0700754 ScriptIntrinsicConvolve3x3(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700755 public:
756 static sp<ScriptIntrinsicConvolve3x3> create(sp<RS> rs, sp<const Element> e);
Tim Murray89daad62013-07-29 14:30:02 -0700757 void setInput(sp<Allocation> in);
758 void forEach(sp<Allocation> out);
759 void setCoefficients(float* v);
760};
761
762class ScriptIntrinsicConvolve5x5 : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700763 private:
Tim Murray89daad62013-07-29 14:30:02 -0700764 ScriptIntrinsicConvolve5x5(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700765 public:
766 static sp<ScriptIntrinsicConvolve5x5> create(sp<RS> rs, sp<const Element> e);
Tim Murray89daad62013-07-29 14:30:02 -0700767 void setInput(sp<Allocation> in);
768 void forEach(sp<Allocation> out);
769 void setCoefficients(float* v);
770};
771
Tim Murrayb27b1812013-08-05 14:00:40 -0700772class ScriptIntrinsicHistogram : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700773 private:
Tim Murrayb27b1812013-08-05 14:00:40 -0700774 ScriptIntrinsicHistogram(sp<RS> rs, sp<const Element> e);
Tim Murray10913a52013-08-20 17:19:47 -0700775 sp<Allocation> mOut;
Tim Murray21fa7a02013-08-15 16:25:03 -0700776 public:
Tim Murray10913a52013-08-20 17:19:47 -0700777 static sp<ScriptIntrinsicHistogram> create(sp<RS> rs);
Tim Murrayb27b1812013-08-05 14:00:40 -0700778 void setOutput(sp<Allocation> aout);
779 void setDotCoefficients(float r, float g, float b, float a);
780 void forEach(sp<Allocation> ain);
781 void forEach_dot(sp<Allocation> ain);
782};
783
784class ScriptIntrinsicLUT : public ScriptIntrinsic {
785 private:
786 sp<Allocation> LUT;
787 bool mDirty;
788 unsigned char mCache[1024];
Tim Murray2acce992013-08-28 14:23:31 -0700789 void setTable(unsigned int offset, unsigned char base, unsigned int length, unsigned char* lutValues);
Tim Murray21fa7a02013-08-15 16:25:03 -0700790 ScriptIntrinsicLUT(sp<RS> rs, sp<const Element> e);
Tim Murrayb27b1812013-08-05 14:00:40 -0700791
Tim Murray89daad62013-07-29 14:30:02 -0700792 public:
Tim Murray21fa7a02013-08-15 16:25:03 -0700793 static sp<ScriptIntrinsicLUT> create(sp<RS> rs, sp<const Element> e);
Tim Murray89daad62013-07-29 14:30:02 -0700794 void forEach(sp<Allocation> ain, sp<Allocation> aout);
Tim Murray2acce992013-08-28 14:23:31 -0700795 void setRed(unsigned char base, unsigned int length, unsigned char* lutValues);
796 void setGreen(unsigned char base, unsigned int length, unsigned char* lutValues);
797 void setBlue(unsigned char base, unsigned int length, unsigned char* lutValues);
798 void setAlpha(unsigned char base, unsigned int length, unsigned char* lutValues);
Tim Murrayb27b1812013-08-05 14:00:40 -0700799 virtual ~ScriptIntrinsicLUT();
800};
801
Tim Murray89daad62013-07-29 14:30:02 -0700802class ScriptIntrinsicYuvToRGB : public ScriptIntrinsic {
Tim Murray21fa7a02013-08-15 16:25:03 -0700803 private:
Tim Murrayb27b1812013-08-05 14:00:40 -0700804 ScriptIntrinsicYuvToRGB(sp<RS> rs, sp<const Element> e);
Tim Murray21fa7a02013-08-15 16:25:03 -0700805 public:
806 static sp<ScriptIntrinsicYuvToRGB> create(sp<RS> rs, sp<const Element> e);
Tim Murrayb27b1812013-08-05 14:00:40 -0700807 void setInput(sp<Allocation> in);
808 void forEach(sp<Allocation> out);
Tim Murray89daad62013-07-29 14:30:02 -0700809
810};
Tim Murrayb27b1812013-08-05 14:00:40 -0700811
Tim Murray89daad62013-07-29 14:30:02 -0700812
Tim Murray729b6fe2013-07-23 16:20:42 -0700813 class Sampler : public BaseObj {
814 private:
815 Sampler(sp<RS> rs, void* id);
816 RsSamplerValue mMin;
817 RsSamplerValue mMag;
818 RsSamplerValue mWrapS;
819 RsSamplerValue mWrapT;
820 RsSamplerValue mWrapR;
821 float mAniso;
822
823 public:
824 static sp<Sampler> create(sp<RS> rs, RsSamplerValue min, RsSamplerValue mag, RsSamplerValue wrapS, RsSamplerValue wrapT, float anisotropy);
825
826 RsSamplerValue getMinification();
827 RsSamplerValue getMagnification();
828 RsSamplerValue getWrapS();
829 RsSamplerValue getWrapT();
830 float getAnisotropy();
831
832 sp<const Sampler> CLAMP_NEAREST(sp<RS> rs);
833 sp<const Sampler> CLAMP_LINEAR(sp<RS> rs);
834 sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR(sp<RS> rs);
835 sp<const Sampler> WRAP_NEAREST(sp<RS> rs);
836 sp<const Sampler> WRAP_LINEAR(sp<RS> rs);
837 sp<const Sampler> WRAP_LINEAR_MIP_LINEAR(sp<RS> rs);
838 sp<const Sampler> MIRRORED_REPEAT_NEAREST(sp<RS> rs);
839 sp<const Sampler> MIRRORED_REPEAT_LINEAR(sp<RS> rs);
840 sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR(sp<RS> rs);
841
842};
843
Stephen Hinesd10412f2013-08-29 18:27:21 -0700844class Byte2 {
845 public:
846 int8_t x, y;
847
848 Byte2(int8_t initX, int8_t initY)
849 : x(initX), y(initY) {}
850 Byte2() : x(0), y(0) {}
851};
852
853class Byte3 {
854 public:
855 int8_t x, y, z;
856
857 Byte3(int8_t initX, int8_t initY, int8_t initZ)
858 : x(initX), y(initY), z(initZ) {}
859 Byte3() : x(0), y(0), z(0) {}
860};
861
862class Byte4 {
863 public:
864 int8_t x, y, z, w;
865
866 Byte4(int8_t initX, int8_t initY, int8_t initZ, int8_t initW)
867 : x(initX), y(initY), z(initZ), w(initW) {}
868 Byte4() : x(0), y(0), z(0), w(0) {}
869};
870
871class UByte2 {
872 public:
873 uint8_t x, y;
874
875 UByte2(uint8_t initX, uint8_t initY)
876 : x(initX), y(initY) {}
877 UByte2() : x(0), y(0) {}
878};
879
880class UByte3 {
881 public:
882 uint8_t x, y, z;
883
884 UByte3(uint8_t initX, uint8_t initY, uint8_t initZ)
885 : x(initX), y(initY), z(initZ) {}
886 UByte3() : x(0), y(0), z(0) {}
887};
888
889class UByte4 {
890 public:
891 uint8_t x, y, z, w;
892
893 UByte4(uint8_t initX, uint8_t initY, uint8_t initZ, uint8_t initW)
894 : x(initX), y(initY), z(initZ), w(initW) {}
895 UByte4() : x(0), y(0), z(0), w(0) {}
896};
897
898class Short2 {
899 public:
900 short x, y;
901
902 Short2(short initX, short initY)
903 : x(initX), y(initY) {}
904 Short2() : x(0), y(0) {}
905};
906
907class Short3 {
908 public:
909 short x, y, z;
910
911 Short3(short initX, short initY, short initZ)
912 : x(initX), y(initY), z(initZ) {}
913 Short3() : x(0), y(0), z(0) {}
914};
915
916class Short4 {
917 public:
918 short x, y, z, w;
919
920 Short4(short initX, short initY, short initZ, short initW)
921 : x(initX), y(initY), z(initZ), w(initW) {}
922 Short4() : x(0), y(0), z(0), w(0) {}
923};
924
925class UShort2 {
926 public:
927 uint16_t x, y;
928
929 UShort2(uint16_t initX, uint16_t initY)
930 : x(initX), y(initY) {}
931 UShort2() : x(0), y(0) {}
932};
933
934class UShort3 {
935 public:
936 uint16_t x, y, z;
937
938 UShort3(uint16_t initX, uint16_t initY, uint16_t initZ)
939 : x(initX), y(initY), z(initZ) {}
940 UShort3() : x(0), y(0), z(0) {}
941};
942
943class UShort4 {
944 public:
945 uint16_t x, y, z, w;
946
947 UShort4(uint16_t initX, uint16_t initY, uint16_t initZ, uint16_t initW)
948 : x(initX), y(initY), z(initZ), w(initW) {}
949 UShort4() : x(0), y(0), z(0), w(0) {}
950};
951
952class Int2 {
953 public:
954 int x, y;
955
956 Int2(int initX, int initY)
957 : x(initX), y(initY) {}
958 Int2() : x(0), y(0) {}
959};
960
961class Int3 {
962 public:
963 int x, y, z;
964
965 Int3(int initX, int initY, int initZ)
966 : x(initX), y(initY), z(initZ) {}
967 Int3() : x(0), y(0), z(0) {}
968};
969
970class Int4 {
971 public:
972 int x, y, z, w;
973
974 Int4(int initX, int initY, int initZ, int initW)
975 : x(initX), y(initY), z(initZ), w(initW) {}
976 Int4() : x(0), y(0), z(0), w(0) {}
977};
978
979class UInt2 {
980 public:
981 uint32_t x, y;
982
983 UInt2(uint32_t initX, uint32_t initY)
984 : x(initX), y(initY) {}
985 UInt2() : x(0), y(0) {}
986};
987
988class UInt3 {
989 public:
990 uint32_t x, y, z;
991
992 UInt3(uint32_t initX, uint32_t initY, uint32_t initZ)
993 : x(initX), y(initY), z(initZ) {}
994 UInt3() : x(0), y(0), z(0) {}
995};
996
997class UInt4 {
998 public:
999 uint32_t x, y, z, w;
1000
1001 UInt4(uint32_t initX, uint32_t initY, uint32_t initZ, uint32_t initW)
1002 : x(initX), y(initY), z(initZ), w(initW) {}
1003 UInt4() : x(0), y(0), z(0), w(0) {}
1004};
1005
1006class Long2 {
1007 public:
1008 int64_t x, y;
1009
1010 Long2(int64_t initX, int64_t initY)
1011 : x(initX), y(initY) {}
1012 Long2() : x(0), y(0) {}
1013};
1014
1015class Long3 {
1016 public:
1017 int64_t x, y, z;
1018
1019 Long3(int64_t initX, int64_t initY, int64_t initZ)
1020 : x(initX), y(initY), z(initZ) {}
1021 Long3() : x(0), y(0), z(0) {}
1022};
1023
1024class Long4 {
1025 public:
1026 int64_t x, y, z, w;
1027
1028 Long4(int64_t initX, int64_t initY, int64_t initZ, int64_t initW)
1029 : x(initX), y(initY), z(initZ), w(initW) {}
1030 Long4() : x(0), y(0), z(0), w(0) {}
1031};
1032
1033class ULong2 {
1034 public:
1035 uint64_t x, y;
1036
1037 ULong2(uint64_t initX, uint64_t initY)
1038 : x(initX), y(initY) {}
1039 ULong2() : x(0), y(0) {}
1040};
1041
1042class ULong3 {
1043 public:
1044 uint64_t x, y, z;
1045
1046 ULong3(uint64_t initX, uint64_t initY, uint64_t initZ)
1047 : x(initX), y(initY), z(initZ) {}
1048 ULong3() : x(0), y(0), z(0) {}
1049};
1050
1051class ULong4 {
1052 public:
1053 uint64_t x, y, z, w;
1054
1055 ULong4(uint64_t initX, uint64_t initY, uint64_t initZ, uint64_t initW)
1056 : x(initX), y(initY), z(initZ), w(initW) {}
1057 ULong4() : x(0), y(0), z(0), w(0) {}
1058};
1059
1060class Float2 {
1061 public:
1062 float x, y;
1063
1064 Float2(float initX, float initY)
1065 : x(initX), y(initY) {}
1066 Float2() : x(0), y(0) {}
1067};
1068
1069class Float3 {
1070 public:
1071 float x, y, z;
1072
1073 Float3(float initX, float initY, float initZ)
1074 : x(initX), y(initY), z(initZ) {}
1075 Float3() : x(0.f), y(0.f), z(0.f) {}
1076};
1077
1078class Float4 {
1079 public:
1080 float x, y, z, w;
1081
1082 Float4(float initX, float initY, float initZ, float initW)
1083 : x(initX), y(initY), z(initZ), w(initW) {}
1084 Float4() : x(0.f), y(0.f), z(0.f), w(0.f) {}
1085};
1086
1087class Double2 {
1088 public:
1089 double x, y;
1090
1091 Double2(double initX, double initY)
1092 : x(initX), y(initY) {}
1093 Double2() : x(0), y(0) {}
1094};
1095
1096class Double3 {
1097 public:
1098 double x, y, z;
1099
1100 Double3(double initX, double initY, double initZ)
1101 : x(initX), y(initY), z(initZ) {}
1102 Double3() : x(0), y(0), z(0) {}
1103};
1104
1105class Double4 {
1106 public:
1107 double x, y, z, w;
1108
1109 Double4(double initX, double initY, double initZ, double initW)
1110 : x(initX), y(initY), z(initZ), w(initW) {}
1111 Double4() : x(0), y(0), z(0), w(0) {}
1112};
1113
Tim Murray84bf2b82012-10-31 16:03:16 -07001114}
Tim Murray7f0d5682012-11-08 16:35:24 -08001115
Tim Murray84bf2b82012-10-31 16:03:16 -07001116}
1117
1118#endif