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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 if (!desc.fTextureHandle) { | 716 if (!desc.fTextureHandle) { |
717 return nullptr; | 717 return nullptr; |
718 } | 718 } |
719 #else | 719 #else |
720 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc.
fTextureHandle); | 720 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc.
fTextureHandle); |
721 if (!info || !info->fID) { | 721 if (!info || !info->fID) { |
722 return nullptr; | 722 return nullptr; |
723 } | 723 } |
724 #endif | 724 #endif |
725 | 725 |
726 GrGLTextureInfo texInfo; | 726 GrGLTexture::IDDesc idDesc; |
| 727 idDesc.fOwnership = GrBackendObjectOwnership::kBorrowed; |
727 GrSurfaceDesc surfDesc; | 728 GrSurfaceDesc surfDesc; |
728 | 729 |
729 #ifdef SK_IGNORE_GL_TEXTURE_TARGET | 730 #ifdef SK_IGNORE_GL_TEXTURE_TARGET |
730 texInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); | 731 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); |
731 // We only support GL_TEXTURE_2D at the moment. | 732 // We only support GL_TEXTURE_2D at the moment. |
732 texInfo.fTarget = GR_GL_TEXTURE_2D; | 733 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; |
733 #else | 734 #else |
734 texInfo = *info; | 735 idDesc.fInfo = *info; |
735 #endif | 736 #endif |
736 | 737 |
737 if (GR_GL_TEXTURE_RECTANGLE != texInfo.fTarget && | 738 if (GR_GL_TEXTURE_RECTANGLE != idDesc.fInfo.fTarget && |
738 GR_GL_TEXTURE_2D != texInfo.fTarget) { | 739 GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) { |
739 // Only texture rectangle and texture 2d are supported. We do not check
whether texture | 740 // Only texture rectangle and texture 2d are supported. We do not check
whether texture |
740 // rectangle is supported by Skia - if the caller provided us with a tex
ture rectangle, | 741 // rectangle is supported by Skia - if the caller provided us with a tex
ture rectangle, |
741 // we assume the necessary support exists. | 742 // we assume the necessary support exists. |
742 return nullptr; | 743 return nullptr; |
743 } | 744 } |
744 | 745 |
745 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; | 746 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; |
746 surfDesc.fWidth = desc.fWidth; | 747 surfDesc.fWidth = desc.fWidth; |
747 surfDesc.fHeight = desc.fHeight; | 748 surfDesc.fHeight = desc.fHeight; |
748 surfDesc.fConfig = desc.fConfig; | 749 surfDesc.fConfig = desc.fConfig; |
749 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()
); | 750 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()
); |
750 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly | 751 // FIXME: this should be calling resolve_origin(), but Chrome code is curre
ntly |
751 // assuming the old behaviour, which is that backend textures are always | 752 // assuming the old behaviour, which is that backend textures are always |
752 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: | 753 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: |
753 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); | 754 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); |
754 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { | 755 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { |
755 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 756 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
756 } else { | 757 } else { |
757 surfDesc.fOrigin = desc.fOrigin; | 758 surfDesc.fOrigin = desc.fOrigin; |
758 } | 759 } |
759 | 760 |
760 GrGLRenderTarget::IDDesc rtIDDesc; | 761 GrGLRenderTarget::IDDesc rtIDDesc; |
761 if (!this->createRenderTargetObjects(surfDesc, texInfo, &rtIDDesc)) { | 762 if (!this->createRenderTargetObjects(surfDesc, idDesc.fInfo, &rtIDDesc)) { |
762 return nullptr; | 763 return nullptr; |
763 } | 764 } |
764 return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0); | 765 return GrGLTextureRenderTarget::CreateWrapped(this, surfDesc, idDesc, rtIDDe
sc); |
765 } | 766 } |
766 | 767 |
767 //////////////////////////////////////////////////////////////////////////////// | 768 //////////////////////////////////////////////////////////////////////////////// |
768 | 769 |
769 bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 770 bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
770 GrPixelConfig srcConfig, | 771 GrPixelConfig srcConfig, |
771 DrawPreference* drawPreference, | 772 DrawPreference* drawPreference, |
772 WritePixelTempDrawInfo* tempDrawInfo) { | 773 WritePixelTempDrawInfo* tempDrawInfo) { |
773 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf
ace->config())) { | 774 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf
ace->config())) { |
774 return false; | 775 return false; |
(...skipping 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4246 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4247 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4247 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4248 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4248 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4249 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4249 copyParams->fWidth = texture->width(); | 4250 copyParams->fWidth = texture->width(); |
4250 copyParams->fHeight = texture->height(); | 4251 copyParams->fHeight = texture->height(); |
4251 return true; | 4252 return true; |
4252 } | 4253 } |
4253 } | 4254 } |
4254 return false; | 4255 return false; |
4255 } | 4256 } |
OLD | NEW |