| 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 #include "GrGLGpu.h" |     8 #include "GrGLGpu.h" | 
|     9 #include "GrGLBuffer.h" |     9 #include "GrGLBuffer.h" | 
|    10 #include "GrGLGLSL.h" |    10 #include "GrGLGLSL.h" | 
| (...skipping 4296 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4307                             dstGLRect.fBottom, |  4307                             dstGLRect.fBottom, | 
|  4308                             dstGLRect.fLeft + dstGLRect.fWidth, |  4308                             dstGLRect.fLeft + dstGLRect.fWidth, | 
|  4309                             dstGLRect.fBottom + dstGLRect.fHeight, |  4309                             dstGLRect.fBottom + dstGLRect.fHeight, | 
|  4310                             GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); |  4310                             GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); | 
|  4311     this->unbindTextureFBOForCopy(GR_GL_DRAW_FRAMEBUFFER, dst); |  4311     this->unbindTextureFBOForCopy(GR_GL_DRAW_FRAMEBUFFER, dst); | 
|  4312     this->unbindTextureFBOForCopy(GR_GL_READ_FRAMEBUFFER, src); |  4312     this->unbindTextureFBOForCopy(GR_GL_READ_FRAMEBUFFER, src); | 
|  4313     this->didWriteToSurface(dst, &dstRect); |  4313     this->didWriteToSurface(dst, &dstRect); | 
|  4314     return true; |  4314     return true; | 
|  4315 } |  4315 } | 
|  4316  |  4316  | 
|  4317 bool gManualMipmaps = true; |  | 
|  4318  |  | 
|  4319 // Manual implementation of mipmap generation, to work around driver bugs w/sRGB
      . |  4317 // Manual implementation of mipmap generation, to work around driver bugs w/sRGB
      . | 
|  4320 // Uses draw calls to do a series of downsample operations to successive mips. |  4318 // Uses draw calls to do a series of downsample operations to successive mips. | 
|  4321 // If this returns false, then the calling code falls back to using glGenerateMi
      pmap. |  4319 // If this returns false, then the calling code falls back to using glGenerateMi
      pmap. | 
|  4322 bool GrGLGpu::generateMipmap(GrGLTexture* texture, bool gammaCorrect) { |  4320 bool GrGLGpu::generateMipmap(GrGLTexture* texture, bool gammaCorrect) { | 
|  4323     // Global switch for manual mipmap generation: |  4321     // Our iterative downsample requires the ability to limit which level we're 
      sampling: | 
|  4324     if (!gManualMipmaps) { |  4322     if (!this->glCaps().doManualMipmapping()) { | 
|  4325         return false; |  4323         return false; | 
|  4326     } |  4324     } | 
|  4327  |  4325  | 
|  4328     // Mipmaps are only supported on 2D textures: |  4326     // Mipmaps are only supported on 2D textures: | 
|  4329     if (GR_GL_TEXTURE_2D != texture->target()) { |  4327     if (GR_GL_TEXTURE_2D != texture->target()) { | 
|  4330         return false; |  4328         return false; | 
|  4331     } |  4329     } | 
|  4332  |  4330  | 
|  4333     // We need to be able to render to the texture for this to work: |  4331     // We need to be able to render to the texture for this to work: | 
|  4334     if (!this->caps()->isConfigRenderable(texture->config(), false)) { |  4332     if (!this->caps()->isConfigRenderable(texture->config(), false)) { | 
|  4335         return false; |  4333         return false; | 
|  4336     } |  4334     } | 
|  4337  |  4335  | 
|  4338     // Our iterative downsample requires the ability to limit which level we're 
      sampling: |  | 
|  4339     if (!this->glCaps().mipMapLevelAndLodControlSupport()) { |  | 
|  4340         return false; |  | 
|  4341     } |  | 
|  4342  |  | 
|  4343     // If we're mipping an sRGB texture, we need to ensure FB sRGB is correct: |  4336     // If we're mipping an sRGB texture, we need to ensure FB sRGB is correct: | 
|  4344     if (GrPixelConfigIsSRGB(texture->config())) { |  4337     if (GrPixelConfigIsSRGB(texture->config())) { | 
|  4345         // If we have write-control, just set the state that we want: |  4338         // If we have write-control, just set the state that we want: | 
|  4346         if (this->glCaps().srgbWriteControl()) { |  4339         if (this->glCaps().srgbWriteControl()) { | 
|  4347             this->flushFramebufferSRGB(gammaCorrect); |  4340             this->flushFramebufferSRGB(gammaCorrect); | 
|  4348         } else if (!gammaCorrect) { |  4341         } else if (!gammaCorrect) { | 
|  4349             // If we don't have write-control we can't do non-gamma-correct mipm
      apping: |  4342             // If we don't have write-control we can't do non-gamma-correct mipm
      apping: | 
|  4350             return false; |  4343             return false; | 
|  4351         } |  4344         } | 
|  4352     } |  4345     } | 
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4647         if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |  4640         if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 
|  4648             GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |  4641             GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 
|  4649             copyParams->fFilter = GrTextureParams::kNone_FilterMode; |  4642             copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 
|  4650             copyParams->fWidth = texture->width(); |  4643             copyParams->fWidth = texture->width(); | 
|  4651             copyParams->fHeight = texture->height(); |  4644             copyParams->fHeight = texture->height(); | 
|  4652             return true; |  4645             return true; | 
|  4653         } |  4646         } | 
|  4654     } |  4647     } | 
|  4655     return false; |  4648     return false; | 
|  4656 } |  4649 } | 
| OLD | NEW |