Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace android { |
| 25 | namespace uirenderer { |
| 26 | |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 27 | void 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 Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 37 | mCaches.textureState().bindTexture(renderTarget, id); |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | glTexParameteri(renderTarget, GL_TEXTURE_WRAP_S, wrapS); |
| 41 | glTexParameteri(renderTarget, GL_TEXTURE_WRAP_T, wrapT); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | void 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 Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 55 | mCaches.textureState().bindTexture(renderTarget, id); |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 56 | } |
| 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 Guy | be1b127 | 2013-06-06 14:02:54 -0700 | [diff] [blame] | 65 | void Texture::deleteTexture() const { |
Chris Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 66 | mCaches.textureState().deleteTexture(id); |
Romain Guy | be1b127 | 2013-06-06 14:02:54 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 69 | }; // namespace uirenderer |
| 70 | }; // namespace android |