| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 | 959 |
| 960 this->setScratchTextureUnit(); | 960 this->setScratchTextureUnit(); |
| 961 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); | 961 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); |
| 962 | 962 |
| 963 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some | 963 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some |
| 964 // drivers have a bug where an FBO won't be complete if it includes a | 964 // drivers have a bug where an FBO won't be complete if it includes a |
| 965 // texture that is not mipmap complete (considering the filter in use). | 965 // texture that is not mipmap complete (considering the filter in use). |
| 966 GrGLTexture::TexParams initialTexParams; | 966 GrGLTexture::TexParams initialTexParams; |
| 967 // we only set a subset here so invalidate first | 967 // we only set a subset here so invalidate first |
| 968 initialTexParams.invalidate(); | 968 initialTexParams.invalidate(); |
| 969 initialTexParams.fFilter = GR_GL_NEAREST; | 969 initialTexParams.fMinFilter = GR_GL_NEAREST; |
| 970 initialTexParams.fMagFilter = GR_GL_NEAREST; |
| 970 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; | 971 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; |
| 971 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; | 972 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; |
| 972 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 973 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 973 GR_GL_TEXTURE_MAG_FILTER, | 974 GR_GL_TEXTURE_MAG_FILTER, |
| 974 initialTexParams.fFilter)); | 975 initialTexParams.fMagFilter)); |
| 975 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 976 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 976 GR_GL_TEXTURE_MIN_FILTER, | 977 GR_GL_TEXTURE_MIN_FILTER, |
| 977 initialTexParams.fFilter)); | 978 initialTexParams.fMinFilter)); |
| 978 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 979 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 979 GR_GL_TEXTURE_WRAP_S, | 980 GR_GL_TEXTURE_WRAP_S, |
| 980 initialTexParams.fWrapS)); | 981 initialTexParams.fWrapS)); |
| 981 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 982 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 982 GR_GL_TEXTURE_WRAP_T, | 983 GR_GL_TEXTURE_WRAP_T, |
| 983 initialTexParams.fWrapT)); | 984 initialTexParams.fWrapT)); |
| 984 if (!this->uploadTexData(glTexDesc, true, 0, 0, | 985 if (!this->uploadTexData(glTexDesc, true, 0, 0, |
| 985 glTexDesc.fWidth, glTexDesc.fHeight, | 986 glTexDesc.fWidth, glTexDesc.fHeight, |
| 986 desc.fConfig, srcData, rowBytes)) { | 987 desc.fConfig, srcData, rowBytes)) { |
| 987 GL_CALL(DeleteTextures(1, &glTexDesc.fTextureID)); | 988 GL_CALL(DeleteTextures(1, &glTexDesc.fTextureID)); |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 this->setTextureUnit(unitIdx); | 2010 this->setTextureUnit(unitIdx); |
| 2010 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); | 2011 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); |
| 2011 fHWBoundTextures[unitIdx] = texture; | 2012 fHWBoundTextures[unitIdx] = texture; |
| 2012 } | 2013 } |
| 2013 | 2014 |
| 2014 ResetTimestamp timestamp; | 2015 ResetTimestamp timestamp; |
| 2015 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); | 2016 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); |
| 2016 bool setAll = timestamp < this->getResetTimestamp(); | 2017 bool setAll = timestamp < this->getResetTimestamp(); |
| 2017 GrGLTexture::TexParams newTexParams; | 2018 GrGLTexture::TexParams newTexParams; |
| 2018 | 2019 |
| 2019 static GrGLenum glFilterModes[] = { | 2020 static GrGLenum glMinFilterModes[] = { |
| 2020 GR_GL_NEAREST, | 2021 GR_GL_NEAREST, |
| 2021 GR_GL_LINEAR, | 2022 GR_GL_LINEAR, |
| 2022 GR_GL_LINEAR_MIPMAP_LINEAR | 2023 GR_GL_LINEAR_MIPMAP_LINEAR |
| 2023 }; | 2024 }; |
| 2024 newTexParams.fFilter = glFilterModes[params.filterMode()]; | 2025 static GrGLenum glMagFilterModes[] = { |
| 2026 GR_GL_NEAREST, |
| 2027 GR_GL_LINEAR, |
| 2028 GR_GL_LINEAR |
| 2029 }; |
| 2030 newTexParams.fMinFilter = glMinFilterModes[params.filterMode()]; |
| 2031 newTexParams.fMagFilter = glMagFilterModes[params.filterMode()]; |
| 2025 | 2032 |
| 2026 #ifndef SKIA_IGNORE_GPU_MIPMAPS | 2033 #ifndef SKIA_IGNORE_GPU_MIPMAPS |
| 2027 if (params.filterMode() == GrTextureParams::kMipMap_FilterMode && | 2034 if (params.filterMode() == GrTextureParams::kMipMap_FilterMode && |
| 2028 texture->mipMapsAreDirty()) { | 2035 texture->mipMapsAreDirty()) { |
| 2029 // GL_CALL(Hint(GR_GL_GENERATE_MIPMAP_HINT,GR_GL_NICEST)); | 2036 // GL_CALL(Hint(GR_GL_GENERATE_MIPMAP_HINT,GR_GL_NICEST)); |
| 2030 GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D)); | 2037 GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D)); |
| 2031 texture->dirtyMipMaps(false); | 2038 texture->dirtyMipMaps(false); |
| 2032 } | 2039 } |
| 2033 #endif | 2040 #endif |
| 2034 | 2041 |
| 2035 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); | 2042 newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); |
| 2036 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); | 2043 newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); |
| 2037 memcpy(newTexParams.fSwizzleRGBA, | 2044 memcpy(newTexParams.fSwizzleRGBA, |
| 2038 GrGLShaderBuilder::GetTexParamSwizzle(texture->config(), this->glCaps
()), | 2045 GrGLShaderBuilder::GetTexParamSwizzle(texture->config(), this->glCaps
()), |
| 2039 sizeof(newTexParams.fSwizzleRGBA)); | 2046 sizeof(newTexParams.fSwizzleRGBA)); |
| 2040 if (setAll || newTexParams.fFilter != oldTexParams.fFilter) { | 2047 if (setAll || newTexParams.fMagFilter != oldTexParams.fMagFilter) { |
| 2041 this->setTextureUnit(unitIdx); | 2048 this->setTextureUnit(unitIdx); |
| 2042 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 2049 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 2043 GR_GL_TEXTURE_MAG_FILTER, | 2050 GR_GL_TEXTURE_MAG_FILTER, |
| 2044 newTexParams.fFilter)); | 2051 newTexParams.fMagFilter)); |
| 2052 } |
| 2053 if (setAll || newTexParams.fMinFilter != oldTexParams.fMinFilter) { |
| 2054 this->setTextureUnit(unitIdx); |
| 2045 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 2055 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 2046 GR_GL_TEXTURE_MIN_FILTER, | 2056 GR_GL_TEXTURE_MIN_FILTER, |
| 2047 newTexParams.fFilter)); | 2057 newTexParams.fMinFilter)); |
| 2048 } | 2058 } |
| 2049 if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) { | 2059 if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) { |
| 2050 this->setTextureUnit(unitIdx); | 2060 this->setTextureUnit(unitIdx); |
| 2051 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 2061 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 2052 GR_GL_TEXTURE_WRAP_S, | 2062 GR_GL_TEXTURE_WRAP_S, |
| 2053 newTexParams.fWrapS)); | 2063 newTexParams.fWrapS)); |
| 2054 } | 2064 } |
| 2055 if (setAll || newTexParams.fWrapT != oldTexParams.fWrapT) { | 2065 if (setAll || newTexParams.fWrapT != oldTexParams.fWrapT) { |
| 2056 this->setTextureUnit(unitIdx); | 2066 this->setTextureUnit(unitIdx); |
| 2057 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 2067 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2539 this->setVertexArrayID(gpu, 0); | 2549 this->setVertexArrayID(gpu, 0); |
| 2540 } | 2550 } |
| 2541 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2551 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2542 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2552 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2543 fDefaultVertexArrayAttribState.resize(attrCount); | 2553 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2544 } | 2554 } |
| 2545 attribState = &fDefaultVertexArrayAttribState; | 2555 attribState = &fDefaultVertexArrayAttribState; |
| 2546 } | 2556 } |
| 2547 return attribState; | 2557 return attribState; |
| 2548 } | 2558 } |
| OLD | NEW |