Merge "Convert Skia calls to use SkColorType/BackendFormats instead of GrPixelConfig."
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
index 365d740..b258bbd 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
@@ -66,20 +66,26 @@
FrameInfoVisualizer* profiler) {
mEglManager.damageFrame(frame, dirty);
+ SkColorType colorType;
// setup surface for fbo0
GrGLFramebufferInfo fboInfo;
fboInfo.fFBOID = 0;
- GrPixelConfig pixelConfig =
- wideColorGamut ? kRGBA_half_GrPixelConfig : kRGBA_8888_GrPixelConfig;
+ if (wideColorGamut) {
+ fboInfo.fFormat = GL_RGBA16F;
+ colorType = kRGBA_F16_SkColorType;
+ } else {
+ fboInfo.fFormat = GL_RGBA8;
+ colorType = kN32_SkColorType;
+ }
- GrBackendRenderTarget backendRT(frame.width(), frame.height(), 0, STENCIL_BUFFER_SIZE,
- pixelConfig, fboInfo);
+ GrBackendRenderTarget backendRT(frame.width(), frame.height(), 0, STENCIL_BUFFER_SIZE, fboInfo);
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
SkASSERT(mRenderThread.getGrContext() != nullptr);
sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(
- mRenderThread.getGrContext(), backendRT, kBottomLeft_GrSurfaceOrigin, nullptr, &props));
+ mRenderThread.getGrContext(), backendRT, kBottomLeft_GrSurfaceOrigin, colorType,
+ nullptr, &props));
SkiaPipeline::updateLighting(lightGeometry, lightInfo);
renderFrame(*layerUpdateQueue, dirty, renderNodes, opaque, wideColorGamut, contentDrawBounds,
@@ -285,7 +291,7 @@
type = GL_UNSIGNED_BYTE;
break;
case kRGBA_F16_SkColorType:
- isSupported = grContext->caps()->isConfigTexturable(kRGBA_half_GrPixelConfig);
+ isSupported = grContext->colorTypeSupportedAsImage(kRGBA_F16_SkColorType);
if (isSupported) {
type = GL_HALF_FLOAT;
pixelFormat = PIXEL_FORMAT_RGBA_FP16;
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
index 107890e..4393f45 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
@@ -50,32 +50,31 @@
grContext->resetContext();
}
- GrGLTextureInfo externalTexture;
- externalTexture.fTarget = GL_TEXTURE_EXTERNAL_OES;
- externalTexture.fID = sourceTexId;
-
- GrPixelConfig pixelConfig;
- switch (bitmap->colorType()) {
- case kRGBA_F16_SkColorType:
- pixelConfig = kRGBA_half_GrPixelConfig;
- break;
- case kN32_SkColorType:
- default:
- pixelConfig = kRGBA_8888_GrPixelConfig;
- break;
- }
-
- if (pixelConfig == kRGBA_half_GrPixelConfig &&
- !grContext->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig, false)) {
+ 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;
}
- GrBackendTexture backendTexture(imgWidth, imgHeight, pixelConfig, externalTexture);
+ GrGLTextureInfo externalTexture;
+ externalTexture.fTarget = GL_TEXTURE_EXTERNAL_OES;
+ externalTexture.fID = sourceTexId;
+ switch (bitmap->colorType()) {
+ case kRGBA_F16_SkColorType:
+ externalTexture.fFormat = GL_RGBA16F;
+ break;
+ case kN32_SkColorType:
+ default:
+ externalTexture.fFormat = GL_RGBA8;
+ break;
+ }
+
+ 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
diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp
index 21c91a2..ffe0578 100644
--- a/libs/hwui/renderthread/VulkanManager.cpp
+++ b/libs/hwui/renderthread/VulkanManager.cpp
@@ -320,7 +320,8 @@
VulkanSurface::ImageInfo& imageInfo = surface->mImageInfos[i];
imageInfo.mSurface = SkSurface::MakeFromBackendRenderTarget(
- mRenderThread.getGrContext(), backendRT, kTopLeft_GrSurfaceOrigin, nullptr, &props);
+ mRenderThread.getGrContext(), backendRT, kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType, nullptr, &props);
}
SkASSERT(mCommandPool != VK_NULL_HANDLE);