Revert "Make GrDirectContext::updateBackendTexture handle pixmaps with non-type row bytes."
This reverts commit 07d8c0d11cae593c46b2fbc0507b8c07cff9000f.
Reason for revert: Looks like failures on PowerVR? (Test-Android-Clang-TecnoSpark3Pro-GPU-PowerVRGE8320-arm-Release-All-Android)
Original change's description:
> Make GrDirectContext::updateBackendTexture handle pixmaps with non-type row bytes.
>
> Some GL contexts don't support GL_UNPACK_ROW_LENGTH and we must
> copy the src data to a pixmap with tight row bytes.
>
> Bug: chromium:1170392
>
> Change-Id: I4590f20dbc80cb792f30f0059536716cf106f6c3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361717
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,robertphillips@google.com
Change-Id: Ie5791bf19b993d46383c5b837b948584487c0496
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1170392
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363037
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp
index f34d124..fbb78ea 100644
--- a/tests/BackendAllocationTest.cpp
+++ b/tests/BackendAllocationTest.cpp
@@ -425,31 +425,16 @@
}
}
-static int make_pixmaps(SkColorType skColorType,
- GrMipmapped mipmapped,
- const SkColor4f colors[6],
- SkPixmap pixmaps[6],
- std::unique_ptr<char[]>* mem) {
+static int make_pixmaps(SkColorType skColorType, GrMipmapped mipMapped,
+ const SkColor4f colors[6], SkAutoPixmapStorage pixmaps[6]) {
int levelSize = 32;
- int numMipLevels = mipmapped == GrMipmapped::kYes ? 6 : 1;
- size_t size = 0;
- SkImageInfo ii[6];
- size_t rowBytes[6];
+ int numMipLevels = mipMapped == GrMipmapped::kYes ? 6 : 1;
for (int level = 0; level < numMipLevels; ++level) {
- ii[level] = SkImageInfo::Make(levelSize, levelSize, skColorType, kUnpremul_SkAlphaType);
- rowBytes[level] = ii[level].minRowBytes();
- // Make sure we test row bytes that aren't tight.
- if (!(level % 2)) {
- rowBytes[level] += (level + 1)*SkColorTypeBytesPerPixel(ii[level].colorType());
- }
- size += rowBytes[level]*ii[level].height();
- levelSize /= 2;
- }
- mem->reset(new char[size]);
- char* addr = mem->get();
- for (int level = 0; level < numMipLevels; ++level) {
- pixmaps[level].reset(ii[level], addr, rowBytes[level]);
- addr += rowBytes[level]*ii[level].height();
+ SkImageInfo ii = SkImageInfo::Make(levelSize,
+ levelSize,
+ skColorType,
+ kUnpremul_SkAlphaType);
+ pixmaps[level].alloc(ii);
pixmaps[level].erase(colors[level]);
levelSize /= 2;
}
@@ -466,10 +451,9 @@
GrRenderable)> create,
SkColorType skColorType,
GrSurfaceOrigin origin,
- GrMipmapped mipmapped,
+ GrMipmapped mipMapped,
GrRenderable renderable) {
- SkPixmap pixmaps[6];
- std::unique_ptr<char[]> memForPixmaps;
+ SkAutoPixmapStorage pixmapMem[6];
SkColor4f colors[6] = {
{ 1.0f, 0.0f, 0.0f, 1.0f }, // R
{ 0.0f, 1.0f, 0.0f, 0.9f }, // G
@@ -479,9 +463,15 @@
{ 1.0f, 1.0f, 0.0f, 0.2f }, // Y
};
- int numMipLevels = make_pixmaps(skColorType, mipmapped, colors, pixmaps, &memForPixmaps);
+ int numMipLevels = make_pixmaps(skColorType, mipMapped, colors, pixmapMem);
SkASSERT(numMipLevels);
+ // TODO: this is tedious. Should we pass in an array of SkBitmaps instead?
+ SkPixmap pixmaps[6];
+ for (int i = 0; i < numMipLevels; ++i) {
+ pixmaps[i].reset(pixmapMem[i].info(), pixmapMem[i].addr(), pixmapMem[i].rowBytes());
+ }
+
sk_sp<ManagedBackendTexture> mbet = create(dContext, pixmaps, numMipLevels, origin, renderable);
if (!mbet) {
// errors here should be reported by the test_wrapping test
@@ -495,7 +485,7 @@
auto checkBackendTexture = [&](SkColor4f colors[6]) {
GrColorType grColorType = SkColorTypeToGrColorType(skColorType);
- if (mipmapped == GrMipmapped::kYes) {
+ if (mipMapped == GrMipmapped::kYes) {
SkColor4f expectedColors[6] = {
get_expected_color(colors[0], grColorType),
get_expected_color(colors[1], grColorType),
@@ -524,7 +514,10 @@
{0.0f, 1.0f, 1.0f, 0.5f}, // C
{1.0f, 0.0f, 1.0f, 0.3f}, // M
};
- make_pixmaps(skColorType, mipmapped, colorsNew, pixmaps, &memForPixmaps);
+ make_pixmaps(skColorType, mipMapped, colorsNew, pixmapMem);
+ for (int i = 0; i < numMipLevels; ++i) {
+ pixmaps[i].reset(pixmapMem[i].info(), pixmapMem[i].addr(), pixmapMem[i].rowBytes());
+ }
// Upload new data and make sure everything still works
dContext->updateBackendTexture(mbet->texture(),
@@ -567,8 +560,7 @@
}
///////////////////////////////////////////////////////////////////////////////
-void color_type_backend_allocation_test(const sk_gpu_test::ContextInfo& ctxInfo,
- skiatest::Reporter* reporter) {
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctxInfo) {
auto context = ctxInfo.directContext();
const GrCaps* caps = context->priv().caps();
@@ -726,31 +718,6 @@
}
}
-DEF_GPUTEST(ColorTypeBackendAllocationTest, reporter, options) {
- for (int t = 0; t < sk_gpu_test::GrContextFactory::kContextTypeCnt; ++t) {
- auto type = static_cast<sk_gpu_test::GrContextFactory::ContextType>(t);
- if (!sk_gpu_test::GrContextFactory::IsRenderingContext(type)) {
- continue;
- }
- sk_gpu_test::GrContextFactory factory(options);
- sk_gpu_test::ContextInfo info = factory.getContextInfo(type);
- if (!info.directContext()) {
- continue;
- }
- color_type_backend_allocation_test(info, reporter);
- // The GL backend must support contexts that don't allow GL_UNPACK_ROW_LENGTH. Other
- // backends are not required to work with this cap disabled.
- if (info.directContext()->priv().caps()->writePixelsRowBytesSupport() &&
- info.directContext()->backend() == GrBackendApi::kOpenGL) {
- GrContextOptions overrideOptions = options;
- overrideOptions.fDisallowWritePixelRowBytes = true;
- sk_gpu_test::GrContextFactory overrideFactory(overrideOptions);
- info = overrideFactory.getContextInfo(type);
- color_type_backend_allocation_test(info, reporter);
- }
- }
-}
-
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_GL