| 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 "GrGLGpu.h" | 9 #include "GrGLGpu.h" | 
| 10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" | 
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 518     idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); | 518     idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); | 
| 519     idDesc.fMSColorRenderbufferID = 0; | 519     idDesc.fMSColorRenderbufferID = 0; | 
| 520     idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; | 520     idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; | 
| 521     switch (ownership) { | 521     switch (ownership) { | 
| 522         case kAdopt_GrWrapOwnership: | 522         case kAdopt_GrWrapOwnership: | 
| 523             idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; | 523             idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; | 
| 524             break; | 524             break; | 
| 525         case kBorrow_GrWrapOwnership: | 525         case kBorrow_GrWrapOwnership: | 
| 526             idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; | 526             idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; | 
| 527             break; | 527             break; | 
| 528     } | 528     } | 
| 529     idDesc.fSampleConfig = GrRenderTarget::kUnified_SampleConfig; | 529     idDesc.fSampleConfig = GrRenderTarget::kUnified_SampleConfig; | 
| 530 | 530 | 
| 531     GrSurfaceDesc desc; | 531     GrSurfaceDesc desc; | 
| 532     desc.fConfig = wrapDesc.fConfig; | 532     desc.fConfig = wrapDesc.fConfig; | 
| 533     desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag; | 533     desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag; | 
| 534     desc.fWidth = wrapDesc.fWidth; | 534     desc.fWidth = wrapDesc.fWidth; | 
| 535     desc.fHeight = wrapDesc.fHeight; | 535     desc.fHeight = wrapDesc.fHeight; | 
| 536     desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()
      ); | 536     desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()
      ); | 
| 537     desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 537     desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 
| 538 | 538 | 
| (...skipping 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2782     } | 2782     } | 
| 2783 | 2783 | 
| 2784     const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTexture()
      ); | 2784     const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTexture()
      ); | 
| 2785     // CopyTex(Sub)Image writes to a texture and we have no way of dynamically w
      rapping a RT in a | 2785     // CopyTex(Sub)Image writes to a texture and we have no way of dynamically w
      rapping a RT in a | 
| 2786     // texture. | 2786     // texture. | 
| 2787     if (!dstTex) { | 2787     if (!dstTex) { | 
| 2788         return false; | 2788         return false; | 
| 2789     } | 2789     } | 
| 2790 | 2790 | 
| 2791     const GrGLTexture* srcTex = static_cast<const GrGLTexture*>(src->asTexture()
      ); | 2791     const GrGLTexture* srcTex = static_cast<const GrGLTexture*>(src->asTexture()
      ); | 
| 2792 | 2792 | 
| 2793     // Check that we could wrap the source in an FBO, that the dst is TEXTURE_2D
      , that no mirroring | 2793     // Check that we could wrap the source in an FBO, that the dst is TEXTURE_2D
      , that no mirroring | 
| 2794     // is required. | 2794     // is required. | 
| 2795     if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
       0) && | 2795     if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
       0) && | 
| 2796         !GrPixelConfigIsCompressed(src->config()) && | 2796         !GrPixelConfigIsCompressed(src->config()) && | 
| 2797         (!srcTex || srcTex->target() == GR_GL_TEXTURE_2D) && | 2797         (!srcTex || srcTex->target() == GR_GL_TEXTURE_2D) && | 
| 2798         dstTex->target() == GR_GL_TEXTURE_2D && | 2798         dstTex->target() == GR_GL_TEXTURE_2D && | 
| 2799         dst->origin() == src->origin()) { | 2799         dst->origin() == src->origin()) { | 
| 2800         return true; | 2800         return true; | 
| 2801     } else { | 2801     } else { | 
| 2802         return false; | 2802         return false; | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 2831         viewport->fWidth = surface->width(); | 2831         viewport->fWidth = surface->width(); | 
| 2832         viewport->fHeight = surface->height(); | 2832         viewport->fHeight = surface->height(); | 
| 2833     } else { | 2833     } else { | 
| 2834         fStats.incRenderTargetBinds(); | 2834         fStats.incRenderTargetBinds(); | 
| 2835         GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO
      ID())); | 2835         GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO
      ID())); | 
