diff options
| author | 2021-04-27 19:06:28 +0000 | |
|---|---|---|
| committer | 2021-04-27 19:06:28 +0000 | |
| commit | b751ed6240983e1853539f26e1e5024aef0450af (patch) | |
| tree | 105ee156e022210492a7739e91cc29fafe52444b /libs | |
| parent | dd98e18be04ee346ffbee0ce991d2622059b7285 (diff) | |
| parent | 21e021f29ab5596fb9933a5469050158eb63e6ef (diff) | |
Merge "Cache shaders for layers that appear during certain app opens" into sc-dev
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/renderengine/skia/Cache.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libs/renderengine/skia/Cache.cpp b/libs/renderengine/skia/Cache.cpp index 1c2b2fc3ca..a0da888a81 100644 --- a/libs/renderengine/skia/Cache.cpp +++ b/libs/renderengine/skia/Cache.cpp @@ -37,12 +37,17 @@ const auto kScaleAndTranslate = mat4(0.7f, 0.f, 0.f, 0.f, 0.f, 0.7f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 67.3f, 52.2f, 0.f, 1.f); +const auto kScaleYOnly = mat4(1.f, 0.f, 0.f, 0.f, + 0.f, 0.7f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f); // clang-format on // When choosing dataspaces below, whether the match the destination or not determined whether // a color correction effect is added to the shader. There may be other additional shader details // for particular color spaces. // TODO(b/184842383) figure out which color related shaders are necessary constexpr auto kDestDataSpace = ui::Dataspace::SRGB; +constexpr auto kOtherDataSpace = ui::Dataspace::DISPLAY_P3; } // namespace static void drawShadowLayers(SkiaRenderEngine* renderengine, const DisplaySettings& display, @@ -182,6 +187,37 @@ static void drawBlurLayers(SkiaRenderEngine* renderengine, const DisplaySettings } } +static void drawTextureScaleLayers(SkiaRenderEngine* renderengine, const DisplaySettings& display, + const std::shared_ptr<ExternalTexture>& dstTexture, + const std::shared_ptr<ExternalTexture>& srcTexture) { + const Rect& displayRect = display.physicalDisplay; + FloatRect rect(0, 0, displayRect.width(), displayRect.height()); + LayerSettings layer{ + .geometry = + Geometry{ + .boundaries = rect, + .roundedCornersCrop = rect, + .positionTransform = kScaleAndTranslate, + .roundedCornersRadius = 300, + }, + .source = PixelSource{.buffer = + Buffer{ + .buffer = srcTexture, + .maxMasteringLuminance = 1000.f, + .maxContentLuminance = 1000.f, + .textureTransform = kScaleYOnly, + }}, + .sourceDataspace = kOtherDataSpace, + }; + + auto layers = std::vector<const LayerSettings*>{&layer}; + for (float alpha : {0.5f, 1.f}) { + layer.alpha = alpha, + renderengine->drawLayers(display, layers, dstTexture, kUseFrameBufferCache, + base::unique_fd(), nullptr); + } +} + // // The collection of shaders cached here were found by using perfetto to record shader compiles // during actions that involve RenderEngine, logging the layer settings, and the shader code @@ -250,6 +286,9 @@ void Cache::primeShaderCache(SkiaRenderEngine* renderengine) { // between 6 and 8 will occur in real uses. drawImageLayers(renderengine, display, dstTexture, externalTexture); + // Draw layers for b/185569240. + drawTextureScaleLayers(renderengine, display, dstTexture, externalTexture); + const nsecs_t timeAfter = systemTime(); const float compileTimeMs = static_cast<float>(timeAfter - timeBefore) / 1.0E6; const int shadersCompiled = renderengine->reportShadersCompiled(); |