| 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 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 return return_null_texture(); | 915 return return_null_texture(); |
| 916 } | 916 } |
| 917 } else { | 917 } else { |
| 918 int maxSize = this->caps()->maxTextureSize(); | 918 int maxSize = this->caps()->maxTextureSize(); |
| 919 if (glTexDesc.fWidth > maxSize || glTexDesc.fHeight > maxSize) { | 919 if (glTexDesc.fWidth > maxSize || glTexDesc.fHeight > maxSize) { |
| 920 return return_null_texture(); | 920 return return_null_texture(); |
| 921 } | 921 } |
| 922 } | 922 } |
| 923 | 923 |
| 924 GL_CALL(GenTextures(1, &glTexDesc.fTextureID)); | 924 GL_CALL(GenTextures(1, &glTexDesc.fTextureID)); |
| 925 if (renderTarget && this->glCaps().textureUsageSupport()) { | 925 |
| 926 // provides a hint about how this texture will be used | |
| 927 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | |
| 928 GR_GL_TEXTURE_USAGE, | |
| 929 GR_GL_FRAMEBUFFER_ATTACHMENT)); | |
| 930 } | |
| 931 if (!glTexDesc.fTextureID) { | 926 if (!glTexDesc.fTextureID) { |
| 932 return return_null_texture(); | 927 return return_null_texture(); |
| 933 } | 928 } |
| 934 | 929 |
| 935 this->setScratchTextureUnit(); | 930 this->setScratchTextureUnit(); |
| 936 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); | 931 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID)); |
| 937 | 932 |
| 933 if (renderTarget && this->glCaps().textureUsageSupport()) { |
| 934 // provides a hint about how this texture will be used |
| 935 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| 936 GR_GL_TEXTURE_USAGE, |
| 937 GR_GL_FRAMEBUFFER_ATTACHMENT)); |
| 938 } |
| 939 |
| 938 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some | 940 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some |
| 939 // drivers have a bug where an FBO won't be complete if it includes a | 941 // drivers have a bug where an FBO won't be complete if it includes a |
| 940 // texture that is not mipmap complete (considering the filter in use). | 942 // texture that is not mipmap complete (considering the filter in use). |
| 941 GrGLTexture::TexParams initialTexParams; | 943 GrGLTexture::TexParams initialTexParams; |
| 942 // we only set a subset here so invalidate first | 944 // we only set a subset here so invalidate first |
| 943 initialTexParams.invalidate(); | 945 initialTexParams.invalidate(); |
| 944 initialTexParams.fFilter = GR_GL_NEAREST; | 946 initialTexParams.fFilter = GR_GL_NEAREST; |
| 945 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; | 947 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE; |
| 946 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; | 948 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE; |
| 947 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, | 949 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, |
| (...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2495 this->setVertexArrayID(gpu, 0); | 2497 this->setVertexArrayID(gpu, 0); |
| 2496 } | 2498 } |
| 2497 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2499 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2498 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2500 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2499 fDefaultVertexArrayAttribState.resize(attrCount); | 2501 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2500 } | 2502 } |
| 2501 attribState = &fDefaultVertexArrayAttribState; | 2503 attribState = &fDefaultVertexArrayAttribState; |
| 2502 } | 2504 } |
| 2503 return attribState; | 2505 return attribState; |
| 2504 } | 2506 } |
| OLD | NEW |