Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 <string.h> |
| 18 | |
| 19 | #include "Texture.h" |
| 20 | |
| 21 | namespace android { |
| 22 | |
| 23 | Texture::Texture() : |
| 24 | mTextureName(0), mTextureTarget(TEXTURE_2D), |
| 25 | mWidth(0), mHeight(0), mFiltering(false) { |
| 26 | const float m[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; |
| 27 | memcpy(mTextureMatrix, m, sizeof(mTextureMatrix)); |
| 28 | } |
| 29 | |
| 30 | Texture::Texture(Target textureTarget, uint32_t textureName) : |
| 31 | mTextureName(textureName), mTextureTarget(textureTarget), |
| 32 | mWidth(0), mHeight(0), mFiltering(false) { |
| 33 | const float m[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; |
| 34 | memcpy(mTextureMatrix, m, sizeof(mTextureMatrix)); |
| 35 | } |
| 36 | |
| 37 | void Texture::init(Target textureTarget, uint32_t textureName) { |
| 38 | mTextureName = textureName; |
| 39 | mTextureTarget = textureTarget; |
| 40 | } |
| 41 | |
| 42 | Texture::~Texture() { |
| 43 | } |
| 44 | |
| 45 | |
| 46 | void Texture::setMatrix(float const* matrix) { |
| 47 | memcpy(mTextureMatrix, matrix, sizeof(mTextureMatrix)); |
| 48 | } |
| 49 | |
| 50 | void Texture::setFiltering(bool enabled) { |
| 51 | mFiltering = enabled; |
| 52 | } |
| 53 | |
| 54 | void Texture::setDimensions(size_t width, size_t height) { |
| 55 | mWidth = width; |
| 56 | mHeight = height; |
| 57 | } |
| 58 | |
| 59 | uint32_t Texture::getTextureName() const { |
| 60 | return mTextureName; |
| 61 | } |
| 62 | |
| 63 | uint32_t Texture::getTextureTarget() const { |
| 64 | return mTextureTarget; |
| 65 | } |
| 66 | |
| 67 | float const* Texture::getMatrix() const { |
| 68 | return mTextureMatrix; |
| 69 | } |
| 70 | |
| 71 | bool Texture::getFiltering() const { |
| 72 | return mFiltering; |
| 73 | } |
| 74 | |
| 75 | size_t Texture::getWidth() const { |
| 76 | return mWidth; |
| 77 | } |
| 78 | |
| 79 | size_t Texture::getHeight() const { |
| 80 | return mHeight; |
| 81 | } |
| 82 | |
| 83 | } /* namespace android */ |