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

Commit 1d2ac86f authored by Romain Guy's avatar Romain Guy Committed by android-build-merger
Browse files

Merge "Use RGBA16F layers when wide color gamut rendering is on" into oc-dr1-dev am: 9ae7bb7a

am: feb16096

Change-Id: Icc5ea6789affa4c8cf09051add0ed78fe2a2e9d1
parents d33c6a63 feb16096
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ namespace uirenderer {
OffscreenBuffer* BakedOpRenderer::startTemporaryLayer(uint32_t width, uint32_t height) {
    LOG_ALWAYS_FATAL_IF(mRenderTarget.offscreenBuffer, "already has layer...");

    OffscreenBuffer* buffer = mRenderState.layerPool().get(mRenderState, width, height);
    OffscreenBuffer* buffer = mRenderState.layerPool().get(
            mRenderState, width, height, mWideColorGamut);
    startRepaintLayer(buffer, Rect(width, height));
    return buffer;
}
@@ -103,7 +104,8 @@ void BakedOpRenderer::endLayer() {
OffscreenBuffer* BakedOpRenderer::copyToLayer(const Rect& area) {
    const uint32_t width = area.getWidth();
    const uint32_t height = area.getHeight();
    OffscreenBuffer* buffer = mRenderState.layerPool().get(mRenderState, width, height);
    OffscreenBuffer* buffer = mRenderState.layerPool().get(
            mRenderState, width, height, mWideColorGamut);
    if (!area.isEmpty() && width != 0 && height != 0) {
        mCaches.textureState().activateTexture(0);
        mCaches.textureState().bindTexture(buffer->texture.id());
+3 −1
Original line number Diff line number Diff line
@@ -54,12 +54,13 @@ public:
        uint8_t spotShadowAlpha;
    };

    BakedOpRenderer(Caches& caches, RenderState& renderState, bool opaque,
    BakedOpRenderer(Caches& caches, RenderState& renderState, bool opaque, bool wideColorGamut,
            const LightInfo& lightInfo)
            : mGlopReceiver(DefaultGlopReceiver)
            , mRenderState(renderState)
            , mCaches(caches)
            , mOpaque(opaque)
            , mWideColorGamut(wideColorGamut)
            , mLightInfo(lightInfo) {
    }

@@ -118,6 +119,7 @@ private:
    RenderState& mRenderState;
    Caches& mCaches;
    bool mOpaque;
    bool mWideColorGamut;
    bool mHasDrawn = false;

    // render target state - setup by start/end layer/frame
+11 −2
Original line number Diff line number Diff line
@@ -120,6 +120,10 @@ void Texture::resetCachedParams() {
void Texture::upload(GLint internalFormat, uint32_t width, uint32_t height,
        GLenum format, GLenum type, const void* pixels) {
    GL_CHECKPOINT(MODERATE);

    // We don't have color space information, we assume the data is gamma encoded
    mIsLinear = false;

    bool needsAlloc = updateLayout(width, height, internalFormat, format, GL_TEXTURE_2D);
    if (!mId) {
        glGenTextures(1, &mId);
@@ -309,11 +313,16 @@ void Texture::upload(Bitmap& bitmap) {
    bool rgba16fNeedsConversion = bitmap.colorType() == kRGBA_F16_SkColorType
            && internalFormat != GL_RGBA16F;

    // RGBA16F is always linear extended sRGB
    if (internalFormat == GL_RGBA16F) {
        mIsLinear = true;
    }

    mConnector.reset();

    // RGBA16F is always extended sRGB, alpha masks don't have color profiles
    // Alpha masks don't have color profiles
    // If an RGBA16F bitmap needs conversion, we know the target will be sRGB
    if (internalFormat != GL_RGBA16F && internalFormat != GL_ALPHA && !rgba16fNeedsConversion) {
    if (!mIsLinear && internalFormat != GL_ALPHA && !rgba16fNeedsConversion) {
        SkColorSpace* colorSpace = bitmap.info().colorSpace();
        // If the bitmap is sRGB we don't need conversion
        if (colorSpace != nullptr && !colorSpace->isSRGB()) {
+6 −2
Original line number Diff line number Diff line
@@ -88,7 +88,8 @@ public:
     * The image data is undefined after calling this.
     */
    void resize(uint32_t width, uint32_t height, GLint internalFormat, GLint format) {
        upload(internalFormat, width, height, format, GL_UNSIGNED_BYTE, nullptr);
        upload(internalFormat, width, height, format,
                internalFormat == GL_RGBA16F ? GL_HALF_FLOAT : GL_UNSIGNED_BYTE, nullptr);
    }

    /**
@@ -155,7 +156,7 @@ public:
     * Returns true if this texture uses a linear encoding format.
     */
    constexpr bool isLinear() const {
        return mInternalFormat == GL_RGBA16F;
        return mIsLinear;
    }

    /**
@@ -219,6 +220,9 @@ private:
    GLenum mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
    GLenum mMagFilter = GL_LINEAR;

    // Indicates whether the content of the texture is in linear space
    bool mIsLinear = false;

    Caches& mCaches;

    std::unique_ptr<ColorSpaceConnector> mConnector;
+3 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ bool SkiaOpenGLPipeline::draw(const Frame& frame, const SkRect& screenDirty,
        const SkRect& dirty,
        const FrameBuilder::LightGeometry& lightGeometry,
        LayerUpdateQueue* layerUpdateQueue,
        const Rect& contentDrawBounds, bool opaque,
        const Rect& contentDrawBounds, bool opaque, bool wideColorGamut,
        const BakedOpRenderer::LightInfo& lightInfo,
        const std::vector<sp<RenderNode>>& renderNodes,
        FrameInfoVisualizer* profiler) {
@@ -85,7 +85,8 @@ bool SkiaOpenGLPipeline::draw(const Frame& frame, const SkRect& screenDirty,
            mRenderThread.getGrContext(), renderTargetDesc, &props));

    SkiaPipeline::updateLighting(lightGeometry, lightInfo);
    renderFrame(*layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds, surface);
    renderFrame(*layerUpdateQueue, dirty, renderNodes, opaque, wideColorGamut,
            contentDrawBounds, surface);
    layerUpdateQueue->clear();

    // Draw visual debugging features
Loading