summaryrefslogtreecommitdiff
path: root/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp')
-rw-r--r--libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
index 107890e57a19..f2f5056bb195 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
@@ -26,6 +26,7 @@
#include "DeviceInfo.h"
#include "Matrix.h"
#include "Properties.h"
+#include "utils/MathUtils.h"
using namespace android::uirenderer::renderthread;
@@ -50,32 +51,31 @@ CopyResult SkiaOpenGLReadback::copyImageInto(EGLImageKHR eglImage, const Matrix4
grContext->resetContext();
}
+ if (bitmap->colorType() == kRGBA_F16_SkColorType &&
+ !grContext->colorTypeSupportedAsSurface(bitmap->colorType())) {
+ ALOGW("Can't copy surface into bitmap, RGBA_F16 config is not supported");
+ return CopyResult::DestinationInvalid;
+ }
+
GrGLTextureInfo externalTexture;
externalTexture.fTarget = GL_TEXTURE_EXTERNAL_OES;
externalTexture.fID = sourceTexId;
-
- GrPixelConfig pixelConfig;
switch (bitmap->colorType()) {
case kRGBA_F16_SkColorType:
- pixelConfig = kRGBA_half_GrPixelConfig;
+ externalTexture.fFormat = GL_RGBA16F;
break;
case kN32_SkColorType:
default:
- pixelConfig = kRGBA_8888_GrPixelConfig;
+ externalTexture.fFormat = GL_RGBA8;
break;
}
- if (pixelConfig == kRGBA_half_GrPixelConfig &&
- !grContext->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig, false)) {
- ALOGW("Can't copy surface into bitmap, RGBA_F16 config is not supported");
- return CopyResult::DestinationInvalid;
- }
-
- GrBackendTexture backendTexture(imgWidth, imgHeight, pixelConfig, externalTexture);
+ GrBackendTexture backendTexture(imgWidth, imgHeight, GrMipMapped::kNo, externalTexture);
CopyResult copyResult = CopyResult::UnknownError;
sk_sp<SkImage> image(SkImage::MakeFromAdoptedTexture(grContext.get(), backendTexture,
- kTopLeft_GrSurfaceOrigin));
+ kTopLeft_GrSurfaceOrigin,
+ bitmap->colorType()));
if (image) {
int displayedWidth = imgWidth, displayedHeight = imgHeight;
// If this is a 90 or 270 degree rotation we need to swap width/height to get the device
@@ -116,9 +116,9 @@ CopyResult SkiaOpenGLReadback::copyImageInto(EGLImageKHR eglImage, const Matrix4
paint.setBlendMode(SkBlendMode::kSrc);
// Apply a filter, which is matching OpenGL pipeline readback behaviour. Filter usage
// is codified by tests using golden images like DecodeAccuracyTest.
- if (skiaSrcRect.width() != bitmap->width() ||
- skiaSrcRect.height() != bitmap->height()) {
- // TODO: apply filter always, but check if tests will be fine
+ bool disableFilter = MathUtils::areEqual(skiaSrcRect.width(), skiaDestRect.width())
+ && MathUtils::areEqual(skiaSrcRect.height(), skiaDestRect.height());
+ if (!disableFilter) {
paint.setFilterQuality(kLow_SkFilterQuality);
}
scaledSurface->getCanvas()->concat(textureMatrix);
@@ -137,6 +137,8 @@ CopyResult SkiaOpenGLReadback::copyImageInto(EGLImageKHR eglImage, const Matrix4
// make sure that we have deleted the texture (in the SkImage) before we
// destroy the EGLImage that it was created from
image.reset();
+ glFinish();
+
return copyResult;
}