Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1842313003: Remove ownership parameter from GrResourceProvider::wrapBackendTextureAsRenderTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: whitespace Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/vk/GrVkGpu.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 desc.fConfig = wrapDesc.fConfig; 654 desc.fConfig = wrapDesc.fConfig;
655 desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag; 655 desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag;
656 desc.fWidth = wrapDesc.fWidth; 656 desc.fWidth = wrapDesc.fWidth;
657 desc.fHeight = wrapDesc.fHeight; 657 desc.fHeight = wrapDesc.fHeight;
658 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); 658 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() );
659 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); 659 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true);
660 660
661 return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencil Bits); 661 return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencil Bits);
662 } 662 }
663 663
664 GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextu reDesc& desc, 664 GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextu reDesc& desc) {
665 GrWrapOwnership owne rship) {
666 #ifdef SK_IGNORE_GL_TEXTURE_TARGET 665 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
667 if (!desc.fTextureHandle) { 666 if (!desc.fTextureHandle) {
668 return nullptr; 667 return nullptr;
669 } 668 }
670 #else 669 #else
671 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle); 670 const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc. fTextureHandle);
672 if (!info || !info->fID) { 671 if (!info || !info->fID) {
673 return nullptr; 672 return nullptr;
674 } 673 }
675 #endif 674 #endif
676 675
677 GrGLTexture::IDDesc idDesc; 676 GrGLTextureInfo texInfo;
678 GrSurfaceDesc surfDesc; 677 GrSurfaceDesc surfDesc;
679 678
680 #ifdef SK_IGNORE_GL_TEXTURE_TARGET 679 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
681 idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle); 680 texInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle);
682 // We only support GL_TEXTURE_2D at the moment. 681 // We only support GL_TEXTURE_2D at the moment.
683 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; 682 texInfo.fTarget = GR_GL_TEXTURE_2D;
684 #else 683 #else
685 idDesc.fInfo = *info; 684 texInfo = *info;
686 #endif 685 #endif
687 686
688 if (GR_GL_TEXTURE_RECTANGLE != idDesc.fInfo.fTarget && 687 if (GR_GL_TEXTURE_RECTANGLE != texInfo.fTarget &&
689 GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) { 688 GR_GL_TEXTURE_2D != texInfo.fTarget) {
690 // Only texture rectangle and texture 2d are supported. We do not check whether texture 689 // Only texture rectangle and texture 2d are supported. We do not check whether texture
691 // rectangle is supported by Skia - if the caller provided us with a tex ture rectangle, 690 // rectangle is supported by Skia - if the caller provided us with a tex ture rectangle,
692 // we assume the necessary support exists. 691 // we assume the necessary support exists.
693 return nullptr; 692 return nullptr;
694 } 693 }
695 694
696 switch (ownership) {
697 case kAdopt_GrWrapOwnership:
698 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle;
699 break;
700 case kBorrow_GrWrapOwnership:
701 idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle;
702 break;
703 }
704
705 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags; 695 surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags;
706 surfDesc.fWidth = desc.fWidth; 696 surfDesc.fWidth = desc.fWidth;
707 surfDesc.fHeight = desc.fHeight; 697 surfDesc.fHeight = desc.fHeight;
708 surfDesc.fConfig = desc.fConfig; 698 surfDesc.fConfig = desc.fConfig;
709 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount() ); 699 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount() );
710 // FIXME: this should be calling resolve_origin(), but Chrome code is curre ntly 700 // FIXME: this should be calling resolve_origin(), but Chrome code is curre ntly
711 // assuming the old behaviour, which is that backend textures are always 701 // assuming the old behaviour, which is that backend textures are always
712 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: 702 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to:
713 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); 703 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget);
714 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { 704 if (kDefault_GrSurfaceOrigin == desc.fOrigin) {
715 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; 705 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
716 } else { 706 } else {
717 surfDesc.fOrigin = desc.fOrigin; 707 surfDesc.fOrigin = desc.fOrigin;
718 } 708 }
719 709
720 GrGLRenderTarget::IDDesc rtIDDesc; 710 GrGLRenderTarget::IDDesc rtIDDesc;
721 if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_Life Cycle, 711 if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_Life Cycle,
722 idDesc.fInfo, &rtIDDesc)) { 712 texInfo, &rtIDDesc)) {
723 return nullptr; 713 return nullptr;
724 } 714 }
725 return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0); 715 return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0);
726 } 716 }
727 717
728 //////////////////////////////////////////////////////////////////////////////// 718 ////////////////////////////////////////////////////////////////////////////////
729 719
730 bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, 720 bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
731 GrPixelConfig srcConfig, 721 GrPixelConfig srcConfig,
732 DrawPreference* drawPreference, 722 DrawPreference* drawPreference,
(...skipping 3497 matching lines...) Expand 10 before | Expand all | Expand 10 after
4230 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4220 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4231 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4221 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4232 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4222 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4233 copyParams->fWidth = texture->width(); 4223 copyParams->fWidth = texture->width();
4234 copyParams->fHeight = texture->height(); 4224 copyParams->fHeight = texture->height();
4235 return true; 4225 return true;
4236 } 4226 }
4237 } 4227 }
4238 return false; 4228 return false;
4239 } 4229 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/vk/GrVkGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698