blob: 5195b457af2b6a2b4cfdb22e7bc3fd07a0533249 [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
Romain Guy8aa195d2013-06-04 18:00:09 -070017#include <utils/Log.h>
18
19#include "Caches.h"
20#include "Texture.h"
21
22namespace android {
23namespace uirenderer {
24
Romain Guy8aa195d2013-06-04 18:00:09 -070025void Texture::setWrapST(GLenum wrapS, GLenum wrapT, bool bindTexture, bool force,
26 GLenum renderTarget) {
27
28 if (mFirstWrap || force || wrapS != mWrapS || wrapT != mWrapT) {
29 mFirstWrap = false;
30
31 mWrapS = wrapS;
32 mWrapT = wrapT;
33
34 if (bindTexture) {
Chris Craik44eb2c02015-01-29 09:45:09 -080035 mCaches.textureState().bindTexture(renderTarget, id);
Romain Guy8aa195d2013-06-04 18:00:09 -070036 }
37
38 glTexParameteri(renderTarget, GL_TEXTURE_WRAP_S, wrapS);
39 glTexParameteri(renderTarget, GL_TEXTURE_WRAP_T, wrapT);
40 }
41}
42
43void Texture::setFilterMinMag(GLenum min, GLenum mag, bool bindTexture, bool force,
44 GLenum renderTarget) {
45
46 if (mFirstFilter || force || min != mMinFilter || mag != mMagFilter) {
47 mFirstFilter = false;
48
49 mMinFilter = min;
50 mMagFilter = mag;
51
52 if (bindTexture) {
Chris Craik44eb2c02015-01-29 09:45:09 -080053 mCaches.textureState().bindTexture(renderTarget, id);
Romain Guy8aa195d2013-06-04 18:00:09 -070054 }
55
56 if (mipMap && min == GL_LINEAR) min = GL_LINEAR_MIPMAP_LINEAR;
57
58 glTexParameteri(renderTarget, GL_TEXTURE_MIN_FILTER, min);
59 glTexParameteri(renderTarget, GL_TEXTURE_MAG_FILTER, mag);
60 }
61}
62
Romain Guybe1b1272013-06-06 14:02:54 -070063void Texture::deleteTexture() const {
Chris Craik44eb2c02015-01-29 09:45:09 -080064 mCaches.textureState().deleteTexture(id);
Romain Guybe1b1272013-06-06 14:02:54 -070065}
66
Romain Guy8aa195d2013-06-04 18:00:09 -070067}; // namespace uirenderer
68}; // namespace android