| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 fHWProgramID = 0; | 227 fHWProgramID = 0; |
| 228 fTempSrcFBOID = 0; | 228 fTempSrcFBOID = 0; |
| 229 fTempDstFBOID = 0; | 229 fTempDstFBOID = 0; |
| 230 fStencilClearFBOID = 0; | 230 fStencilClearFBOID = 0; |
| 231 | 231 |
| 232 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 232 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
| 233 fPathRendering.reset(new GrGLPathRendering(this)); | 233 fPathRendering.reset(new GrGLPathRendering(this)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 this->createCopyPrograms(); | 236 this->createCopyProgram(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 GrGLGpu::~GrGLGpu() { | 239 GrGLGpu::~GrGLGpu() { |
| 240 if (0 != fHWProgramID) { | 240 if (0 != fHWProgramID) { |
| 241 // detach the current program so there is no confusion on OpenGL's part | 241 // detach the current program so there is no confusion on OpenGL's part |
| 242 // that we want it to be deleted | 242 // that we want it to be deleted |
| 243 GL_CALL(UseProgram(0)); | 243 GL_CALL(UseProgram(0)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 if (0 != fTempSrcFBOID) { | 246 if (0 != fTempSrcFBOID) { |
| 247 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID)); | 247 GL_CALL(DeleteFramebuffers(1, &fTempSrcFBOID)); |
| 248 } | 248 } |
| 249 if (0 != fTempDstFBOID) { | 249 if (0 != fTempDstFBOID) { |
| 250 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID)); | 250 GL_CALL(DeleteFramebuffers(1, &fTempDstFBOID)); |
| 251 } | 251 } |
| 252 if (0 != fStencilClearFBOID) { | 252 if (0 != fStencilClearFBOID) { |
| 253 GL_CALL(DeleteFramebuffers(1, &fStencilClearFBOID)); | 253 GL_CALL(DeleteFramebuffers(1, &fStencilClearFBOID)); |
| 254 } | 254 } |
| 255 | 255 |
| 256 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 256 if (0 != fCopyProgram.fArrayBuffer) { |
| 257 if (0 != fCopyPrograms[i].fProgram) { | 257 GL_CALL(DeleteBuffers(1, &fCopyProgram.fArrayBuffer)); |
| 258 GL_CALL(DeleteProgram(fCopyPrograms[i].fProgram)); | |
| 259 } | |
| 260 } | 258 } |
| 261 if (0 != fCopyProgramArrayBuffer) { | 259 |
| 262 GL_CALL(DeleteBuffers(1, &fCopyProgramArrayBuffer)); | 260 if (0 != fCopyProgram.fProgram) { |
| 261 GL_CALL(DeleteProgram(fCopyProgram.fProgram)); |
| 263 } | 262 } |
| 264 | 263 |
| 265 delete fProgramCache; | 264 delete fProgramCache; |
| 266 } | 265 } |
| 267 | 266 |
| 268 void GrGLGpu::contextAbandoned() { | 267 void GrGLGpu::contextAbandoned() { |
| 269 INHERITED::contextAbandoned(); | 268 INHERITED::contextAbandoned(); |
| 270 fProgramCache->abandon(); | 269 fProgramCache->abandon(); |
| 271 fHWProgramID = 0; | 270 fHWProgramID = 0; |
| 272 fTempSrcFBOID = 0; | 271 fTempSrcFBOID = 0; |
| 273 fTempDstFBOID = 0; | 272 fTempDstFBOID = 0; |
| 274 fStencilClearFBOID = 0; | 273 fStencilClearFBOID = 0; |
| 275 fCopyProgramArrayBuffer = 0; | 274 fCopyProgram.fArrayBuffer = 0; |
| 276 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 275 fCopyProgram.fProgram = 0; |
| 277 fCopyPrograms[i].fProgram = 0; | |
| 278 } | |
| 279 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { | 276 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { |
| 280 this->glPathRendering()->abandonGpuResources(); | 277 this->glPathRendering()->abandonGpuResources(); |
| 281 } | 278 } |
| 282 } | 279 } |
| 283 | 280 |
| 284 /////////////////////////////////////////////////////////////////////////////// | 281 /////////////////////////////////////////////////////////////////////////////// |
| 285 | 282 |
| 286 void GrGLGpu::onResetContext(uint32_t resetBits) { | 283 void GrGLGpu::onResetContext(uint32_t resetBits) { |
| 287 // we don't use the zb at all | 284 // we don't use the zb at all |
| 288 if (resetBits & kMisc_GrGLBackendState) { | 285 if (resetBits & kMisc_GrGLBackendState) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 if (!info || !info->fID) { | 422 if (!info || !info->fID) { |
| 426 return nullptr; | 423 return nullptr; |
| 427 } | 424 } |
| 428 #endif | 425 #endif |
| 429 | 426 |
| 430 int maxSize = this->caps()->maxTextureSize(); | 427 int maxSize = this->caps()->maxTextureSize(); |
| 431 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | 428 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
| 432 return nullptr; | 429 return nullptr; |
| 433 } | 430 } |
| 434 | 431 |
| 435 // next line relies on GrBackendTextureDesc's flags matching GrTexture's | |
| 436 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); | |
| 437 | |
| 438 GrGLTexture::IDDesc idDesc; | 432 GrGLTexture::IDDesc idDesc; |
| 439 GrSurfaceDesc surfDesc; | 433 GrSurfaceDesc surfDesc; |
| 440 | 434 |
| 441 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | 435 #ifdef SK_IGNORE_GL_TEXTURE_TARGET |
| 442 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); | 436 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); |
| 443 // We only support GL_TEXTURE_2D at the moment. | 437 // We only support GL_TEXTURE_2D at the moment. |
| 444 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; | 438 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; |
| 445 #else | 439 #else |
| 446 idDesc.fInfo = *info; | 440 idDesc.fInfo = *info; |
| 447 #endif | 441 #endif |
| 448 if (GR_GL_TEXTURE_EXTERNAL == idDesc.fInfo.fTarget) { | |
| 449 if (renderTarget) { | |
| 450 // This combination is not supported. | |
| 451 return nullptr; | |
| 452 } | |
| 453 if (!this->glCaps().externalTextureSupport()) { | |
| 454 return nullptr; | |
| 455 } | |
| 456 } | |
| 457 | 442 |
| 458 switch (ownership) { | 443 switch (ownership) { |
| 459 case kAdopt_GrWrapOwnership: | 444 case kAdopt_GrWrapOwnership: |
| 460 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; | 445 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; |
| 461 break; | 446 break; |
| 462 case kBorrow_GrWrapOwnership: | 447 case kBorrow_GrWrapOwnership: |
| 463 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; | 448 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; |
| 464 break; | 449 break; |
| 465 } | 450 } |
| 466 | 451 |
| 452 // next line relies on GrBackendTextureDesc's flags matching GrTexture's |
| 467 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; | 453 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; |
| 468 surfDesc.fWidth = desc.fWidth; | 454 surfDesc.fWidth = desc.fWidth; |
| 469 surfDesc.fHeight = desc.fHeight; | 455 surfDesc.fHeight = desc.fHeight; |
| 470 surfDesc.fConfig = desc.fConfig; | 456 surfDesc.fConfig = desc.fConfig; |
| 471 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()
); | 457 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()
); |
| 458 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla
g); |
| 472 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly | 459 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly |
| 473 // assuming the old behaviour, which is that backend textures are always | 460 // assuming the old behaviour, which is that backend textures are always |
| 474 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: | 461 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: |
| 475 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | 462 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); |
| 476 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { | 463 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { |
| 477 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 464 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 478 } else { | 465 } else { |
| 479 surfDesc.fOrigin = desc.fOrigin; | 466 surfDesc.fOrigin = desc.fOrigin; |
| 480 } | 467 } |
| 481 | 468 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 DrawPreference* drawPreference, | 517 DrawPreference* drawPreference, |
| 531 WritePixelTempDrawInfo* tempDrawInfo) { | 518 WritePixelTempDrawInfo* tempDrawInfo) { |
| 532 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf
ace->config())) { | 519 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf
ace->config())) { |
| 533 return false; | 520 return false; |
| 534 } | 521 } |
| 535 | 522 |
| 536 // This subclass only allows writes to textures. If the dst is not a texture
we have to draw | 523 // This subclass only allows writes to textures. If the dst is not a texture
we have to draw |
| 537 // into it. We could use glDrawPixels on GLs that have it, but we don't toda
y. | 524 // into it. We could use glDrawPixels on GLs that have it, but we don't toda
y. |
| 538 if (!dstSurface->asTexture()) { | 525 if (!dstSurface->asTexture()) { |
| 539 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); | 526 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); |
| 540 } else { | |
| 541 GrGLTexture* texture = static_cast<GrGLTexture*>(dstSurface->asTexture()
); | |
| 542 if (GR_GL_TEXTURE_2D != texture->target()) { | |
| 543 // We don't currently support writing pixels to non-TEXTURE_2D text
ures. | |
| 544 return false; | |
| 545 } | |
| 546 } | 527 } |
| 547 | 528 |
| 548 if (GrPixelConfigIsSRGB(dstSurface->config()) != GrPixelConfigIsSRGB(srcConf
ig)) { | 529 if (GrPixelConfigIsSRGB(dstSurface->config()) != GrPixelConfigIsSRGB(srcConf
ig)) { |
| 549 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); | 530 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); |
| 550 } | 531 } |
| 551 | 532 |
| 552 tempDrawInfo->fSwapRAndB = false; | 533 tempDrawInfo->fSwapRAndB = false; |
| 553 | 534 |
| 554 // These settings we will always want if a temp draw is performed. Initially
set the config | 535 // These settings we will always want if a temp draw is performed. Initially
set the config |
| 555 // to srcConfig, though that may be modified if we decide to do a R/G swap. | 536 // to srcConfig, though that may be modified if we decide to do a R/G swap. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 GrGLTexture* glTex = static_cast<GrGLTexture*>(surface->asTexture()); | 578 GrGLTexture* glTex = static_cast<GrGLTexture*>(surface->asTexture()); |
| 598 if (!glTex) { | 579 if (!glTex) { |
| 599 return false; | 580 return false; |
| 600 } | 581 } |
| 601 | 582 |
| 602 // OpenGL doesn't do sRGB <-> linear conversions when reading and writing pi
xels. | 583 // OpenGL doesn't do sRGB <-> linear conversions when reading and writing pi
xels. |
| 603 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { | 584 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { |
| 604 return false; | 585 return false; |
| 605 } | 586 } |
| 606 | 587 |
| 607 // Write pixels is only implemented for TEXTURE_2D textures | |
| 608 if (GR_GL_TEXTURE_2D != glTex->target()) { | |
| 609 return false; | |
| 610 } | |
| 611 | |
| 612 this->setScratchTextureUnit(); | 588 this->setScratchTextureUnit(); |
| 613 GL_CALL(BindTexture(glTex->target(), glTex->textureID())); | 589 GL_CALL(BindTexture(glTex->target(), glTex->textureID())); |
| 614 | 590 |
| 615 bool success = false; | 591 bool success = false; |
| 616 if (GrPixelConfigIsCompressed(glTex->desc().fConfig)) { | 592 if (GrPixelConfigIsCompressed(glTex->desc().fConfig)) { |
| 617 // We check that config == desc.fConfig in GrGLGpu::canWriteTexturePixel
s() | 593 // We check that config == desc.fConfig in GrGLGpu::canWriteTexturePixel
s() |
| 618 SkASSERT(config == glTex->desc().fConfig); | 594 SkASSERT(config == glTex->desc().fConfig); |
| 619 success = this->uploadCompressedTexData(glTex->desc(), glTex->target(),
buffer, false, left, | 595 success = this->uploadCompressedTexData(glTex->desc(), glTex->target(),
buffer, false, left, |
| 620 top, width, height); | 596 top, width, height); |
| 621 } else { | 597 } else { |
| (...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2769 int lastUnitIdx = fHWBoundTextureUniqueIDs.count() - 1; | 2745 int lastUnitIdx = fHWBoundTextureUniqueIDs.count() - 1; |
| 2770 if (lastUnitIdx != fHWActiveTextureUnitIdx) { | 2746 if (lastUnitIdx != fHWActiveTextureUnitIdx) { |
| 2771 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); | 2747 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); |
| 2772 fHWActiveTextureUnitIdx = lastUnitIdx; | 2748 fHWActiveTextureUnitIdx = lastUnitIdx; |
| 2773 } | 2749 } |
| 2774 // clear out the this field so that if a program does use this unit it will
rebind the correct | 2750 // clear out the this field so that if a program does use this unit it will
rebind the correct |
| 2775 // texture. | 2751 // texture. |
| 2776 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID; | 2752 fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID; |
| 2777 } | 2753 } |
| 2778 | 2754 |
| 2755 namespace { |
| 2779 // Determines whether glBlitFramebuffer could be used between src and dst. | 2756 // Determines whether glBlitFramebuffer could be used between src and dst. |
| 2780 static inline bool can_blit_framebuffer(const GrSurface* dst, | 2757 inline bool can_blit_framebuffer(const GrSurface* dst, |
| 2781 const GrSurface* src, | 2758 const GrSurface* src, |
| 2782 const GrGLGpu* gpu) { | 2759 const GrGLGpu* gpu) { |
| 2783 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && | 2760 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && |
| 2784 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && | 2761 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && |
| 2785 gpu->glCaps().usesMSAARenderBuffers()) { | 2762 gpu->glCaps().usesMSAARenderBuffers()) { |
| 2786 // ES3 doesn't allow framebuffer blits when the src has MSAA and the con
figs don't match | 2763 // ES3 doesn't allow framebuffer blits when the src has MSAA and the con
figs don't match |
| 2787 // or the rects are not the same (not just the same size but have the sa
me edges). | 2764 // or the rects are not the same (not just the same size but have the sa
me edges). |
| 2788 if (GrGLCaps::kES_3_0_MSFBOType == gpu->glCaps().msFBOType() && | 2765 if (GrGLCaps::kES_3_0_MSFBOType == gpu->glCaps().msFBOType() && |
| 2789 (src->desc().fSampleCnt > 0 || src->config() != dst->config())) { | 2766 (src->desc().fSampleCnt > 0 || src->config() != dst->config())) { |
| 2790 return false; | 2767 return false; |
| 2791 } | 2768 } |
| 2792 const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTextu
re()); | |
| 2793 if (dstTex && dstTex->target() != GR_GL_TEXTURE_2D) { | |
| 2794 return false; | |
| 2795 } | |
| 2796 const GrGLTexture* srcTex = static_cast<const GrGLTexture*>(dst->asTextu
re()); | |
| 2797 if (srcTex && srcTex->target() != GR_GL_TEXTURE_2D) { | |
| 2798 return false; | |
| 2799 } | |
| 2800 return true; | 2769 return true; |
| 2801 } else { | 2770 } else { |
| 2802 return false; | 2771 return false; |
| 2803 } | 2772 } |
| 2804 } | 2773 } |
| 2805 | 2774 |
| 2806 static inline bool can_copy_texsubimage(const GrSurface* dst, | 2775 inline bool can_copy_texsubimage(const GrSurface* dst, |
| 2807 const GrSurface* src, | 2776 const GrSurface* src, |
| 2808 const GrGLGpu* gpu) { | 2777 const GrGLGpu* gpu) { |
| 2809 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub
Image | 2778 // Table 3.9 of the ES2 spec indicates the supported formats with CopyTexSub
Image |
| 2810 // and BGRA isn't in the spec. There doesn't appear to be any extension that
adds it. Perhaps | 2779 // and BGRA isn't in the spec. There doesn't appear to be any extension that
adds it. Perhaps |
| 2811 // many drivers would allow it to work, but ANGLE does not. | 2780 // many drivers would allow it to work, but ANGLE does not. |
| 2812 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF
ormat() && | 2781 if (kGLES_GrGLStandard == gpu->glStandard() && gpu->glCaps().bgraIsInternalF
ormat() && |
| 2813 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig =
= src->config())) { | 2782 (kBGRA_8888_GrPixelConfig == dst->config() || kBGRA_8888_GrPixelConfig =
= src->config())) { |
| 2814 return false; | 2783 return false; |
| 2815 } | 2784 } |
| 2816 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as
RenderTarget()); | 2785 const GrGLRenderTarget* dstRT = static_cast<const GrGLRenderTarget*>(dst->as
RenderTarget()); |
| 2817 // If dst is multisampled (and uses an extension where there is a separate M
SAA renderbuffer) | 2786 // If dst is multisampled (and uses an extension where there is a separate M
SAA renderbuffer) |
| 2818 // then we don't want to copy to the texture but to the MSAA buffer. | 2787 // then we don't want to copy to the texture but to the MSAA buffer. |
| 2819 if (dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) { | 2788 if (dstRT && dstRT->renderFBOID() != dstRT->textureFBOID()) { |
| 2820 return false; | 2789 return false; |
| 2821 } | 2790 } |
| 2822 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as
RenderTarget()); | 2791 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as
RenderTarget()); |
| 2823 // If the src is multisampled (and uses an extension where there is a separa
te MSAA | 2792 // If the src is multisampled (and uses an extension where there is a separa
te MSAA |
| 2824 // renderbuffer) then it is an invalid operation to call CopyTexSubImage | 2793 // renderbuffer) then it is an invalid operation to call CopyTexSubImage |
| 2825 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { | 2794 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { |
| 2826 return false; | 2795 return false; |
| 2827 } | 2796 } |
| 2828 | |
| 2829 const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTexture()
); | |
| 2830 // CopyTex(Sub)Image writes to a texture and we have no way of dynamically w
rapping a RT in a | |
| 2831 // texture. | |
| 2832 if (!dstTex) { | |
| 2833 return false; | |
| 2834 } | |
| 2835 | |
| 2836 const GrGLTexture* srcTex = static_cast<const GrGLTexture*>(src->asTexture()
); | |
| 2837 | |
| 2838 // Check that we could wrap the source in an FBO, that the dst is TEXTURE_2D
, that no mirroring | |
| 2839 // is required. | |
| 2840 if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && | 2797 if (gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && |
| 2841 !GrPixelConfigIsCompressed(src->config()) && | 2798 dst->asTexture() && |
| 2842 (!srcTex || srcTex->target() == GR_GL_TEXTURE_2D) && | 2799 dst->origin() == src->origin() && |
| 2843 dstTex->target() == GR_GL_TEXTURE_2D && | 2800 !GrPixelConfigIsCompressed(src->config())) { |
| 2844 dst->origin() == src->origin()) { | |
| 2845 return true; | 2801 return true; |
| 2846 } else { | 2802 } else { |
| 2847 return false; | 2803 return false; |
| 2848 } | 2804 } |
| 2849 } | 2805 } |
| 2850 | 2806 |
| 2807 } |
| 2808 |
| 2851 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha
t the copy rect is | 2809 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha
t the copy rect is |
| 2852 // relative to is output. | 2810 // relative to is output. |
| 2853 void GrGLGpu::bindSurfaceFBOForCopy(GrSurface* surface, GrGLenum fboTarget, GrGL
IRect* viewport, | 2811 void GrGLGpu::bindSurfaceFBOForCopy(GrSurface* surface, GrGLenum fboTarget, GrGL
IRect* viewport, |
| 2854 TempFBOTarget tempFBOTarget) { | 2812 TempFBOTarget tempFBOTarget) { |
| 2855 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge
t()); | 2813 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge
t()); |
| 2856 if (nullptr == rt) { | 2814 if (nullptr == rt) { |
| 2857 SkASSERT(surface->asTexture()); | 2815 SkASSERT(surface->asTexture()); |
| 2858 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur
eID(); | 2816 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur
eID(); |
| 2859 GrGLenum target = static_cast<GrGLTexture*>(surface->asTexture())->targe
t(); | 2817 GrGLenum target = static_cast<GrGLTexture*>(surface->asTexture())->targe
t(); |
| 2860 GrGLuint* tempFBOID; | 2818 GrGLuint* tempFBOID; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2898 bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc)
const { | 2856 bool GrGLGpu::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc)
const { |
| 2899 // If the src is a texture, we can implement the blit as a draw assuming the
config is | 2857 // If the src is a texture, we can implement the blit as a draw assuming the
config is |
| 2900 // renderable. | 2858 // renderable. |
| 2901 if (src->asTexture() && this->caps()->isConfigRenderable(src->config(), fals
e)) { | 2859 if (src->asTexture() && this->caps()->isConfigRenderable(src->config(), fals
e)) { |
| 2902 desc->fOrigin = kDefault_GrSurfaceOrigin; | 2860 desc->fOrigin = kDefault_GrSurfaceOrigin; |
| 2903 desc->fFlags = kRenderTarget_GrSurfaceFlag; | 2861 desc->fFlags = kRenderTarget_GrSurfaceFlag; |
| 2904 desc->fConfig = src->config(); | 2862 desc->fConfig = src->config(); |
| 2905 return true; | 2863 return true; |
| 2906 } | 2864 } |
| 2907 | 2865 |
| 2908 const GrGLTexture* srcTexture = static_cast<const GrGLTexture*>(src->asTextu
re()); | |
| 2909 if (srcTexture && srcTexture->target() != GR_GL_TEXTURE_2D) { | |
| 2910 // Not supported for FBO blit or CopyTexSubImage | |
| 2911 return false; | |
| 2912 } | |
| 2913 | |
| 2914 // We look for opportunities to use CopyTexSubImage, or fbo blit. If neither
are | 2866 // We look for opportunities to use CopyTexSubImage, or fbo blit. If neither
are |
| 2915 // possible and we return false to fallback to creating a render target dst
for render-to- | 2867 // possible and we return false to fallback to creating a render target dst
for render-to- |
| 2916 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger
ing temporary fbo | 2868 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger
ing temporary fbo |
| 2917 // creation. It isn't clear that avoiding temporary fbo creation is actually
optimal. | 2869 // creation. It isn't clear that avoiding temporary fbo creation is actually
optimal. |
| 2918 | 2870 |
| 2919 // Check for format issues with glCopyTexSubImage2D | 2871 // Check for format issues with glCopyTexSubImage2D |
| 2920 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna
lFormat() && | 2872 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna
lFormat() && |
| 2921 kBGRA_8888_GrPixelConfig == src->config()) { | 2873 kBGRA_8888_GrPixelConfig == src->config()) { |
| 2922 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be
used with fbo blit | 2874 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be
used with fbo blit |
| 2923 // then we set up for that, otherwise fail. | 2875 // then we set up for that, otherwise fail. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2968 } | 2920 } |
| 2969 | 2921 |
| 2970 if (can_blit_framebuffer(dst, src, this)) { | 2922 if (can_blit_framebuffer(dst, src, this)) { |
| 2971 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); | 2923 return this->copySurfaceAsBlitFramebuffer(dst, src, srcRect, dstPoint); |
| 2972 } | 2924 } |
| 2973 | 2925 |
| 2974 return false; | 2926 return false; |
| 2975 } | 2927 } |
| 2976 | 2928 |
| 2977 | 2929 |
| 2978 void GrGLGpu::createCopyPrograms() { | 2930 void GrGLGpu::createCopyProgram() { |
| 2979 for (size_t i = 0; i < SK_ARRAY_COUNT(fCopyPrograms); ++i) { | 2931 const char* version = this->glCaps().glslCaps()->versionDeclString(); |
| 2980 fCopyPrograms[i].fProgram = 0; | 2932 |
| 2933 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttribute
_TypeModifier); |
| 2934 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, |
| 2935 GrShaderVar::kUniform_TypeModifier); |
| 2936 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, GrShaderVar::kUnifo
rm_TypeModifier); |
| 2937 GrGLSLShaderVar uTexture("u_texture", kSampler2D_GrSLType, GrShaderVar::kUni
form_TypeModifier); |
| 2938 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, GrShaderVar::kVaryi
ngOut_TypeModifier); |
| 2939 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut
_TypeModifier); |
| 2940 |
| 2941 SkString vshaderTxt(version); |
| 2942 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 2943 vshaderTxt.append(";"); |
| 2944 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 2945 vshaderTxt.append(";"); |
| 2946 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 2947 vshaderTxt.append(";"); |
| 2948 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); |
| 2949 vshaderTxt.append(";"); |
| 2950 |
| 2951 vshaderTxt.append( |
| 2952 "// Copy Program VS\n" |
| 2953 "void main() {" |
| 2954 " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.zw;" |
| 2955 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" |
| 2956 " gl_Position.zw = vec2(0, 1);" |
| 2957 "}" |
| 2958 ); |
| 2959 |
| 2960 SkString fshaderTxt(version); |
| 2961 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, |
| 2962 *this->glCaps().glslCaps(), |
| 2963 &fshaderTxt); |
| 2964 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); |
| 2965 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
| 2966 fshaderTxt.append(";"); |
| 2967 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
| 2968 fshaderTxt.append(";"); |
| 2969 const char* fsOutName; |
| 2970 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { |
| 2971 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); |
| 2972 fshaderTxt.append(";"); |
| 2973 fsOutName = oFragColor.c_str(); |
| 2974 } else { |
| 2975 fsOutName = "gl_FragColor"; |
| 2981 } | 2976 } |
| 2982 const char* version = this->glCaps().glslCaps()->versionDeclString(); | 2977 fshaderTxt.appendf( |
| 2983 static const GrSLType kSamplerTypes[2] = { kSampler2D_GrSLType, kSamplerExte
rnal_GrSLType }; | 2978 "// Copy Program FS\n" |
| 2984 SkASSERT(2 == SK_ARRAY_COUNT(fCopyPrograms)); | 2979 "void main() {" |
| 2985 int programCount = this->glCaps().externalTextureSupport() ? 2 : 1; | 2980 " %s = %s(u_texture, v_texCoord);" |
| 2986 for (int i = 0; i < programCount; ++i) { | 2981 "}", |
| 2987 GrGLSLShaderVar aVertex("a_vertex", kVec2f_GrSLType, GrShaderVar::kAttri
bute_TypeModifier); | 2982 fsOutName, |
| 2988 GrGLSLShaderVar uTexCoordXform("u_texCoordXform", kVec4f_GrSLType, | 2983 GrGLSLTexture2DFunctionName(kVec2f_GrSLType, this->glslGeneration()) |
| 2989 GrShaderVar::kUniform_TypeModifier); | 2984 ); |
| 2990 GrGLSLShaderVar uPosXform("u_posXform", kVec4f_GrSLType, | |
| 2991 GrShaderVar::kUniform_TypeModifier); | |
| 2992 GrGLSLShaderVar uTexture("u_texture", kSamplerTypes[i], | |
| 2993 GrShaderVar::kUniform_TypeModifier); | |
| 2994 GrGLSLShaderVar vTexCoord("v_texCoord", kVec2f_GrSLType, | |
| 2995 GrShaderVar::kVaryingOut_TypeModifier); | |
| 2996 GrGLSLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, | |
| 2997 GrShaderVar::kOut_TypeModifier); | |
| 2998 | 2985 |
| 2999 SkString vshaderTxt(version); | 2986 GL_CALL_RET(fCopyProgram.fProgram, CreateProgram()); |
| 3000 aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | 2987 const char* str; |
| 3001 vshaderTxt.append(";"); | 2988 GrGLint length; |
| 3002 uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 3003 vshaderTxt.append(";"); | |
| 3004 uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 3005 vshaderTxt.append(";"); | |
| 3006 vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt); | |
| 3007 vshaderTxt.append(";"); | |
| 3008 | |
| 3009 vshaderTxt.append( | |
| 3010 "// Copy Program VS\n" | |
| 3011 "void main() {" | |
| 3012 " v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.z
w;" | |
| 3013 " gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;" | |
| 3014 " gl_Position.zw = vec2(0, 1);" | |
| 3015 "}" | |
| 3016 ); | |
| 3017 | 2989 |
| 3018 SkString fshaderTxt(version); | 2990 str = vshaderTxt.c_str(); |
| 3019 if (kSamplerTypes[i] == kSamplerExternal_GrSLType) { | 2991 length = SkToInt(vshaderTxt.size()); |
| 3020 fshaderTxt.appendf("#extension %s : require\n", | 2992 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyProgram.fPro
gram, |
| 3021 this->glCaps().glslCaps()->externalTextureExtensi
onString()); | 2993 GR_GL_VERTEX_SHADER, &str, &le
ngth, 1, &fStats); |
| 3022 } | |
| 3023 GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, | |
| 3024 *this->glCaps().glslCaps(), | |
| 3025 &fshaderTxt); | |
| 3026 vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier); | |
| 3027 vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
| 3028 fshaderTxt.append(";"); | |
| 3029 uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
| 3030 fshaderTxt.append(";"); | |
| 3031 const char* fsOutName; | |
| 3032 if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) { | |
| 3033 oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt); | |
| 3034 fshaderTxt.append(";"); | |
| 3035 fsOutName = oFragColor.c_str(); | |
| 3036 } else { | |
| 3037 fsOutName = "gl_FragColor"; | |
| 3038 } | |
| 3039 fshaderTxt.appendf( | |
| 3040 "// Copy Program FS\n" | |
| 3041 "void main() {" | |
| 3042 " %s = %s(u_texture, v_texCoord);" | |
| 3043 "}", | |
| 3044 fsOutName, | |
| 3045 GrGLSLTexture2DFunctionName(kVec2f_GrSLType, this->glslGeneration()) | |
| 3046 ); | |
| 3047 | |
| 3048 GL_CALL_RET(fCopyPrograms[i].fProgram, CreateProgram()); | |
| 3049 const char* str; | |
| 3050 GrGLint length; | |
| 3051 | 2994 |
| 3052 str = vshaderTxt.c_str(); | 2995 str = fshaderTxt.c_str(); |
| 3053 length = SkToInt(vshaderTxt.size()); | 2996 length = SkToInt(fshaderTxt.size()); |
| 3054 GrGLuint vshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms
[i].fProgram, | 2997 GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fCopyProgram.fPro
gram, |
| 3055 GR_GL_VERTEX_SHADER, &str,
&length, 1, | 2998 GR_GL_FRAGMENT_SHADER, &str, &
length, 1, &fStats); |
| 3056 &fStats); | |
| 3057 | 2999 |
| 3058 str = fshaderTxt.c_str(); | 3000 GL_CALL(LinkProgram(fCopyProgram.fProgram)); |
| 3059 length = SkToInt(fshaderTxt.size()); | |
| 3060 GrGLuint fshader = GrGLCompileAndAttachShader(*fGLContext, fCopyPrograms
[i].fProgram, | |
| 3061 GR_GL_FRAGMENT_SHADER, &st
r, &length, 1, | |
| 3062 &fStats); | |
| 3063 | 3001 |
| 3064 GL_CALL(LinkProgram(fCopyPrograms[i].fProgram)); | 3002 GL_CALL_RET(fCopyProgram.fTextureUniform, GetUniformLocation(fCopyProgram.fP
rogram, |
| 3003 "u_texture")); |
| 3004 GL_CALL_RET(fCopyProgram.fPosXformUniform, GetUniformLocation(fCopyProgram.f
Program, |
| 3005 "u_posXform"))
; |
| 3006 GL_CALL_RET(fCopyProgram.fTexCoordXformUniform, GetUniformLocation(fCopyProg
ram.fProgram, |
| 3007 "u_texCoo
rdXform")); |
| 3065 | 3008 |
| 3066 GL_CALL_RET(fCopyPrograms[i].fTextureUniform, | 3009 GL_CALL(BindAttribLocation(fCopyProgram.fProgram, 0, "a_vertex")); |
| 3067 GetUniformLocation(fCopyPrograms[i].fProgram, "u_texture")); | |
| 3068 GL_CALL_RET(fCopyPrograms[i].fPosXformUniform, | |
| 3069 GetUniformLocation(fCopyPrograms[i].fProgram, "u_posXform"))
; | |
| 3070 GL_CALL_RET(fCopyPrograms[i].fTexCoordXformUniform, | |
| 3071 GetUniformLocation(fCopyPrograms[i].fProgram, "u_texCoordXfo
rm")); | |
| 3072 | 3010 |
| 3073 GL_CALL(BindAttribLocation(fCopyPrograms[i].fProgram, 0, "a_vertex")); | 3011 GL_CALL(DeleteShader(vshader)); |
| 3012 GL_CALL(DeleteShader(fshader)); |
| 3074 | 3013 |
| 3075 GL_CALL(DeleteShader(vshader)); | 3014 GL_CALL(GenBuffers(1, &fCopyProgram.fArrayBuffer)); |
| 3076 GL_CALL(DeleteShader(fshader)); | 3015 fHWGeometryState.setVertexBufferID(this, fCopyProgram.fArrayBuffer); |
| 3077 } | |
| 3078 | |
| 3079 GL_CALL(GenBuffers(1, &fCopyProgramArrayBuffer)); | |
| 3080 fHWGeometryState.setVertexBufferID(this, fCopyProgramArrayBuffer); | |
| 3081 static const GrGLfloat vdata[] = { | 3016 static const GrGLfloat vdata[] = { |
| 3082 0, 0, | 3017 0, 0, |
| 3083 0, 1, | 3018 0, 1, |
| 3084 1, 0, | 3019 1, 0, |
| 3085 1, 1 | 3020 1, 1 |
| 3086 }; | 3021 }; |
| 3087 GL_ALLOC_CALL(this->glInterface(), | 3022 GL_ALLOC_CALL(this->glInterface(), |
| 3088 BufferData(GR_GL_ARRAY_BUFFER, | 3023 BufferData(GR_GL_ARRAY_BUFFER, |
| 3089 (GrGLsizeiptr) sizeof(vdata), | 3024 (GrGLsizeiptr) sizeof(vdata), |
| 3090 vdata, // data ptr | 3025 vdata, // data ptr |
| 3091 GR_GL_STATIC_DRAW)); | 3026 GR_GL_STATIC_DRAW)); |
| 3092 } | 3027 } |
| 3093 | 3028 |
| 3094 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, | 3029 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, |
| 3095 GrSurface* src, | 3030 GrSurface* src, |
| 3096 const SkIRect& srcRect, | 3031 const SkIRect& srcRect, |
| 3097 const SkIPoint& dstPoint) { | 3032 const SkIPoint& dstPoint) { |
| 3098 int w = srcRect.width(); | 3033 int w = srcRect.width(); |
| 3099 int h = srcRect.height(); | 3034 int h = srcRect.height(); |
| 3100 | 3035 |
| 3101 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); | 3036 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); |
| 3102 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil
terMode); | 3037 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil
terMode); |
| 3103 this->bindTexture(0, params, srcTex); | 3038 this->bindTexture(0, params, srcTex); |
| 3104 | 3039 |
| 3105 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget
()); | 3040 GrGLRenderTarget* dstRT = static_cast<GrGLRenderTarget*>(dst->asRenderTarget
()); |
| 3106 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); | 3041 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); |
| 3107 this->flushRenderTarget(dstRT, &dstRect); | 3042 this->flushRenderTarget(dstRT, &dstRect); |
| 3108 | 3043 |
| 3109 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); | 3044 GL_CALL(UseProgram(fCopyProgram.fProgram)); |
| 3110 | 3045 fHWProgramID = fCopyProgram.fProgram; |
| 3111 GL_CALL(UseProgram(fCopyPrograms[progIdx].fProgram)); | |
| 3112 fHWProgramID = fCopyPrograms[progIdx].fProgram; | |
| 3113 | 3046 |
| 3114 fHWGeometryState.setVertexArrayID(this, 0); | 3047 fHWGeometryState.setVertexArrayID(this, 0); |
| 3115 | 3048 |
| 3116 GrGLAttribArrayState* attribs = | 3049 GrGLAttribArrayState* attribs = |
| 3117 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgramArrayBuffer)
; | 3050 fHWGeometryState.bindArrayAndBufferToDraw(this, fCopyProgram.fArrayBuffe
r); |
| 3118 attribs->set(this, 0, fCopyProgramArrayBuffer, 2, GR_GL_FLOAT, false, | 3051 attribs->set(this, 0, fCopyProgram.fArrayBuffer, 2, GR_GL_FLOAT, false, |
| 3119 2 * sizeof(GrGLfloat), 0); | 3052 2 * sizeof(GrGLfloat), 0); |
| 3120 attribs->disableUnusedArrays(this, 0x1); | 3053 attribs->disableUnusedArrays(this, 0x1); |
| 3121 | 3054 |
| 3122 // dst rect edges in NDC (-1 to 1) | 3055 // dst rect edges in NDC (-1 to 1) |
| 3123 int dw = dst->width(); | 3056 int dw = dst->width(); |
| 3124 int dh = dst->height(); | 3057 int dh = dst->height(); |
| 3125 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; | 3058 GrGLfloat dx0 = 2.f * dstPoint.fX / dw - 1.f; |
| 3126 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; | 3059 GrGLfloat dx1 = 2.f * (dstPoint.fX + w) / dw - 1.f; |
| 3127 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; | 3060 GrGLfloat dy0 = 2.f * dstPoint.fY / dh - 1.f; |
| 3128 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; | 3061 GrGLfloat dy1 = 2.f * (dstPoint.fY + h) / dh - 1.f; |
| 3129 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { | 3062 if (kBottomLeft_GrSurfaceOrigin == dst->origin()) { |
| 3130 dy0 = -dy0; | 3063 dy0 = -dy0; |
| 3131 dy1 = -dy1; | 3064 dy1 = -dy1; |
| 3132 } | 3065 } |
| 3133 | 3066 |
| 3134 // src rect edges in normalized texture space (0 to 1) | 3067 // src rect edges in normalized texture space (0 to 1) |
| 3135 int sw = src->width(); | 3068 int sw = src->width(); |
| 3136 int sh = src->height(); | 3069 int sh = src->height(); |
| 3137 GrGLfloat sx0 = (GrGLfloat)srcRect.fLeft / sw; | 3070 GrGLfloat sx0 = (GrGLfloat)srcRect.fLeft / sw; |
| 3138 GrGLfloat sx1 = (GrGLfloat)(srcRect.fLeft + w) / sw; | 3071 GrGLfloat sx1 = (GrGLfloat)(srcRect.fLeft + w) / sw; |
| 3139 GrGLfloat sy0 = (GrGLfloat)srcRect.fTop / sh; | 3072 GrGLfloat sy0 = (GrGLfloat)srcRect.fTop / sh; |
| 3140 GrGLfloat sy1 = (GrGLfloat)(srcRect.fTop + h) / sh; | 3073 GrGLfloat sy1 = (GrGLfloat)(srcRect.fTop + h) / sh; |
| 3141 if (kBottomLeft_GrSurfaceOrigin == src->origin()) { | 3074 if (kBottomLeft_GrSurfaceOrigin == src->origin()) { |
| 3142 sy0 = 1.f - sy0; | 3075 sy0 = 1.f - sy0; |
| 3143 sy1 = 1.f - sy1; | 3076 sy1 = 1.f - sy1; |
| 3144 } | 3077 } |
| 3145 | 3078 |
| 3146 GL_CALL(Uniform4f(fCopyPrograms[progIdx].fPosXformUniform, dx1 - dx0, dy1 -
dy0, dx0, dy0)); | 3079 GL_CALL(Uniform4f(fCopyProgram.fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0,
dy0)); |
| 3147 GL_CALL(Uniform4f(fCopyPrograms[progIdx].fTexCoordXformUniform, | 3080 GL_CALL(Uniform4f(fCopyProgram.fTexCoordXformUniform, sx1 - sx0, sy1 - sy0,
sx0, sy0)); |
| 3148 sx1 - sx0, sy1 - sy0, sx0, sy0)); | 3081 GL_CALL(Uniform1i(fCopyProgram.fTextureUniform, 0)); |
| 3149 GL_CALL(Uniform1i(fCopyPrograms[progIdx].fTextureUniform, 0)); | |
| 3150 | 3082 |
| 3151 GrXferProcessor::BlendInfo blendInfo; | 3083 GrXferProcessor::BlendInfo blendInfo; |
| 3152 blendInfo.reset(); | 3084 blendInfo.reset(); |
| 3153 this->flushBlend(blendInfo); | 3085 this->flushBlend(blendInfo); |
| 3154 this->flushColorWrite(true); | 3086 this->flushColorWrite(true); |
| 3155 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); | 3087 this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); |
| 3156 this->flushHWAAState(dstRT, false); | 3088 this->flushHWAAState(dstRT, false); |
| 3157 this->disableScissor(); | 3089 this->disableScissor(); |
| 3158 GrStencilSettings stencil; | 3090 GrStencilSettings stencil; |
| 3159 stencil.setDisabled(); | 3091 stencil.setDisabled(); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3393 this->setVertexArrayID(gpu, 0); | 3325 this->setVertexArrayID(gpu, 0); |
| 3394 } | 3326 } |
| 3395 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3327 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3396 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3328 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3397 fDefaultVertexArrayAttribState.resize(attrCount); | 3329 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3398 } | 3330 } |
| 3399 attribState = &fDefaultVertexArrayAttribState; | 3331 attribState = &fDefaultVertexArrayAttribState; |
| 3400 } | 3332 } |
| 3401 return attribState; | 3333 return attribState; |
| 3402 } | 3334 } |
| OLD | NEW |