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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 desc.fConfig = wrapDesc.fConfig; | 650 desc.fConfig = wrapDesc.fConfig; |
651 desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag; | 651 desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag; |
652 desc.fWidth = wrapDesc.fWidth; | 652 desc.fWidth = wrapDesc.fWidth; |
653 desc.fHeight = wrapDesc.fHeight; | 653 desc.fHeight = wrapDesc.fHeight; |
654 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); | 654 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); |
655 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 655 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
656 | 656 |
657 return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencil Bits); | 657 return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencil Bits); |
658 } | 658 } |
659 | 659 |
660 GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextu reDesc& desc, | |
661 GrWrapOwnership owne rship) { | |
662 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | |
663 if (!desc.fTextureHandle) { | |
664 return nullptr; | |
665 } | |
666 #else | |
667 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle); | |
668 if (!info || !info->fID) { | |
669 return nullptr; | |
670 } | |
671 #endif | |
672 | |
673 int maxSize = this->caps()->maxTextureSize(); | |
bsalomon
2016/02/22 16:41:01
I think this can be checked in the base class
ericrk
2016/02/22 21:02:59
Was mirroring wrapBackendTexture here - where were
bsalomon
2016/02/23 02:25:27
Oh, I see that code now. I was thinking move the s
ericrk
2016/02/24 00:39:53
Good point - moved.
| |
674 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | |
675 return nullptr; | |
676 } | |
677 | |
678 GrGLTexture::IDDesc idDesc; | |
679 GrSurfaceDesc surfDesc; | |
680 | |
681 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | |
682 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); | |
683 // We only support GL_TEXTURE_2D at the moment. | |
684 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; | |
685 #else | |
686 idDesc.fInfo = *info; | |
687 #endif | |
688 | |
689 if (GR_GL_TEXTURE_RECTANGLE != idDesc.fInfo.fTarget && | |
690 GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) { | |
691 // Only texture rectangle and texture 2d are supported. We do not check whether texture | |
692 // rectangle is supported by Skia - if the caller provided us with a tex ture rectangle, | |
693 // we assume the necessary support exists. | |
694 return nullptr; | |
695 } | |
696 | |
697 switch (ownership) { | |
698 case kAdopt_GrWrapOwnership: | |
699 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; | |
700 break; | |
701 case kBorrow_GrWrapOwnership: | |
702 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle; | |
703 break; | |
704 } | |
705 | |
706 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; | |
707 surfDesc.fWidth = desc.fWidth; | |
708 surfDesc.fHeight = desc.fHeight; | |
709 surfDesc.fConfig = desc.fConfig; | |
710 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount() ); | |
711 // FIXME: this should be calling resolve_origin(), but Chrome code is curre ntly | |
712 // assuming the old behaviour, which is that backend textures are always | |
713 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: | |
714 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | |
715 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { | |
716 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; | |
717 } else { | |
718 surfDesc.fOrigin = desc.fOrigin; | |
719 } | |
720 | |
721 GrGLRenderTarget::IDDesc rtIDDesc; | |
722 if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_Life Cycle, | |
723 idDesc.fInfo, &rtIDDesc)) { | |
724 return nullptr; | |
725 } | |
726 return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0); | |
727 } | |
660 //////////////////////////////////////////////////////////////////////////////// | 728 //////////////////////////////////////////////////////////////////////////////// |
661 bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 729 bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
662 GrPixelConfig srcConfig, | 730 GrPixelConfig srcConfig, |
663 DrawPreference* drawPreference, | 731 DrawPreference* drawPreference, |
664 WritePixelTempDrawInfo* tempDrawInfo) { | 732 WritePixelTempDrawInfo* tempDrawInfo) { |
665 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf ace->config())) { | 733 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf ace->config())) { |
666 return false; | 734 return false; |
667 } | 735 } |
668 | 736 |
669 // This subclass only allows writes to textures. If the dst is not a texture we have to draw | 737 // This subclass only allows writes to textures. If the dst is not a texture we have to draw |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1527 desc.fTextureStorageAllocator.fDeallocateTextureStorage( | 1595 desc.fTextureStorageAllocator.fDeallocateTextureStorage( |
1528 desc.fTextureStorageAllocator.fCtx, reinterpret_cast<GrBackendOb ject>(info)); | 1596 desc.fTextureStorageAllocator.fCtx, reinterpret_cast<GrBackendOb ject>(info)); |
1529 return false; | 1597 return false; |
1530 } | 1598 } |
1531 return true; | 1599 return true; |
1532 } | 1600 } |
1533 | 1601 |
1534 GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen derTarget* rt, | 1602 GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen derTarget* rt, |
1535 int width, | 1603 int width, |
1536 int height) { | 1604 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()); | 1605 SkASSERT(width >= rt->width()); |
1541 SkASSERT(height >= rt->height()); | 1606 SkASSERT(height >= rt->height()); |
1542 | 1607 |
1543 int samples = rt->numStencilSamples(); | 1608 int samples = rt->numStencilSamples(); |
1544 GrGLStencilAttachment::IDDesc sbDesc; | 1609 GrGLStencilAttachment::IDDesc sbDesc; |
1545 | 1610 |
1546 int sIdx = this->getCompatibleStencilIndex(rt->config()); | 1611 int sIdx = this->getCompatibleStencilIndex(rt->config()); |
1547 if (sIdx < 0) { | 1612 if (sIdx < 0) { |
1548 return nullptr; | 1613 return nullptr; |
1549 } | 1614 } |
(...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3952 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4017 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
3953 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4018 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
3954 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4019 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
3955 copyParams->fWidth = texture->width(); | 4020 copyParams->fWidth = texture->width(); |
3956 copyParams->fHeight = texture->height(); | 4021 copyParams->fHeight = texture->height(); |
3957 return true; | 4022 return true; |
3958 } | 4023 } |
3959 } | 4024 } |
3960 return false; | 4025 return false; |
3961 } | 4026 } |
OLD | NEW |