blob: 2cb3b6585a0e85b4267db36d2193a187d8611b3a [file] [log] [blame]
Mathias Agopian49457ac2013-08-14 18:20:17 -07001/*
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
21namespace android {
22
23Texture::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
30Texture::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
37void Texture::init(Target textureTarget, uint32_t textureName) {
38 mTextureName = textureName;
39 mTextureTarget = textureTarget;
40}
41
42Texture::~Texture() {
43}
44
45
46void Texture::setMatrix(float const* matrix) {
47 memcpy(mTextureMatrix, matrix, sizeof(mTextureMatrix));
48}
49
50void Texture::setFiltering(bool enabled) {
51 mFiltering = enabled;
52}
53
54void Texture::setDimensions(size_t width, size_t height) {
55 mWidth = width;
56 mHeight = height;
57}
58
59uint32_t Texture::getTextureName() const {
60 return mTextureName;
61}
62
63uint32_t Texture::getTextureTarget() const {
64 return mTextureTarget;
65}
66
67float const* Texture::getMatrix() const {
68 return mTextureMatrix;
69}
70
71bool Texture::getFiltering() const {
72 return mFiltering;
73}
74
75size_t Texture::getWidth() const {
76 return mWidth;
77}
78
79size_t Texture::getHeight() const {
80 return mHeight;
81}
82
83} /* namespace android */