• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
setWrapST(GLenum wrapS,GLenum wrapT,bool bindTexture,bool force,GLenum renderTarget)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) {
37             mCaches.textureState().bindTexture(renderTarget, id);
38         }
39 
40         glTexParameteri(renderTarget, GL_TEXTURE_WRAP_S, wrapS);
41         glTexParameteri(renderTarget, GL_TEXTURE_WRAP_T, wrapT);
42     }
43 }
44 
setFilterMinMag(GLenum min,GLenum mag,bool bindTexture,bool force,GLenum renderTarget)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) {
55             mCaches.textureState().bindTexture(renderTarget, id);
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 
deleteTexture() const65 void Texture::deleteTexture() const {
66     mCaches.textureState().deleteTexture(id);
67 }
68 
69 }; // namespace uirenderer
70 }; // namespace android
71