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

Unified Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1709163003: Add wrapBackendTextureAsRenderTarget API (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Remove assert that is no longer true Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« include/gpu/GrTextureProvider.h ('K') | « src/gpu/gl/GrGLGpu.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLGpu.cpp
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 73d219d03323dcc863786736df427dd4ad7e0348..08abde98953e1cd22b7facb11a365a99699d69ef 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -657,6 +657,74 @@ GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
return GrGLRenderTarget::CreateWrapped(this, desc, idDesc, wrapDesc.fStencilBits);
}
+GrRenderTarget* GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc,
+ GrWrapOwnership ownership) {
+#ifdef SK_IGNORE_GL_TEXTURE_TARGET
+ if (!desc.fTextureHandle) {
+ return nullptr;
+ }
+#else
+ const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc.fTextureHandle);
+ if (!info || !info->fID) {
+ return nullptr;
+ }
+#endif
+
+ 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.
+ if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
+ return nullptr;
+ }
+
+ GrGLTexture::IDDesc idDesc;
+ GrSurfaceDesc surfDesc;
+
+#ifdef SK_IGNORE_GL_TEXTURE_TARGET
+ idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle);
+ // We only support GL_TEXTURE_2D at the moment.
+ idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
+#else
+ idDesc.fInfo = *info;
+#endif
+
+ if (GR_GL_TEXTURE_RECTANGLE != idDesc.fInfo.fTarget &&
+ GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) {
+ // Only texture rectangle and texture 2d are supported. We do not check whether texture
+ // rectangle is supported by Skia - if the caller provided us with a texture rectangle,
+ // we assume the necessary support exists.
+ return nullptr;
+ }
+
+ switch (ownership) {
+ case kAdopt_GrWrapOwnership:
+ idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle;
+ break;
+ case kBorrow_GrWrapOwnership:
+ idDesc.fLifeCycle = GrGpuResource::kBorrowed_LifeCycle;
+ break;
+ }
+
+ surfDesc.fFlags = (GrSurfaceFlags) desc.fFlags;
+ surfDesc.fWidth = desc.fWidth;
+ surfDesc.fHeight = desc.fHeight;
+ surfDesc.fConfig = desc.fConfig;
+ surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount());
+ // FIXME: this should be calling resolve_origin(), but Chrome code is currently
+ // assuming the old behaviour, which is that backend textures are always
+ // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to:
+ // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget);
+ if (kDefault_GrSurfaceOrigin == desc.fOrigin) {
+ surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+ } else {
+ surfDesc.fOrigin = desc.fOrigin;
+ }
+
+ GrGLRenderTarget::IDDesc rtIDDesc;
+ if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_LifeCycle,
+ idDesc.fInfo, &rtIDDesc)) {
+ return nullptr;
+ }
+ return GrGLRenderTarget::CreateWrapped(this, surfDesc, rtIDDesc, 0);
+}
////////////////////////////////////////////////////////////////////////////////
bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
GrPixelConfig srcConfig,
@@ -1534,9 +1602,6 @@ bool GrGLGpu::createTextureExternalAllocatorImpl(
GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
int width,
int height) {
- // All internally created RTs are also textures. We don't create
- // SBs for a client's standalone RT (that is a RT that isn't also a texture).
- SkASSERT(rt->asTexture());
SkASSERT(width >= rt->width());
SkASSERT(height >= rt->height());
« include/gpu/GrTextureProvider.h ('K') | « src/gpu/gl/GrGLGpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698