Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b6c1035 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7394644 from 72b639e7 to sc-d1-release

Change-Id: I11303614f9268ff4aab65da35e65b10a969b6dff
parents 649fbc5b 72b639e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ enum class InputDeviceSensorReportingMode : int32_t {
};

enum class InputDeviceLightType : int32_t {
    SINGLE = 0,
    MONO = 0,
    PLAYER_ID = 1,
    RGB = 2,
    MULTI_COLOR = 3,
+2 −1
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@ narayan@google.com
patb@google.com
svetoslavganov@google.com
toddke@google.com
patb@google.com
 No newline at end of file
+0 −3
Original line number Diff line number Diff line
@@ -14,9 +14,6 @@
 * limitations under the License.
 */

// TODO(b/183120308): This file is a copy of f/b/libs/hwui/utils/TraceUtils.h
//  It should be migrated to a common place where both SF and hwui could use it.

#pragma once

#include <cutils/trace.h>
+16 −4
Original line number Diff line number Diff line
@@ -107,6 +107,9 @@ struct PixelSource {
 * material design guidelines.
 */
struct ShadowSettings {
    // Boundaries of the shadow.
    FloatRect boundaries = FloatRect();

    // Color to the ambient shadow. The alpha is premultiplied.
    vec4 ambientColor = vec4();

@@ -150,6 +153,10 @@ struct LayerSettings {
    // True if blending will be forced to be disabled.
    bool disableBlending = false;

    // If true, then this layer casts a shadow and/or blurs behind it, but it does
    // not otherwise draw any of the layer's other contents.
    bool skipContentDraw = false;

    ShadowSettings shadow;

    int backgroundBlurRadius = 0;
@@ -189,9 +196,10 @@ static inline bool operator==(const PixelSource& lhs, const PixelSource& rhs) {
}

static inline bool operator==(const ShadowSettings& lhs, const ShadowSettings& rhs) {
    return lhs.ambientColor == rhs.ambientColor && lhs.spotColor == rhs.spotColor &&
            lhs.lightPos == rhs.lightPos && lhs.lightRadius == rhs.lightRadius &&
            lhs.length == rhs.length && lhs.casterIsTranslucent == rhs.casterIsTranslucent;
    return lhs.boundaries == rhs.boundaries && lhs.ambientColor == rhs.ambientColor &&
            lhs.spotColor == rhs.spotColor && lhs.lightPos == rhs.lightPos &&
            lhs.lightRadius == rhs.lightRadius && lhs.length == rhs.length &&
            lhs.casterIsTranslucent == rhs.casterIsTranslucent;
}

static inline bool operator==(const LayerSettings& lhs, const LayerSettings& rhs) {
@@ -208,7 +216,8 @@ static inline bool operator==(const LayerSettings& lhs, const LayerSettings& rhs
    return lhs.geometry == rhs.geometry && lhs.source == rhs.source && lhs.alpha == rhs.alpha &&
            lhs.sourceDataspace == rhs.sourceDataspace &&
            lhs.colorTransform == rhs.colorTransform &&
            lhs.disableBlending == rhs.disableBlending && lhs.shadow == rhs.shadow &&
            lhs.disableBlending == rhs.disableBlending &&
            lhs.skipContentDraw == rhs.skipContentDraw && lhs.shadow == rhs.shadow &&
            lhs.backgroundBlurRadius == rhs.backgroundBlurRadius &&
            lhs.blurRegionTransform == rhs.blurRegionTransform &&
            lhs.stretchEffect == rhs.stretchEffect;
@@ -251,6 +260,8 @@ static inline void PrintTo(const PixelSource& settings, ::std::ostream* os) {

static inline void PrintTo(const ShadowSettings& settings, ::std::ostream* os) {
    *os << "ShadowSettings {";
    *os << "\n    .boundaries = ";
    PrintTo(settings.boundaries, os);
    *os << "\n    .ambientColor = " << settings.ambientColor;
    *os << "\n    .spotColor = " << settings.spotColor;
    *os << "\n    .lightPos = " << settings.lightPos;
@@ -286,6 +297,7 @@ static inline void PrintTo(const LayerSettings& settings, ::std::ostream* os) {
    PrintTo(settings.sourceDataspace, os);
    *os << "\n    .colorTransform = " << settings.colorTransform;
    *os << "\n    .disableBlending = " << settings.disableBlending;
    *os << "\n    .skipContentDraw = " << settings.skipContentDraw;
    *os << "\n    .backgroundBlurRadius = " << settings.backgroundBlurRadius;
    for (auto blurRegion : settings.blurRegions) {
        *os << "\n";
+28 −18
Original line number Diff line number Diff line
@@ -505,10 +505,11 @@ void SkiaGLRenderEngine::mapExternalTextureBuffer(const sp<GraphicBuffer>& buffe
    if (mRenderEngineType != RenderEngineType::SKIA_GL_THREADED) {
        return;
    }
    // we currently don't attempt to map a buffer if the buffer contains protected content
    // because GPU resources for protected buffers is much more limited.
    // We currently don't attempt to map a buffer if the buffer contains protected content
    // or we are using a protected context because GPU resources for protected buffers is
    // much more limited.
    const bool isProtectedBuffer = buffer->getUsage() & GRALLOC_USAGE_PROTECTED;
    if (isProtectedBuffer) {
    if (isProtectedBuffer || mInProtectedContext) {
        return;
    }
    ATRACE_CALL();
@@ -517,7 +518,7 @@ void SkiaGLRenderEngine::mapExternalTextureBuffer(const sp<GraphicBuffer>& buffe
    // bound context if we are not already using the protected context (and subsequently switch
    // back after the buffer is cached).
    auto grContext = getActiveGrContext();
    auto& cache = mInProtectedContext ? mProtectedTextureCache : mTextureCache;
    auto& cache = mTextureCache;

    std::lock_guard<std::mutex> lock(mRenderingMutex);
    mGraphicBufferExternalRefs[buffer->getId()]++;
@@ -846,7 +847,9 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
        // Layers have a local transform that should be applied to them
        canvas->concat(getSkM44(layer->geometry.positionTransform).asM33());

        const auto [bounds, roundRectClip] = getBoundsAndClip(layer);
        const auto [bounds, roundRectClip] =
                getBoundsAndClip(layer->geometry.boundaries, layer->geometry.roundedCornersCrop,
                                 layer->geometry.roundedCornersRadius);
        if (mBlurFilter && layerHasBlur(layer)) {
            std::unordered_map<uint32_t, sk_sp<SkImage>> cachedBlurs;

@@ -895,14 +898,21 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
            }
        }

        // Shadows are assumed to live only on their own layer - it's not valid
        // to draw the boundary rectangles when there is already a caster shadow
        // TODO(b/175915334): consider relaxing this restriction to enable more flexible
        // composition - using a well-defined invalid color is long-term less error-prone.
        if (layer->shadow.length > 0) {
            // This would require a new parameter/flag to SkShadowUtils::DrawShadow
            LOG_ALWAYS_FATAL_IF(layer->disableBlending, "Cannot disableBlending with a shadow");

            SkRRect shadowBounds, shadowClip;
            if (layer->geometry.boundaries == layer->shadow.boundaries) {
                shadowBounds = bounds;
                shadowClip = roundRectClip;
            } else {
                std::tie(shadowBounds, shadowClip) =
                        getBoundsAndClip(layer->shadow.boundaries,
                                         layer->geometry.roundedCornersCrop,
                                         layer->geometry.roundedCornersRadius);
            }

            // Technically, if bounds is a rect and roundRectClip is not empty,
            // it means that the bounds and roundedCornersCrop were different
            // enough that we should intersect them to find the proper shadow.
@@ -910,9 +920,8 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
            // not match due to rounding errors. Draw the rounded version, which
            // looks more like the intent.
            const auto& rrect =
                    bounds.isRect() && !roundRectClip.isEmpty() ? roundRectClip : bounds;
                    shadowBounds.isRect() && !shadowClip.isEmpty() ? shadowClip : shadowBounds;
            drawShadow(canvas, rrect, layer->shadow);
            continue;
        }

        const bool requiresLinearEffect = layer->colorTransform != mat4() ||
@@ -922,8 +931,9 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
                 display.sdrWhitePointNits != display.maxLuminance);

        // quick abort from drawing the remaining portion of the layer
        if (layer->alpha == 0 && !requiresLinearEffect && !layer->disableBlending &&
            (!displayColorTransform || displayColorTransform->isAlphaUnchanged())) {
        if (layer->skipContentDraw ||
            (layer->alpha == 0 && !requiresLinearEffect && !layer->disableBlending &&
             (!displayColorTransform || displayColorTransform->isAlphaUnchanged()))) {
            continue;
        }

@@ -1093,11 +1103,11 @@ inline SkRect SkiaGLRenderEngine::getSkRect(const Rect& rect) {
    return SkRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom);
}

inline std::pair<SkRRect, SkRRect> SkiaGLRenderEngine::getBoundsAndClip(
        const LayerSettings* layer) {
    const auto bounds = getSkRect(layer->geometry.boundaries);
    const auto crop = getSkRect(layer->geometry.roundedCornersCrop);
    const auto cornerRadius = layer->geometry.roundedCornersRadius;
inline std::pair<SkRRect, SkRRect> SkiaGLRenderEngine::getBoundsAndClip(const FloatRect& boundsRect,
                                                                        const FloatRect& cropRect,
                                                                        const float cornerRadius) {
    const SkRect bounds = getSkRect(boundsRect);
    const SkRect crop = getSkRect(cropRect);

    SkRRect clip;
    if (cornerRadius > 0) {
Loading