| 2836         *viewport = rt->getViewport(); | 2836         *viewport = rt->getViewport(); | 
| 2837     } | 2837     } | 
| 2838 } | 2838 } | 
| 2839 | 2839 | 
| 2840 void GrGLGpu::unbindTextureFBOForCopy(GrGLenum fboTarget, GrSurface* surface) { | 2840 void GrGLGpu::unbindTextureFBOForCopy(GrGLenum fboTarget, GrSurface* surface) { | 
| 2841     // bindSurfaceFBOForCopy temporarily binds textures that are not render targ
      ets to | 2841     // bindSurfaceFBOForCopy temporarily binds textures that are not render targ
      ets to | 
| 2842     if (!surface->asRenderTarget()) { | 2842     if (!surface->asRenderTarget()) { | 
| 2843         SkASSERT(surface->asTexture()); | 2843         SkASSERT(surface->asTexture()); | 
| 2844         GrGLenum textureTarget = static_cast<GrGLTexture*>(surface->asTexture())
      ->target(); | 2844         GrGLenum textureTarget = static_cast<GrGLTexture*>(surface->asTexture())
      ->target(); | 
| 2845         GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget, | 2845         GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget, | 
| 2846                                                              GR_GL_COLOR_ATTACHM
      ENT0, | 2846                                                              GR_GL_COLOR_ATTACHM
      ENT0, | 
| 2847                                                              textureTarget, | 2847                                                              textureTarget, | 
| 2848                                                              0, | 2848                                                              0, | 
| 2849                                                              0)); | 2849                                                              0)); | 
| 2850     } | 2850     } | 
| 2851 } | 2851 } | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2915     // None of our copy methods can handle a swizzle. TODO: Make copySurfaceAsDr
      aw handle the | 2915     // None of our copy methods can handle a swizzle. TODO: Make copySurfaceAsDr
      aw handle the | 
