Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 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 "rsComponent.h" |
Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame^] | 18 | #include <GLES/gl.h> |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 19 | |
| 20 | using namespace android; |
| 21 | using namespace android::renderscript; |
| 22 | |
| 23 | |
| 24 | Component::Component() |
| 25 | { |
| 26 | mType = FLOAT; |
| 27 | mKind = NONE; |
| 28 | mIsNormalized = false; |
| 29 | mBits = 0; |
| 30 | } |
| 31 | |
| 32 | Component::Component( |
Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame^] | 33 | DataKind dk, DataType dt, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 34 | bool isNormalized, uint32_t bits) |
| 35 | { |
| 36 | mType = dt; |
| 37 | mKind = dk; |
| 38 | mIsNormalized = isNormalized; |
| 39 | mBits = bits; |
| 40 | } |
| 41 | |
| 42 | Component::~Component() |
| 43 | { |
| 44 | } |
Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame^] | 45 | |
| 46 | uint32_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 | |