Modify GrGLTexture/RenderTarget and related functions to not take
GrSurfaceDesc.
Change-Id: If853cff7624ec80e0152a28766dda188778913d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/232577
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index a7784e9..d588335 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -20,49 +20,52 @@
// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
// Constructor for wrapped render targets.
GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
- const GrSurfaceDesc& desc,
+ const SkISize& size,
+ GrGLFormat format,
+ GrPixelConfig config,
int sampleCount,
- GrGLenum format,
- const IDDesc& idDesc,
+ const IDs& ids,
GrGLStencilAttachment* stencil)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCount, GrProtected::kNo,
- stencil) {
- this->setFlags(gpu->glCaps(), idDesc);
- this->init(desc, format, idDesc);
+ : GrSurface(gpu, size, config, GrProtected::kNo)
+ , INHERITED(gpu, size, config, sampleCount, GrProtected::kNo, stencil) {
+ this->setFlags(gpu->glCaps(), ids);
+ this->init(format, ids);
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
}
-GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, int sampleCount,
- GrGLenum format, const IDDesc& idDesc)
- : GrSurface(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, GrProtected::kNo)
- , INHERITED(gpu, {desc.fWidth, desc.fHeight}, desc.fConfig, sampleCount, GrProtected::kNo) {
- this->setFlags(gpu->glCaps(), idDesc);
- this->init(desc, format, idDesc);
+GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
+ const SkISize& size,
+ GrGLFormat format,
+ GrPixelConfig config,
+ int sampleCount,
+ const IDs& ids)
+ : GrSurface(gpu, size, config, GrProtected::kNo)
+ , INHERITED(gpu, size, config, sampleCount, GrProtected::kNo) {
+ this->setFlags(gpu->glCaps(), ids);
+ this->init(format, ids);
}
-inline void GrGLRenderTarget::setFlags(const GrGLCaps& glCaps, const IDDesc& idDesc) {
+inline void GrGLRenderTarget::setFlags(const GrGLCaps& glCaps, const IDs& idDesc) {
if (!idDesc.fRTFBOID) {
this->setGLRTFBOIDIs0();
}
}
-void GrGLRenderTarget::init(const GrSurfaceDesc& desc, GrGLenum format, const IDDesc& idDesc) {
- fRTFBOID = idDesc.fRTFBOID;
- fTexFBOID = idDesc.fTexFBOID;
- fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
- fRTFBOOwnership = idDesc.fRTFBOOwnership;
-
- fRTFormat = format;
-
+void GrGLRenderTarget::init(GrGLFormat format, const IDs& idDesc) {
+ fRTFBOID = idDesc.fRTFBOID;
+ fTexFBOID = idDesc.fTexFBOID;
+ fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
+ fRTFBOOwnership = idDesc.fRTFBOOwnership;
+ fRTFormat = format;
fNumSamplesOwnedPerPixel = this->totalSamples();
}
sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu,
- const GrSurfaceDesc& desc,
+ const SkISize& size,
+ GrGLFormat format,
+ GrPixelConfig config,
int sampleCount,
- GrGLenum format,
- const IDDesc& idDesc,
+ const IDs& idDesc,
int stencilBits) {
GrGLStencilAttachment* sb = nullptr;
if (stencilBits) {
@@ -73,10 +76,11 @@
format.fStencilBits = stencilBits;
format.fTotalBits = stencilBits;
// Ownership of sb is passed to the GrRenderTarget so doesn't need to be deleted
- sb = new GrGLStencilAttachment(gpu, sbDesc, desc.fWidth, desc.fHeight, sampleCount, format);
+ sb = new GrGLStencilAttachment(gpu, sbDesc, size.width(), size.height(), sampleCount,
+ format);
}
return sk_sp<GrGLRenderTarget>(
- new GrGLRenderTarget(gpu, desc, sampleCount, format, idDesc, sb));
+ new GrGLRenderTarget(gpu, size, format, config, sampleCount, idDesc, sb));
}
GrBackendRenderTarget GrGLRenderTarget::getBackendRenderTarget() const {
@@ -95,7 +99,7 @@
GrBackendFormat GrGLRenderTarget::backendFormat() const {
// We should never have a GrGLRenderTarget (even a textureable one with a target that is not
// texture 2D.
- return GrBackendFormat::MakeGL(fRTFormat, GR_GL_TEXTURE_2D);
+ return GrBackendFormat::MakeGL(GrGLFormatToEnum(fRTFormat), GR_GL_TEXTURE_2D);
}
size_t GrGLRenderTarget::onGpuMemorySize() const {