| 2916     // swizzle. | 2916     // swizzle. | 
| 2917     if (this->glCaps().glslCaps()->configOutputSwizzle(src->config()) != | 2917     if (this->glCaps().glslCaps()->configOutputSwizzle(src->config()) != | 
| 2918         this->glCaps().glslCaps()->configOutputSwizzle(dst->config())) { | 2918         this->glCaps().glslCaps()->configOutputSwizzle(dst->config())) { | 
| 2919         return false; | 2919         return false; | 
| 2920     } | 2920     } | 
| 2921     if (src->asTexture() && dst->asRenderTarget()) { | 2921     if (src->asTexture() && dst->asRenderTarget()) { | 
| 2922         this->copySurfaceAsDraw(dst, src, srcRect, dstPoint); | 2922         this->copySurfaceAsDraw(dst, src, srcRect, dstPoint); | 
| 2923         return true; | 2923         return true; | 
| 2924     } | 2924     } | 
| 2925 | 2925 | 
| 2926     if (can_copy_texsubimage(dst, src, this)) { | 2926     if (can_copy_texsubimage(dst, src, this)) { | 
| 2927         this->copySurfaceAsCopyTexSubImage(dst, src, srcRect, dstPoint); | 2927         this->copySurfaceAsCopyTexSubImage(dst, src, srcRect, dstPoint); | 
| 2928         return true; | 2928         return true; | 
| 2929     } | 2929     } | 
| 2930 | 2930 | 
| 2931     if (can_blit_framebuffer(dst, src, this)) { | 2931     if (can_blit_framebuffer(dst, src, this)) { | 
| 2932         return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); | 2932         return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); | 
| 2933     } | 2933     } | 
| 2934 | 2934 | 
| 2935     return false; | 2935     return false; | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 2966 | 2966 | 
| 2967         SkString vshaderTxt(version); | 2967         SkString vshaderTxt(version); | 
| 2968         aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 2968         aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 
| 2969         vshaderTxt.append(";"); | 2969         vshaderTxt.append(";"); | 
| 2970         uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 2970         uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 
| 2971         vshaderTxt.append(";"); | 2971         vshaderTxt.append(";"); | 
| 2972         uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 2972         uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 
| 2973         vshaderTxt.append(";"); | 2973         vshaderTxt.append(";"); | 
| 2974         vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 2974         vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 
| 2975         vshaderTxt.append(";"); | 2975         vshaderTxt.append(";"); | 
| 2976 | 2976 | 
| 2977         vshaderTxt.append( | 2977         vshaderTxt.append( | 
| 2978             "// Copy Program VS\n" | 2978             "// Copy Program VS\n" | 
| 2979             "void main() {" | 2979             "void main() {" | 
| 2980             "  v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.z
      w;" | 2980             "  v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.z
      w;" | 
| 2981             "  gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" | 2981             "  gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" | 
| 2982             "  gl_Position.zw = vec2(0, 1);" | 2982             "  gl_Position.zw = vec2(0, 1);" | 
| 2983             "}" | 2983             "}" | 
| 2984         ); | 2984         ); | 
| 2985 | 2985 | 
| 2986         SkString fshaderTxt(version); | 2986         SkString fshaderTxt(version); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 3005             fsOutName = "gl_FragColor"; | 3005             fsOutName = "gl_FragColor"; | 
| 3006         } | 3006         } | 
| 3007         fshaderTxt.appendf( | 3007         fshaderTxt.appendf( | 
| 3008             "// Copy Program FS\n" | 3008             "// Copy Program FS\n" | 
| 3009             "void main() {" | 3009             "void main() {" | 
| 3010             "  %s = %s(u_texture, v_texCoord);" | 3010             "  %s = %s(u_texture, v_texCoord);" | 
| 3011             "}", | 3011             "}", | 
| 3012             fsOutName, | 3012             fsOutName, | 
| 3013             GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[i], this-
      >glslGeneration()) | 3013             GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[i], this-
      >glslGeneration()) | 
| 3014         ); | 3014         ); | 
| 3015 | 3015 | 
| 3016         GL_CALL_RET(fCopyPrograms[i].fProgram, CreateProgram()); | 3016         GL_CALL_RET(fCopyPrograms[i].fProgram, CreateProgram()); | 
| 3017         const char* str; | 3017         const char* str; | 
| 3018         GrGLint length; | 3018         GrGLint length; | 
| 3019 | 3019 | 
| 3020         str = vshaderTxt.c_str(); | 3020         str = vshaderTxt.c_str(); | 
| 3021         length = SkToInt(vshaderTxt.size()); | 3021         length = SkToInt(vshaderTxt.size()); | 
| 3022         GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms
      [i].fProgram, | 3022         GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms
      [i].fProgram, | 
| 3023                                                       GR_GL_VERTEX_SHADER, &str,
       &length, 1, | 3023                                                       GR_GL_VERTEX_SHADER, &str,
       &length, 1, | 
| 3024                                                       &fStats); | 3024                                                       &fStats); | 
| 3025 | 3025 | 
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3556         if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 3556         if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 
| 3557             GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 3557             GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 
| 3558             copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 3558             copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 
| 3559             copyParams->fWidth = texture->width(); | 3559             copyParams->fWidth = texture->width(); | 
| 3560             copyParams->fHeight = texture->height(); | 3560             copyParams->fHeight = texture->height(); | 
| 3561             return true; | 3561             return true; | 
| 3562         } | 3562         } | 
| 3563     } | 3563     } | 
| 3564     return false; | 3564     return false; | 
| 3565 } | 3565 } | 
| OLD | NEW | 
|---|