OSDN Git Service

Use F16 render target when wide color rendering is enabled
authorStan Iliev <stani@google.com>
Mon, 24 Jul 2017 14:20:33 +0000 (10:20 -0400)
committerStan Iliev <stani@google.com>
Wed, 26 Jul 2017 13:27:29 +0000 (09:27 -0400)
Support F16 render targets in Skia pipeline. Enable readback from
F16 surface.

Test: device boots with Skia pipeline
Change-Id: Ib31e618be1a987de3736987a496c799693923594

libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp
libs/hwui/pipeline/skia/SkiaOpenGLReadback.cpp
libs/hwui/pipeline/skia/SkiaPipeline.cpp

index 925db30..bf77446 100644 (file)
@@ -73,9 +73,11 @@ bool SkiaOpenGLPipeline::draw(const Frame& frame, const SkRect& screenDirty,
     // setup surface for fbo0
     GrGLFramebufferInfo fboInfo;
     fboInfo.fFBOID = 0;
+    GrPixelConfig pixelConfig =
+            wideColorGamut ? kRGBA_half_GrPixelConfig : kRGBA_8888_GrPixelConfig;
 
     GrBackendRenderTarget backendRT(frame.width(), frame.height(), 0, STENCIL_BUFFER_SIZE,
-            kRGBA_8888_GrPixelConfig, fboInfo);
+            pixelConfig, fboInfo);
 
     SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
 
index 311419d..e9b55e5 100644 (file)
@@ -54,7 +54,18 @@ CopyResult SkiaOpenGLReadback::copyImageInto(EGLImageKHR eglImage, const Matrix4
     externalTexture.fTarget = GL_TEXTURE_EXTERNAL_OES;
     externalTexture.fID = sourceTexId;
 
-    GrBackendTexture backendTexture(imgWidth, imgHeight, kRGBA_8888_GrPixelConfig, externalTexture);
+    GrPixelConfig pixelConfig;
+    switch (bitmap->colorType()) {
+    case kRGBA_F16_SkColorType:
+        pixelConfig = kRGBA_half_GrPixelConfig;
+        break;
+    case kN32_SkColorType:
+    default:
+        pixelConfig = kRGBA_8888_GrPixelConfig;
+        break;
+    }
+
+    GrBackendTexture backendTexture(imgWidth, imgHeight, pixelConfig, externalTexture);
 
     CopyResult copyResult = CopyResult::UnknownError;
     sk_sp<SkImage> image(SkImage::MakeFromAdoptedTexture(grContext.get(), backendTexture,
index 03792e0..d08a62c 100644 (file)
@@ -134,7 +134,13 @@ bool SkiaPipeline::createOrUpdateLayer(RenderNode* node,
         const DamageAccumulator& damageAccumulator, bool wideColorGamut) {
     SkSurface* layer = node->getLayerSurface();
     if (!layer || layer->width() != node->getWidth() || layer->height() != node->getHeight()) {
-        SkImageInfo info = SkImageInfo::MakeN32Premul(node->getWidth(), node->getHeight());
+        SkImageInfo info;
+        if (wideColorGamut) {
+            info = SkImageInfo::Make(node->getWidth(), node->getHeight(), kRGBA_F16_SkColorType,
+                    kPremul_SkAlphaType);
+        } else {
+            info = SkImageInfo::MakeN32Premul(node->getWidth(), node->getHeight());
+        }
         SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
         SkASSERT(mRenderThread.getGrContext() != nullptr);
         // TODO: Handle wide color gamut requests