blob: 831580b251d9d456b9f3ca6eb869330519e87905 [file] [log] [blame]
Jason Samsd19f10d2009-05-22 14:03:28 -07001/*
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 "rsComponent.h"
Jason Sams1bada8c2009-08-09 17:01:55 -070018#include <GLES/gl.h>
Jason Samsd19f10d2009-05-22 14:03:28 -070019
20using namespace android;
21using namespace android::renderscript;
22
23
24Component::Component()
25{
26 mType = FLOAT;
27 mKind = NONE;
28 mIsNormalized = false;
29 mBits = 0;
30}
31
32Component::Component(
Jason Sams1bada8c2009-08-09 17:01:55 -070033 DataKind dk, DataType dt,
Jason Sams43ee06852009-08-12 17:54:11 -070034 bool isNormalized, uint32_t bits, const char * name)
Jason Samsd19f10d2009-05-22 14:03:28 -070035{
36 mType = dt;
37 mKind = dk;
38 mIsNormalized = isNormalized;
39 mBits = bits;
Jason Sams43ee06852009-08-12 17:54:11 -070040 if (name) {
41 mName = name;
42 }
Jason Samsd19f10d2009-05-22 14:03:28 -070043}
44
45Component::~Component()
46{
47}
Jason Sams1bada8c2009-08-09 17:01:55 -070048
49uint32_t Component::getGLType() const
50{
51 switch(mType) {
52 case RS_TYPE_FLOAT:
53 rsAssert(mBits == 32);
54 return GL_FLOAT;
55 case RS_TYPE_SIGNED:
56 switch(mBits) {
57 case 32:
58 return 0;//GL_INT;
59 case 16:
60 return GL_SHORT;
61 case 8:
62 return GL_BYTE;
63 }
64 break;
65 case RS_TYPE_UNSIGNED:
66 switch(mBits) {
67 case 32:
68 return 0;//GL_UNSIGNED_INT;
69 case 16:
70 return GL_UNSIGNED_SHORT;
71 case 8:
72 return GL_UNSIGNED_BYTE;
73 }
74 break;
75 }
76 //rsAssert(!"Bad type");
77 //LOGE("mType %i, mKind %i, mBits %i, mIsNormalized %i", mType, mKind, mBits, mIsNormalized);
78 return 0;
79}
80
81