| 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 |  | 
| Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 23 | Texture::Texture() | 
|  | 24 | : mTextureName(0), mTextureTarget(TEXTURE_2D), mWidth(0), mHeight(0), mFiltering(false) {} | 
| Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 25 |  | 
| Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 26 | Texture::Texture(Target textureTarget, uint32_t textureName) | 
|  | 27 | : mTextureName(textureName), | 
|  | 28 | mTextureTarget(textureTarget), | 
|  | 29 | mWidth(0), | 
|  | 30 | mHeight(0), | 
|  | 31 | mFiltering(false) {} | 
| Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 32 |  | 
|  | 33 | void Texture::init(Target textureTarget, uint32_t textureName) { | 
|  | 34 | mTextureName = textureName; | 
|  | 35 | mTextureTarget = textureTarget; | 
|  | 36 | } | 
|  | 37 |  | 
| Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 38 | Texture::~Texture() {} | 
| Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 39 |  | 
|  | 40 | void Texture::setMatrix(float const* matrix) { | 
| Mathias Agopian | a8c386f | 2013-08-26 20:42:07 -0700 | [diff] [blame] | 41 | mTextureMatrix = mat4(matrix); | 
| Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 42 | } | 
|  | 43 |  | 
|  | 44 | void Texture::setFiltering(bool enabled) { | 
|  | 45 | mFiltering = enabled; | 
|  | 46 | } | 
|  | 47 |  | 
|  | 48 | void Texture::setDimensions(size_t width, size_t height) { | 
|  | 49 | mWidth = width; | 
|  | 50 | mHeight = height; | 
|  | 51 | } | 
|  | 52 |  | 
|  | 53 | uint32_t Texture::getTextureName() const { | 
|  | 54 | return mTextureName; | 
|  | 55 | } | 
|  | 56 |  | 
|  | 57 | uint32_t Texture::getTextureTarget() const { | 
|  | 58 | return mTextureTarget; | 
|  | 59 | } | 
|  | 60 |  | 
| Mathias Agopian | a8c386f | 2013-08-26 20:42:07 -0700 | [diff] [blame] | 61 | const mat4& Texture::getMatrix() const { | 
| Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 62 | return mTextureMatrix; | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | bool Texture::getFiltering() const { | 
|  | 66 | return mFiltering; | 
|  | 67 | } | 
|  | 68 |  | 
|  | 69 | size_t Texture::getWidth() const { | 
|  | 70 | return mWidth; | 
|  | 71 | } | 
|  | 72 |  | 
|  | 73 | size_t Texture::getHeight() const { | 
|  | 74 | return mHeight; | 
|  | 75 | } | 
|  | 76 |  | 
|  | 77 | } /* namespace android */ |