Be more stringent about API failure cases in AsyncReadPixels test
Bug: skia:8962 Change-Id: I636d8d5c53a653c7b02bfe315e927c1e2fbc0ddf Reviewed-on: https://skia-review.googlesource.com/c/skia/+/222791 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
1d1e44f689
commit
624f9063c1
@ -1842,8 +1842,12 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
|
||||
callback(context, nullptr, 0);
|
||||
return;
|
||||
}
|
||||
// Fail if readCT does not have all of readCT's color channels.
|
||||
if (GrColorTypeComponentFlags(dstCT) & ~GrColorTypeComponentFlags(readInfo.fColorType)) {
|
||||
// Fail if read color type does not have all of dstCT's color channels and those missing color
|
||||
// channels are in the src.
|
||||
uint32_t dstComponents = GrColorTypeComponentFlags(dstCT);
|
||||
uint32_t legalReadComponents = GrColorTypeComponentFlags(readInfo.fColorType);
|
||||
uint32_t srcComponents = GrColorTypeComponentFlags(this->colorSpaceInfo().colorType());
|
||||
if ((~legalReadComponents & dstComponents) & srcComponents) {
|
||||
callback(context, nullptr, 0);
|
||||
return;
|
||||
}
|
||||
@ -1915,8 +1919,12 @@ GrRenderTargetContext::PixelTransferResult GrRenderTargetContext::transferPixels
|
||||
}
|
||||
auto supportedRead = this->caps()->supportedReadPixelsColorType(
|
||||
fRenderTargetProxy->config(), fRenderTargetProxy->backendFormat(), dstCT);
|
||||
// Fail if readCT does not have all of readCT's color channels.
|
||||
if (GrColorTypeComponentFlags(dstCT) & ~GrColorTypeComponentFlags(supportedRead.fColorType)) {
|
||||
// Fail if read color type does not have all of dstCT's color channels and those missing color
|
||||
// channels are in the src.
|
||||
uint32_t dstComponents = GrColorTypeComponentFlags(dstCT);
|
||||
uint32_t legalReadComponents = GrColorTypeComponentFlags(supportedRead.fColorType);
|
||||
uint32_t srcComponents = GrColorTypeComponentFlags(this->colorSpaceInfo().colorType());
|
||||
if ((~legalReadComponents & dstComponents) & srcComponents) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -743,7 +743,20 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AsyncReadPixels, reporter, ctxInfo) {
|
||||
if (rect.isEmpty() || !SkIRect::MakeWH(kW, kH).contains(rect)) {
|
||||
REPORTER_ASSERT(reporter, !context.fSuceeded);
|
||||
}
|
||||
if (!context.fSuceeded) {
|
||||
if (context.fSuceeded) {
|
||||
REPORTER_ASSERT(reporter, readCT != kUnknown_SkColorType &&
|
||||
!rect.isEmpty());
|
||||
} else {
|
||||
// TODO: Support reading to kGray.
|
||||
auto surfBounds = SkIRect::MakeWH(surf->width(), surf->height());
|
||||
if (readCT != kUnknown_SkColorType && readCT != kGray_8_SkColorType &&
|
||||
!rect.isEmpty() && surfBounds.contains(rect)) {
|
||||
ERRORF(reporter,
|
||||
"Async read failed. Surf Color Type: %d, Read CT: %d,"
|
||||
"Rect [%d, %d, %d, %d], origin: %d, CS conversion: %d\n",
|
||||
surfCT, readCT, rect.fLeft, rect.fTop, rect.fRight,
|
||||
rect.fBottom, origin, (bool)readCS);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// We use a synchronous read as the source of truth.
|
||||
|
Loading…
Reference in New Issue
Block a user