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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 return return_null_texture(); | 949 return return_null_texture(); |
950 } | 950 } |
951 } else { | 951 } else { |
952 int maxSize = this->caps()->maxTextureSize(); | 952 int maxSize = this->caps()->maxTextureSize(); |
953 if (glTexDesc.fWidth > maxSize || glTexDesc.fHeight > maxSize) { | 953 if (glTexDesc.fWidth > maxSize || glTexDesc.fHeight > maxSize) { |
954 return return_null_texture(); | 954 return return_null_texture(); |
955 } | 955 } |
956 } | 956 } |
957 | 957 |
958 GL_CALL(GenTextures(1, &glTexDesc.fTextureID)); | 958 GL_CALL(GenTextures(1, &glTexDesc.fTextureID)); |
959 if (renderTarget && this->glCaps().textureUsageSupport()) { | 959 |
960 // provides a hint about how this texture will be used | |
961 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | |
962 GR_GL_TEXTURE_USAGE, | |
963 GR_GL_FRAMEBUFFER_ATTACHMENT)); | |
964 } | |
965 if (!glTexDesc.fTextureID) { | 960 if (!glTexDesc.fTextureID) { |
966 return return_null_texture(); | 961 return return_null_texture(); |
967 } | 962 } |
968 | 963 |
969 this->setScratchTextureUnit(); | 964 this->setScratchTextureUnit(); |
970 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); | 965 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); |
971 | 966 |
| 967 if (renderTarget && this->glCaps().textureUsageSupport()) { |
| 968 // provides a hint about how this texture will be used |
| 969 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 970 GR_GL_TEXTURE_USAGE, |
| 971 GR_GL_FRAMEBUFFER_ATTACHMENT)); |
| 972 } |
| 973 |
972 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some | 974 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some |
973 // drivers have a bug where an FBO won't be complete if it includes a | 975 // drivers have a bug where an FBO won't be complete if it includes a |
974 // texture that is not mipmap complete (considering the filter in use). | 976 // texture that is not mipmap complete (considering the filter in use). |
975 GrGLTexture::TexParams initialTexParams; | 977 GrGLTexture::TexParams initialTexParams; |
976 // we only set a subset here so invalidate first | 978 // we only set a subset here so invalidate first |
977 initialTexParams.invalidate(); | 979 initialTexParams.invalidate(); |
978 initialTexParams.fMinFilter = GR_GL_NEAREST; | 980 initialTexParams.fMinFilter = GR_GL_NEAREST; |
979 initialTexParams.fMagFilter = GR_GL_NEAREST; | 981 initialTexParams.fMagFilter = GR_GL_NEAREST; |
980 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; | 982 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; |
981 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; | 983 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; |
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2559 this->setVertexArrayID(gpu, 0); | 2561 this->setVertexArrayID(gpu, 0); |
2560 } | 2562 } |
2561 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2563 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2562 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2564 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2563 fDefaultVertexArrayAttribState.resize(attrCount); | 2565 fDefaultVertexArrayAttribState.resize(attrCount); |
2564 } | 2566 } |
2565 attribState = &fDefaultVertexArrayAttribState; | 2567 attribState = &fDefaultVertexArrayAttribState; |
2566 } | 2568 } |
2567 return attribState; | 2569 return attribState; |
2568 } | 2570 } |
OLD | NEW |