blob: 593e918180934f1566088ccd68fa6ee27c787af7 [file] [log] [blame]
Romain Guy8aa195d2013-06-04 18:00:09 -07001/*
2 * Copyright (C) 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#define LOG_TAG "OpenGLRenderer"
18
19#include <utils/Log.h>
20
21#include "Caches.h"
22#include "Texture.h"
23
24namespace android {
25namespace uirenderer {
26
Romain Guy8aa195d2013-06-04 18:00:09 -070027void Texture::setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture, bool force,
28 GLenum renderTarget) {
29
30 if (mFirstWrap || force || wrapS != mWrapS || wrapT != mWrapT) {
31 mFirstWrap = false;
32
33 mWrapS = wrapS;
34 mWrapT = wrapT;
35
36 if (bindTexture) {
Chris Craik44eb2c02015-01-29 09:45:09 -080037 mCaches.textureState().bindTexture(renderTarget, id);
Romain Guy8aa195d2013-06-04 18:00:09 -070038 }
39
40 glTexParameteri(renderTarget, GL_TEXTURE_WRAP_S, wrapS);
41 glTexParameteri(renderTarget, GL_TEXTURE_WRAP_T, wrapT);
42 }
43}
44
45void Texture::setFilterMinMag(GLenum min, GLenum mag, bool bindTexture, bool force,
46 GLenum renderTarget) {
47
48 if (mFirstFilter || force || min != mMinFilter || mag != mMagFilter) {
49 mFirstFilter = false;
50
51 mMinFilter = min;
52 mMagFilter = mag;
53
54 if (bindTexture) {
Chris Craik44eb2c02015-01-29 09:45:09 -080055 mCaches.textureState().bindTexture(renderTarget, id);
Romain Guy8aa195d2013-06-04 18:00:09 -070056 }
57
58 if (mipMap && min == GL_LINEAR) min = GL_LINEAR_MIPMAP_LINEAR;
59
60 glTexParameteri(renderTarget, GL_TEXTURE_MIN_FILTER, min);
61 glTexParameteri(renderTarget, GL_TEXTURE_MAG_FILTER, mag);
62 }
63}
64
Romain Guybe1b1272013-06-06 14:02:54 -070065void Texture::deleteTexture() const {
Chris Craik44eb2c02015-01-29 09:45:09 -080066 mCaches.textureState().deleteTexture(id);
Romain Guybe1b1272013-06-06 14:02:54 -070067}
68
Romain Guy8aa195d2013-06-04 18:00:09 -070069}; // namespace uirenderer
70}; // namespace android