Fix CtsViewTestCases when running on swiftshader emulators.
Test: CtsViewTestCases
Bug: 64478761
Change-Id: Ie85d25054c2f426cc88cf512c166c175b894a8fe
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
index e932c3c..df94092 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
@@ -16,6 +16,7 @@
#include "SkiaOpenGLReadback.h"
+#include "DeviceInfo.h"
#include "Matrix.h"
#include "Properties.h"
#include <SkCanvas.h>
@@ -65,6 +66,18 @@
break;
}
+ /* Ideally, we would call grContext->caps()->isConfigRenderable(...). We
+ * currently can't do that since some devices (i.e. SwiftShader) supports all
+ * the appropriate half float extensions, but only allow the buffer to be read
+ * back as full floats. We can relax this extension if Skia implements support
+ * for reading back float buffers (skbug.com/6945).
+ */
+ if (pixelConfig == kRGBA_half_GrPixelConfig &&
+ !DeviceInfo::get()->extensions().hasFloatTextures()) {
+ ALOGW("Can't copy surface into bitmap, RGBA_F16 config is not supported");
+ return CopyResult::DestinationInvalid;
+ }
+
GrBackendTexture backendTexture(imgWidth, imgHeight, pixelConfig, externalTexture);
CopyResult copyResult = CopyResult::UnknownError;