blob: fde62a00d6cae1e911d69d3a5201b42e1a5a8a9e [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 Samsd19f10d2009-05-22 14:03:28 -070034 bool isNormalized, uint32_t bits)
35{
36 mType = dt;
37 mKind = dk;
38 mIsNormalized = isNormalized;
39 mBits = bits;
40}
41
42Component::~Component()
43{
44}
Jason Sams1bada8c2009-08-09 17:01:55 -070045
46uint32_t Component::getGLType() const
47{
48 switch(mType) {
49 case RS_TYPE_FLOAT:
50 rsAssert(mBits == 32);
51 return GL_FLOAT;
52 case RS_TYPE_SIGNED:
53 switch(mBits) {
54 case 32:
55 return 0;//GL_INT;
56 case 16:
57 return GL_SHORT;
58 case 8:
59 return GL_BYTE;
60 }
61 break;
62 case RS_TYPE_UNSIGNED:
63 switch(mBits) {
64 case 32:
65 return 0;//GL_UNSIGNED_INT;
66 case 16:
67 return GL_UNSIGNED_SHORT;
68 case 8:
69 return GL_UNSIGNED_BYTE;
70 }
71 break;
72 }
73 //rsAssert(!"Bad type");
74 //LOGE("mType %i, mKind %i, mBits %i, mIsNormalized %i", mType, mKind, mBits, mIsNormalized);
75 return 0;
76}
77
78