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 "GrGLGLSL.h" | 9 #include "GrGLGLSL.h" |
10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 if (!desc.fTextureHandle) { | 540 if (!desc.fTextureHandle) { |
541 return nullptr; | 541 return nullptr; |
542 } | 542 } |
543 #else | 543 #else |
544 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle); | 544 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle); |
545 if (!info || !info->fID) { | 545 if (!info || !info->fID) { |
546 return nullptr; | 546 return nullptr; |
547 } | 547 } |
548 #endif | 548 #endif |
549 | 549 |
550 int maxSize = this->caps()->maxTextureSize(); | |
551 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | |
552 return nullptr; | |
553 } | |
554 | |
555 // next line relies on GrBackendTextureDesc's flags matching GrTexture's | 550 // next line relies on GrBackendTextureDesc's flags matching GrTexture's |
556 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla g); | 551 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla g); |
557 | 552 |
558 GrGLTexture::IDDesc idDesc; | 553 GrGLTexture::IDDesc idDesc; |
559 GrSurfaceDesc surfDesc; | 554 GrSurfaceDesc surfDesc; |
560 | 555 |
561 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | 556 #ifdef SK_IGNORE_GL_TEXTURE_TARGET |
562 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); | 557 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); |
563 // We only support GL_TEXTURE_2D at the moment. | 558 // We only support GL_TEXTURE_2D at the moment. |
564 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; | 559 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 desc.fConfig = wrapDesc.fConfig; | 645 desc.fConfig = wrapDesc.fConfig; |
651 desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag; | 646 desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag; |
652 desc.fWidth = wrapDesc.fWidth; | 647 desc.fWidth = wrapDesc.fWidth; |
653 desc.fHeight = wrapDesc.fHeight; | 648 desc.fHeight = wrapDesc.fHeight; |
654 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); | 649 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); |
655 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 650 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
656 | 651 |
657 return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencil Bits); | 652 return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencil Bits); |
658 } | 653 } |
659 | 654 |
655 GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextu reDesc& desc, | |
656 GrWrapOwnership owne rship) { | |
657 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | |
658 if (!desc.fTextureHandle) { | |
659 return nullptr; | |
660 } | |
661 #else | |
662 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle); | |
663 if (!info || !info->fID) { | |
664 return nullptr; | |
665 } | |
666 #endif | |
667 | |
668 GrGLTexture::IDDesc idDesc; | |
669 GrSurfaceDesc surfDesc; | |
670 | |
671 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | |
672 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); | |
673 // We only support GL_TEXTURE_2D at the moment. | |
674 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; | |
675 #else | |
676 idDesc.fInfo = *info; | |
677 #endif | |
678 | |
679 if (GR_GL_TEXTURE_RECTANGLE != idDesc.fInfo.fTarget && | |
680 GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) { | |
681 // Only texture rectangle and texture 2d are supported. We do not check whether texture | |
682 // rectangle is supported by Skia - if the caller provided us with a tex ture rectangle, | |
683 // we assume the necessary support exists. | |
684 return nullptr; | |
685 } | |
686 | |
687 switch (ownership) { | |
688 case kAdopt_GrWrapOwnership: | |
689 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; | |
690 break; | |
691 case kBorrow_GrWrapOwnership: | |
692 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; | |
693 break; | |
694 } | |
695 | |
696 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; | |
697 surfDesc.fWidth = desc.fWidth; | |
698 surfDesc.fHeight = desc.fHeight; | |
699 surfDesc.fConfig = desc.fConfig; | |
700 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount() ); | |
701 // FIXME: this should be calling resolve_origin(), but Chrome code is curre ntly | |
702 // assuming the old behaviour, which is that backend textures are always | |
703 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: | |
704 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | |
705 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { | |
706 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; | |
707 } else { | |
708 surfDesc.fOrigin = desc.fOrigin; | |
709 } | |
710 | |
711 GrGLRenderTarget::IDDesc rtIDDesc; | |
712 if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_Life Cycle, | |
713 idDesc.fInfo, &rtIDDesc)) { | |
714 return nullptr; | |
715 } | |
716 return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0); | |
717 } | |
660 //////////////////////////////////////////////////////////////////////////////// | 718 //////////////////////////////////////////////////////////////////////////////// |
bsalomon
2016/02/24 18:22:02
\n
ericrk
2016/02/24 19:59:09
Done.
| |
661 bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 719 bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
662 GrPixelConfig srcConfig, | 720 GrPixelConfig srcConfig, |
663 DrawPreference* drawPreference, | 721 DrawPreference* drawPreference, |
664 WritePixelTempDrawInfo* tempDrawInfo) { | 722 WritePixelTempDrawInfo* tempDrawInfo) { |
665 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf ace->config())) { | 723 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf ace->config())) { |
666 return false; | 724 return false; |
667 } | 725 } |
668 | 726 |
669 // This subclass only allows writes to textures. If the dst is not a texture we have to draw | 727 // This subclass only allows writes to textures. If the dst is not a texture we have to draw |
670 // into it. We could use glDrawPixels on GLs that have it, but we don't toda y. | 728 // into it. We could use glDrawPixels on GLs that have it, but we don't toda y. |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1527 desc.fTextureStorageAllocator.fDeallocateTextureStorage( | 1585 desc.fTextureStorageAllocator.fDeallocateTextureStorage( |
1528 desc.fTextureStorageAllocator.fCtx, reinterpret_cast<GrBackendOb ject>(info)); | 1586 desc.fTextureStorageAllocator.fCtx, reinterpret_cast<GrBackendOb ject>(info)); |
1529 return false; | 1587 return false; |
1530 } | 1588 } |
1531 return true; | 1589 return true; |
1532 } | 1590 } |
1533 | 1591 |
1534 GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen derTarget* rt, | 1592 GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen derTarget* rt, |
1535 int width, | 1593 int width, |
1536 int height) { | 1594 int height) { |
1537 // All internally created RTs are also textures. We don't create | |
1538 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . | |
1539 SkASSERT(rt->asTexture()); | |
1540 SkASSERT(width >= rt->width()); | 1595 SkASSERT(width >= rt->width()); |
1541 SkASSERT(height >= rt->height()); | 1596 SkASSERT(height >= rt->height()); |
1542 | 1597 |
1543 int samples = rt->numStencilSamples(); | 1598 int samples = rt->numStencilSamples(); |
1544 GrGLStencilAttachment::IDDesc sbDesc; | 1599 GrGLStencilAttachment::IDDesc sbDesc; |
1545 | 1600 |
1546 int sIdx = this->getCompatibleStencilIndex(rt->config()); | 1601 int sIdx = this->getCompatibleStencilIndex(rt->config()); |
1547 if (sIdx < 0) { | 1602 if (sIdx < 0) { |
1548 return nullptr; | 1603 return nullptr; |
1549 } | 1604 } |
(...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3952 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4007 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
3953 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4008 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
3954 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4009 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
3955 copyParams->fWidth = texture->width(); | 4010 copyParams->fWidth = texture->width(); |
3956 copyParams->fHeight = texture->height(); | 4011 copyParams->fHeight = texture->height(); |
3957 return true; | 4012 return true; |
3958 } | 4013 } |
3959 } | 4014 } |
3960 return false; | 4015 return false; |
3961 } | 4016 } |
OLD | NEW |