Add kRGBA_8888_SRGB GrColorType and remove GrSRGBEncoded.
Change-Id: Iad1c72eb81ffd9c006e39c96191fada990d9dbd6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/226224
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp
index 77fd908..2883c52 100644
--- a/tests/BackendAllocationTest.cpp
+++ b/tests/BackendAllocationTest.cpp
@@ -574,7 +574,6 @@
kRGBA_16161616_GrPixelConfig, SkColors::kLtGray },
{ kUnknown_SkColorType, GR_GL_RG16F,
kRG_half_GrPixelConfig, SkColors::kYellow },
-
};
for (auto combo : combinations) {
@@ -593,7 +592,17 @@
// We current disallow uninitialized ETC1 textures in the GL backend
continue;
}
- if (!glCaps->isFormatTexturable(SkColorTypeToGrColorType(combo.fColorType), format)) {
+
+ GrColorType grCT = SkColorTypeToGrColorType(combo.fColorType);
+ // TODO: Once SkColorType has an SRGB type we can remove this manual setting.
+ if (glCaps->isFormatSRGB(format)) {
+ if (grCT != GrColorType::kRGBA_8888) {
+ continue;
+ }
+ grCT = GrColorType::kRGBA_8888_SRGB;
+ }
+
+ if (!glCaps->isFormatTexturable(grCT, format)) {
continue;
}
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 7aeb29e..2829b76 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -134,10 +134,8 @@
REPORTER_ASSERT(reporter, SkToBool(tex) == ict,
"config:%d, tex:%d, isConfigTexturable:%d", config, SkToBool(tex), ict);
- GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
- GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(config, &srgbEncoded);
- const GrBackendFormat format =
- caps->getBackendFormatFromColorType(colorType, srgbEncoded);
+ GrColorType colorType = GrPixelConfigToColorType(config);
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(colorType);
if (!format.isValid()) {
continue;
}
@@ -241,11 +239,8 @@
if (desc.fConfig == kRGB_888X_GrPixelConfig) {
continue;
}
- GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
- GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(desc.fConfig,
- &srgbEncoded);
- const GrBackendFormat format =
- caps->getBackendFormatFromColorType(colorType, srgbEncoded);
+ GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(colorType);
// Try creating the texture as a deferred proxy.
for (int i = 0; i < 2; ++i) {
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index f42f378..6604c56 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -130,8 +130,7 @@
, fTest(test)
, fAtlas(atlas) {
const GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(GrColorType::kAlpha_F16,
- GrSRGBEncoded::kNo);
+ ctx->priv().caps()->getBackendFormatFromColorType(GrColorType::kAlpha_F16);
fLazyProxy = GrProxyProvider::MakeFullyLazyProxy(
[this](GrResourceProvider* rp) -> GrSurfaceProxy::LazyInstantiationResult {
REPORTER_ASSERT(fTest->fReporter, !fTest->fHasClipTexture);
diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp
index 95a7a33..0a5bb36 100644
--- a/tests/ProxyConversionTest.cpp
+++ b/tests/ProxyConversionTest.cpp
@@ -26,8 +26,7 @@
GrSurfaceOrigin origin) {
// We don't currently have a way of making MSAA backend render targets.
SkASSERT(1 == desc.fSampleCnt);
- GrSRGBEncoded srgbEncoded;
- auto ct = GrPixelConfigToColorTypeAndEncoding(desc.fConfig, &srgbEncoded);
+ auto ct = GrPixelConfigToColorType(desc.fConfig);
auto backendRT = gpu->createTestingOnlyBackendRenderTarget(desc.fWidth, desc.fHeight, ct);
return provider->wrapBackendRenderTarget(backendRT, origin, nullptr, nullptr);
}
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 0babeb4..aa0c4c7 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -117,7 +117,7 @@
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
for (auto numSamples : {1, 4, 16, 128}) {
- auto config = GrColorTypeToPixelConfig(ct, GrSRGBEncoded::kNo);
+ auto config = GrColorTypeToPixelConfig(ct);
SkASSERT(kUnknown_GrPixelConfig != config);
GrSurfaceDesc desc;
@@ -127,8 +127,7 @@
desc.fConfig = config;
desc.fSampleCnt = numSamples;
- const GrBackendFormat format =
- caps.getBackendFormatFromColorType(ct, GrSRGBEncoded::kNo);
+ const GrBackendFormat format = caps.getBackendFormatFromColorType(ct);
if (!format.isValid()) {
continue;
}
@@ -240,7 +239,7 @@
}
for (auto numSamples : {1, 4}) {
- GrPixelConfig config = GrColorTypeToPixelConfig(grColorType, GrSRGBEncoded::kNo);
+ GrPixelConfig config = GrColorTypeToPixelConfig(grColorType);
SkASSERT(kUnknown_GrPixelConfig != config);
int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config);
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 3cfa1eb..4d365d2 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -158,12 +158,11 @@
static constexpr struct {
GrColorType fColorType;
SkAlphaType fAlphaType;
- GrSRGBEncoded fSRGBEncoded;
} kInfos[] = {
- {GrColorType::kRGBA_8888, kPremul_SkAlphaType, GrSRGBEncoded::kNo},
- {GrColorType::kBGRA_8888, kPremul_SkAlphaType, GrSRGBEncoded::kNo},
- {GrColorType::kRGBA_8888, kPremul_SkAlphaType, GrSRGBEncoded::kYes},
- {GrColorType::kRGBA_1010102, kPremul_SkAlphaType, GrSRGBEncoded::kNo},
+ {GrColorType::kRGBA_8888, kPremul_SkAlphaType},
+ {GrColorType::kBGRA_8888, kPremul_SkAlphaType},
+ {GrColorType::kRGBA_8888_SRGB, kPremul_SkAlphaType},
+ {GrColorType::kRGBA_1010102, kPremul_SkAlphaType},
};
for (int y = 0; y < Y_SIZE; ++y) {
@@ -191,8 +190,8 @@
auto origin = GrRenderable::kYes == renderable ? kBottomLeft_GrSurfaceOrigin
: kTopLeft_GrSurfaceOrigin;
auto proxy = sk_gpu_test::MakeTextureProxyFromData(
- context, renderable, X_SIZE, Y_SIZE, info.fColorType, info.fAlphaType,
- info.fSRGBEncoded, origin, rgbaData, 0);
+ context, renderable, X_SIZE, Y_SIZE, info.fColorType, info.fAlphaType, origin,
+ rgbaData, 0);
if (!proxy) {
continue;
}
diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp
index 42a0c5f..3e7bd79 100644
--- a/tests/ResourceAllocatorTest.cpp
+++ b/tests/ResourceAllocatorTest.cpp
@@ -35,7 +35,7 @@
static sk_sp<GrSurfaceProxy> make_deferred(GrProxyProvider* proxyProvider, const GrCaps* caps,
const ProxyParams& p) {
GrColorType grCT = SkColorTypeToGrColorType(p.fColorType);
- GrPixelConfig config = GrColorTypeToPixelConfig(grCT, GrSRGBEncoded::kNo);
+ GrPixelConfig config = GrColorTypeToPixelConfig(grCT);
GrSurfaceDesc desc;
desc.fFlags = p.fIsRT ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
@@ -270,7 +270,7 @@
sk_sp<GrSurfaceProxy> make_lazy(GrProxyProvider* proxyProvider, const GrCaps* caps,
const ProxyParams& p, bool deinstantiate) {
GrColorType grCT = SkColorTypeToGrColorType(p.fColorType);
- GrPixelConfig config = GrColorTypeToPixelConfig(grCT, GrSRGBEncoded::kNo);
+ GrPixelConfig config = GrColorTypeToPixelConfig(grCT);
GrSurfaceDesc desc;
desc.fFlags = p.fIsRT ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index e148620..765805e 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -163,15 +163,6 @@
return nullptr;
}
-static GrPixelConfig encoding_as_pixel_config(Encoding encoding) {
- switch (encoding) {
- case Encoding::kUntagged: return kRGBA_8888_GrPixelConfig;
- case Encoding::kLinear: return kRGBA_8888_GrPixelConfig;
- case Encoding::kSRGB: return kSRGBA_8888_GrPixelConfig;
- }
- return kUnknown_GrPixelConfig;
-}
-
static const char* encoding_as_str(Encoding encoding) {
switch (encoding) {
case Encoding::kUntagged: return "untagged";
@@ -200,12 +191,10 @@
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = kW;
desc.fHeight = kH;
- desc.fConfig = encoding_as_pixel_config(contextEncoding);
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
- GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
- GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(desc.fConfig, &srgbEncoded);
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(colorType, srgbEncoded);
+ GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
+ const GrBackendFormat format = context->priv().caps()->getBackendFormatFromColorType(colorType);
auto surfaceContext = context->priv().makeDeferredSurfaceContext(
format, desc, kBottomLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp
index 0da2096..fdfda42 100644
--- a/tests/TransferPixelsTest.cpp
+++ b/tests/TransferPixelsTest.cpp
@@ -98,88 +98,81 @@
memcpy(data, srcBuffer.get(), size);
buffer->unmap();
- for (auto srgbEncoding : {GrSRGBEncoded::kNo, GrSRGBEncoded::kYes}) {
- // create texture
- GrSurfaceDesc desc;
- desc.fFlags = renderTarget ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
- desc.fWidth = kTextureWidth;
- desc.fHeight = kTextureHeight;
- desc.fConfig = GrColorTypeToPixelConfig(colorType, srgbEncoding);
- desc.fSampleCnt = 1;
+ // create texture
+ GrSurfaceDesc desc;
+ desc.fFlags = renderTarget ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
+ desc.fWidth = kTextureWidth;
+ desc.fHeight = kTextureHeight;
+ desc.fConfig = GrColorTypeToPixelConfig(colorType);
+ desc.fSampleCnt = 1;
- if (kUnknown_GrPixelConfig == desc.fConfig) {
- SkASSERT(GrSRGBEncoded::kYes == srgbEncoding);
- continue;
- }
+ if (!context->priv().caps()->isConfigTexturable(desc.fConfig) ||
+ (renderTarget && !context->priv().caps()->isConfigRenderable(desc.fConfig))) {
+ return;
+ }
- if (!context->priv().caps()->isConfigTexturable(desc.fConfig) ||
- (renderTarget && !context->priv().caps()->isConfigRenderable(desc.fConfig))) {
- continue;
- }
+ sk_sp<GrTexture> tex = resourceProvider->createTexture(
+ desc, SkBudgeted::kNo, GrResourceProvider::Flags::kNoPendingIO);
+ if (!tex) {
+ return;
+ }
- sk_sp<GrTexture> tex = resourceProvider->createTexture(
- desc, SkBudgeted::kNo, GrResourceProvider::Flags::kNoPendingIO);
- if (!tex) {
- continue;
- }
+ //////////////////////////
+ // transfer full data
- //////////////////////////
- // transfer full data
+ bool result;
+ result = gpu->transferPixelsTo(tex.get(), 0, 0, kTextureWidth, kTextureHeight, colorType,
+ buffer.get(), 0, rowBytes);
+ REPORTER_ASSERT(reporter, result);
- bool result;
- result = gpu->transferPixelsTo(tex.get(), 0, 0, kTextureWidth, kTextureHeight, colorType,
- buffer.get(), 0, rowBytes);
- REPORTER_ASSERT(reporter, result);
+ memset(dstBuffer.get(), 0xCDCD, size);
+ result = gpu->readPixels(tex.get(), 0, 0, kTextureWidth, kTextureHeight, colorType,
+ dstBuffer.get(), rowBytes);
+ if (result) {
+ REPORTER_ASSERT(reporter, do_buffers_contain_same_values(srcBuffer,
+ dstBuffer,
+ kTextureWidth,
+ kTextureHeight,
+ rowBytes,
+ rowBytes,
+ false));
+ }
- memset(dstBuffer.get(), 0xCDCD, size);
- result = gpu->readPixels(tex.get(), 0, 0, kTextureWidth, kTextureHeight, colorType,
- dstBuffer.get(), rowBytes);
- if (result) {
- REPORTER_ASSERT(reporter, do_buffers_contain_same_values(srcBuffer,
- dstBuffer,
- kTextureWidth,
- kTextureHeight,
- rowBytes,
- rowBytes,
- false));
- }
-
- //////////////////////////
- // transfer partial data
+ //////////////////////////
+ // transfer partial data
#ifdef SK_BUILD_FOR_IOS
- // UNPACK_ROW_LENGTH is broken on iOS so we can't do partial transfers
- if (GrBackendApi::kOpenGL == context->backend()) {
- continue;
- }
+ // UNPACK_ROW_LENGTH is broken on iOS so we can't do partial transfers
+ if (GrBackendApi::kOpenGL == context->backend()) {
+ return;
+ }
#endif
- const int kLeft = 2;
- const int kTop = 10;
- const int kWidth = 10;
- const int kHeight = 2;
+ const int kLeft = 2;
+ const int kTop = 10;
+ const int kWidth = 10;
+ const int kHeight = 2;
- // change color of subrectangle
- fill_transfer_data(kLeft, kTop, kWidth, kHeight, kBufferWidth, srcBuffer.get());
- data = buffer->map();
- memcpy(data, srcBuffer.get(), size);
- buffer->unmap();
+ // change color of subrectangle
+ fill_transfer_data(kLeft, kTop, kWidth, kHeight, kBufferWidth, srcBuffer.get());
+ data = buffer->map();
+ memcpy(data, srcBuffer.get(), size);
+ buffer->unmap();
- size_t offset = sizeof(GrColor) * (kTop * kBufferWidth + kLeft);
- result = gpu->transferPixelsTo(tex.get(), kLeft, kTop, kWidth, kHeight, colorType,
- buffer.get(), offset, rowBytes);
- REPORTER_ASSERT(reporter, result);
+ size_t offset = sizeof(GrColor) * (kTop * kBufferWidth + kLeft);
+ result = gpu->transferPixelsTo(tex.get(), kLeft, kTop, kWidth, kHeight, colorType,
+ buffer.get(), offset, rowBytes);
+ REPORTER_ASSERT(reporter, result);
- memset(dstBuffer.get(), 0xCDCD, size);
- result = gpu->readPixels(tex.get(), 0, 0, kTextureWidth, kTextureHeight, colorType,
- dstBuffer.get(), rowBytes);
- if (result) {
- REPORTER_ASSERT(reporter, do_buffers_contain_same_values(srcBuffer,
- dstBuffer,
- kTextureWidth,
- kTextureHeight,
- rowBytes,
- rowBytes,
- false));
- }
+ memset(dstBuffer.get(), 0xCDCD, size);
+ result = gpu->readPixels(tex.get(), 0, 0, kTextureWidth, kTextureHeight, colorType,
+ dstBuffer.get(), rowBytes);
+ if (result) {
+ REPORTER_ASSERT(reporter, do_buffers_contain_same_values(srcBuffer,
+ dstBuffer,
+ kTextureWidth,
+ kTextureHeight,
+ rowBytes,
+ rowBytes,
+ false));
}
}
@@ -232,102 +225,95 @@
int expectedTransferCnt = 0;
gpu->stats()->reset();
- for (auto srgbEncoding : {GrSRGBEncoded::kNo, GrSRGBEncoded::kYes}) {
- // create texture
- GrSurfaceDesc desc;
- desc.fFlags = renderTarget ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
- desc.fWidth = kTextureWidth;
- desc.fHeight = kTextureHeight;
- desc.fConfig = GrColorTypeToPixelConfig(colorType, srgbEncoding);
- desc.fSampleCnt = 1;
+ // create texture
+ GrSurfaceDesc desc;
+ desc.fFlags = renderTarget ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
+ desc.fWidth = kTextureWidth;
+ desc.fHeight = kTextureHeight;
+ desc.fConfig = GrColorTypeToPixelConfig(colorType);
+ desc.fSampleCnt = 1;
- if (kUnknown_GrPixelConfig == desc.fConfig) {
- SkASSERT(GrSRGBEncoded::kYes == srgbEncoding);
- continue;
- }
-
- if (!context->priv().caps()->isConfigTexturable(desc.fConfig) ||
- (renderTarget && !context->priv().caps()->isConfigRenderable(desc.fConfig))) {
- continue;
- }
-
- SkAutoTMalloc<GrColor> textureData(kTextureWidth * kTextureHeight);
- size_t textureDataRowBytes = kTextureWidth * sizeof(GrColor);
- fill_transfer_data(0, 0, kTextureWidth, kTextureHeight, kTextureWidth, textureData.get());
- GrMipLevel data;
- data.fPixels = textureData.get();
- data.fRowBytes = kTextureWidth * sizeof(GrColor);
- sk_sp<GrTexture> tex = resourceProvider->createTexture(desc, SkBudgeted::kNo, &data, 1);
- if (!tex) {
- continue;
- }
-
- //////////////////////////
- // transfer full data
- bool result = gpu->transferPixelsFrom(tex.get(), 0, 0, kTextureWidth, kTextureHeight,
- readColorType, buffer.get(), 0);
- if (!result) {
- ERRORF(reporter, "transferPixelsFrom failed.");
- continue;
- }
- ++expectedTransferCnt;
-
- GrFlushInfo flushInfo;
- flushInfo.fFlags = kSyncCpu_GrFlushFlag;
- if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
- gpu->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo,
- GrPrepareForExternalIORequests());
- }
-
- const auto* map = reinterpret_cast<const GrColor*>(buffer->map());
- REPORTER_ASSERT(reporter, map);
- if (!map) {
- continue;
- }
- REPORTER_ASSERT(reporter, do_buffers_contain_same_values(textureData.get(),
- map,
- kTextureWidth,
- kTextureHeight,
- textureDataRowBytes,
- fullBufferRowBytes,
- readColorType != colorType));
- buffer->unmap();
-
- ///////////////////////
- // Now test a partial read at an offset into the buffer.
- result = gpu->transferPixelsFrom(tex.get(), kPartialLeft, kPartialTop, kPartialWidth,
- kPartialHeight, readColorType, buffer.get(),
- partialReadOffset);
- if (!result) {
- ERRORF(reporter, "transferPixelsFrom failed.");
- continue;
- }
- ++expectedTransferCnt;
-
- if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
- gpu->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo,
- GrPrepareForExternalIORequests());
- }
-
- map = reinterpret_cast<const GrColor*>(buffer->map());
- REPORTER_ASSERT(reporter, map);
- if (!map) {
- continue;
- }
- const GrColor* textureDataStart = reinterpret_cast<const GrColor*>(
- reinterpret_cast<const char*>(textureData.get()) +
- textureDataRowBytes * kPartialTop + sizeof(GrColor) * kPartialLeft);
- const GrColor* bufferStart = reinterpret_cast<const GrColor*>(
- reinterpret_cast<const char*>(map) + partialReadOffset);
- REPORTER_ASSERT(reporter, do_buffers_contain_same_values(textureDataStart,
- bufferStart,
- kPartialWidth,
- kPartialHeight,
- textureDataRowBytes,
- partialBufferRowBytes,
- readColorType != colorType));
- buffer->unmap();
+ if (!context->priv().caps()->isConfigTexturable(desc.fConfig) ||
+ (renderTarget && !context->priv().caps()->isConfigRenderable(desc.fConfig))) {
+ return;
}
+
+ SkAutoTMalloc<GrColor> textureData(kTextureWidth * kTextureHeight);
+ size_t textureDataRowBytes = kTextureWidth * sizeof(GrColor);
+ fill_transfer_data(0, 0, kTextureWidth, kTextureHeight, kTextureWidth, textureData.get());
+ GrMipLevel data;
+ data.fPixels = textureData.get();
+ data.fRowBytes = kTextureWidth * sizeof(GrColor);
+ sk_sp<GrTexture> tex = resourceProvider->createTexture(desc, SkBudgeted::kNo, &data, 1);
+ if (!tex) {
+ return;
+ }
+
+ //////////////////////////
+ // transfer full data
+ bool result = gpu->transferPixelsFrom(tex.get(), 0, 0, kTextureWidth, kTextureHeight,
+ readColorType, buffer.get(), 0);
+ if (!result) {
+ ERRORF(reporter, "transferPixelsFrom failed.");
+ return;
+ }
+ ++expectedTransferCnt;
+
+ GrFlushInfo flushInfo;
+ flushInfo.fFlags = kSyncCpu_GrFlushFlag;
+ if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
+ gpu->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo,
+ GrPrepareForExternalIORequests());
+ }
+
+ const auto* map = reinterpret_cast<const GrColor*>(buffer->map());
+ REPORTER_ASSERT(reporter, map);
+ if (!map) {
+ return;
+ }
+ REPORTER_ASSERT(reporter, do_buffers_contain_same_values(textureData.get(),
+ map,
+ kTextureWidth,
+ kTextureHeight,
+ textureDataRowBytes,
+ fullBufferRowBytes,
+ readColorType != colorType));
+ buffer->unmap();
+
+ ///////////////////////
+ // Now test a partial read at an offset into the buffer.
+ result = gpu->transferPixelsFrom(tex.get(), kPartialLeft, kPartialTop, kPartialWidth,
+ kPartialHeight, readColorType, buffer.get(),
+ partialReadOffset);
+ if (!result) {
+ ERRORF(reporter, "transferPixelsFrom failed.");
+ return;
+ }
+ ++expectedTransferCnt;
+
+ if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
+ gpu->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo,
+ GrPrepareForExternalIORequests());
+ }
+
+ map = reinterpret_cast<const GrColor*>(buffer->map());
+ REPORTER_ASSERT(reporter, map);
+ if (!map) {
+ return;
+ }
+ const GrColor* textureDataStart = reinterpret_cast<const GrColor*>(
+ reinterpret_cast<const char*>(textureData.get()) +
+ textureDataRowBytes * kPartialTop + sizeof(GrColor) * kPartialLeft);
+ const GrColor* bufferStart = reinterpret_cast<const GrColor*>(
+ reinterpret_cast<const char*>(map) + partialReadOffset);
+ REPORTER_ASSERT(reporter, do_buffers_contain_same_values(textureDataStart,
+ bufferStart,
+ kPartialWidth,
+ kPartialHeight,
+ textureDataRowBytes,
+ partialBufferRowBytes,
+ readColorType != colorType));
+ buffer->unmap();
#if GR_GPU_STATS
REPORTER_ASSERT(reporter, gpu->stats()->transfersFromSurface() == expectedTransferCnt);
#else
@@ -342,6 +328,8 @@
// RGBA
basic_transfer_to_test(reporter, ctxInfo.grContext(), GrColorType::kRGBA_8888, false);
basic_transfer_to_test(reporter, ctxInfo.grContext(), GrColorType::kRGBA_8888, true);
+ basic_transfer_to_test(reporter, ctxInfo.grContext(), GrColorType::kRGBA_8888_SRGB, false);
+ basic_transfer_to_test(reporter, ctxInfo.grContext(), GrColorType::kRGBA_8888_SRGB, true);
// BGRA
basic_transfer_to_test(reporter, ctxInfo.grContext(), GrColorType::kBGRA_8888, false);
@@ -356,6 +344,8 @@
// RGBA
basic_transfer_from_test(reporter, ctxInfo, GrColorType::kRGBA_8888, false);
basic_transfer_from_test(reporter, ctxInfo, GrColorType::kRGBA_8888, true);
+ basic_transfer_from_test(reporter, ctxInfo, GrColorType::kRGBA_8888_SRGB, false);
+ basic_transfer_from_test(reporter, ctxInfo, GrColorType::kRGBA_8888_SRGB, true);
// BGRA
basic_transfer_from_test(reporter, ctxInfo, GrColorType::kBGRA_8888, false);