Reland "Move ExternalFormat and Type to FormatInfo."
This reverts commit e2c5e8c7eeb07a7c2de566851956027cf6c12b07.
Reason for revert: relanding with fix
Original change's description:
> Revert "Move ExternalFormat and Type to FormatInfo."
>
> This reverts commit 80140518ef7627d103e7d80fec599c052280053a.
>
> Reason for revert: probably breaking angle
>
> Original change's description:
> > Move ExternalFormat and Type to FormatInfo.
> >
> > This also deletes the ConfigInfoTable in GrGLCaps as there is no more use
> > of it.
> >
> > Additionally with the rework of storing External Io info on the format table
> > I rewrote the implimination of supportedReadPixels and supportedWritePixels
> > for GL to loop over the supported types looking for a match instead of
> > simply defaulting to a base value.
> >
> > Finally transferFromOffsetAlignment has been rolled into the SupportedRead
> > instead of being its own query.
> >
> > Bug: skia:6718
> > Change-Id: I39f77adf6c0b5b38245e55e8a7e18c0b428862d0
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229381
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: Ifef2e7308fdb4d91d649f08488b798815e0aa5fa
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:6718
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229896
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: Ida09be706b461cf89467fc0082744177e71e8985
Bug: skia:6718
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229918
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 8c99f24..b6fd67f 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -296,32 +296,6 @@
return surface->readOnly() ? false : this->onSurfaceSupportsWritePixels(surface);
}
-size_t GrCaps::transferFromOffsetAlignment(GrColorType bufferColorType) const {
- if (!this->transferBufferSupport()) {
- return 0;
- }
- size_t result = this->onTransferFromOffsetAlignment(bufferColorType);
- if (!result) {
- return 0;
- }
- // It's very convenient to access 1 byte-per-channel 32 bitvRGB/RGBA color types as uint32_t.
- // Make those aligned reads out of the buffer even if the underlying API doesn't require it.
- auto componentFlags = GrColorTypeComponentFlags(bufferColorType);
- if ((componentFlags == kRGBA_SkColorTypeComponentFlags ||
- componentFlags == kRGB_SkColorTypeComponentFlags) &&
- GrColorTypeBytesPerPixel(bufferColorType) == 4) {
- switch (result & 0b11) {
- // offset alignment already a multiple of 4
- case 0: return result;
- // offset alignment is a multiple of 2 but not 4.
- case 2: return 2 * result;
- // offset alignment is not a multiple of 2.
- default: return 4 * result;
- }
- }
- return result;
-}
-
bool GrCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
const SkIRect& srcRect, const SkIPoint& dstPoint) const {
if (dst->readOnly()) {
@@ -377,9 +351,35 @@
}
GrCaps::SupportedRead GrCaps::supportedReadPixelsColorType(GrColorType srcColorType,
- const GrBackendFormat&,
+ const GrBackendFormat& srcFormat,
GrColorType dstColorType) const {
- return SupportedRead{GrSwizzle::RGBA(), srcColorType};
+ SupportedRead read = this->onSupportedReadPixelsColorType(srcColorType, srcFormat,
+ dstColorType);
+
+ // There are known problems with 24 vs 32 bit BPP with this color type. Just fail for now if
+ // using a transfer buffer.
+ if (GrColorType::kRGB_888x == read.fColorType) {
+ read.fOffsetAlignmentForTransferBuffer = 0;
+ }
+ // It's very convenient to access 1 byte-per-channel 32 bitvRGB/RGBA color types as uint32_t.
+ // Make those aligned reads out of the buffer even if the underlying API doesn't require it.
+ auto componentFlags = GrColorTypeComponentFlags(read.fColorType);
+ if ((componentFlags == kRGBA_SkColorTypeComponentFlags ||
+ componentFlags == kRGB_SkColorTypeComponentFlags) &&
+ GrColorTypeBytesPerPixel(read.fColorType) == 4) {
+ switch (read.fOffsetAlignmentForTransferBuffer & 0b11) {
+ // offset alignment already a multiple of 4
+ case 0:
+ break;
+ // offset alignment is a multiple of 2 but not 4.
+ case 2:
+ read.fOffsetAlignmentForTransferBuffer *= 2;
+ // offset alignment is not a multiple of 2.
+ default:
+ read.fOffsetAlignmentForTransferBuffer *= 4;
+ }
+ }
+ return read;
}
#ifdef SK_DEBUG