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

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

Snap for 4826885 from b46d5b2d to pi-release

Change-Id: I28d7d98dd2f98a088767c01007d0453ecebb8c7b
parents 4c798c91 b46d5b2d
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -815,6 +815,13 @@ bool BufferLayer::getOpacityForFormat(uint32_t format) {
    return true;
}

bool BufferLayer::isHdrY410() const {
    // pixel format is HDR Y410 masquerading as RGBA_1010102
    return (mCurrentDataSpace == ui::Dataspace::BT2020_ITU_PQ &&
            mConsumer->getCurrentApi() == NATIVE_WINDOW_API_MEDIA &&
            getBE().compositionInfo.mBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102);
}

void BufferLayer::drawWithOpenGL(const RenderArea& renderArea, bool useIdentityTransform) const {
    ATRACE_CALL();
    const State& s(getDrawingState());
@@ -868,9 +875,7 @@ void BufferLayer::drawWithOpenGL(const RenderArea& renderArea, bool useIdentityT
                              getColor());
    engine.setSourceDataSpace(mCurrentDataSpace);

    if (mCurrentDataSpace == ui::Dataspace::BT2020_ITU_PQ &&
        mConsumer->getCurrentApi() == NATIVE_WINDOW_API_MEDIA &&
        getBE().compositionInfo.mBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102) {
    if (isHdrY410()) {
        engine.setSourceY410BT2020(true);
    }

+2 −0
Original line number Diff line number Diff line
@@ -129,6 +129,8 @@ public:
    bool isBufferLatched() const override { return mRefreshPending; }
    void setDefaultBufferSize(uint32_t w, uint32_t h) override;

    bool isHdrY410() const override;

    void setPerFrameData(const sp<const DisplayDevice>& displayDevice) override;

    bool isOpaque(const Layer::State& s) const override;
+2 −0
Original line number Diff line number Diff line
@@ -378,6 +378,8 @@ protected:
public:
    virtual void setDefaultBufferSize(uint32_t /*w*/, uint32_t /*h*/) {}

    virtual bool isHdrY410() const { return false; }

    void setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z);
    void forceClientComposition(int32_t hwcId);
    bool getForceClientComposition(int32_t hwcId);
+4 −1
Original line number Diff line number Diff line
@@ -112,7 +112,10 @@ namespace impl {
using ui::Dataspace;

GLES20RenderEngine::GLES20RenderEngine(uint32_t featureFlags)
      : mVpWidth(0), mVpHeight(0), mPlatformHasWideColor((featureFlags & WIDE_COLOR_SUPPORT) != 0) {
      : RenderEngine(featureFlags),
        mVpWidth(0),
        mVpHeight(0),
        mPlatformHasWideColor((featureFlags & WIDE_COLOR_SUPPORT) != 0) {
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);

+30 −8
Original line number Diff line number Diff line
@@ -14,10 +14,13 @@
 * limitations under the License.
 */

#define ATRACE_TAG ATRACE_TAG_GRAPHICS

#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>

#include <utils/String8.h>
#include <utils/Trace.h>

#include "Description.h"
#include "Program.h"
@@ -75,15 +78,11 @@ Formatter& dedent(Formatter& f) {

ANDROID_SINGLETON_STATIC_INSTANCE(ProgramCache)

ProgramCache::ProgramCache() {
    // Until surfaceflinger has a dependable blob cache on the filesystem,
    // generate shaders on initialization so as to avoid jank.
    primeCache();
}
ProgramCache::ProgramCache() {}

ProgramCache::~ProgramCache() {}

void ProgramCache::primeCache() {
void ProgramCache::primeCache(bool hasWideColor) {
    uint32_t shaderCount = 0;
    uint32_t keyMask = Key::BLEND_MASK | Key::OPACITY_MASK | Key::ALPHA_MASK | Key::TEXTURE_MASK;
    // Prime the cache for all combinations of the above masks,
@@ -104,6 +103,27 @@ void ProgramCache::primeCache() {
            shaderCount++;
        }
    }

    // Prime for sRGB->P3 conversion
    if (hasWideColor) {
        Key shaderKey;
        shaderKey.set(Key::BLEND_MASK | Key::TEXTURE_MASK | Key::OUTPUT_TRANSFORM_MATRIX_MASK |
                              Key::INPUT_TF_MASK | Key::OUTPUT_TF_MASK,
                      Key::BLEND_PREMULT | Key::TEXTURE_EXT | Key::OUTPUT_TRANSFORM_MATRIX_ON |
                              Key::INPUT_TF_SRGB | Key::OUTPUT_TF_SRGB);
        for (int i = 0; i < 4; i++) {
            shaderKey.set(Key::OPACITY_MASK,
                          (i & 1) ? Key::OPACITY_OPAQUE : Key::OPACITY_TRANSLUCENT);
            shaderKey.set(Key::ALPHA_MASK, (i & 2) ? Key::ALPHA_LT_ONE : Key::ALPHA_EQ_ONE);
            Program* program = mCache.valueFor(shaderKey);
            if (program == nullptr) {
                program = generateProgram(shaderKey);
                mCache.add(shaderKey, program);
                shaderCount++;
            }
        }
    }

    nsecs_t timeAfter = systemTime();
    float compileTimeMs = static_cast<float>(timeAfter - timeBefore) / 1.0E6;
    ALOGD("shader cache generated - %u shaders in %f ms\n", shaderCount, compileTimeMs);
@@ -631,6 +651,8 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) {
}

Program* ProgramCache::generateProgram(const Key& needs) {
    ATRACE_CALL();

    // vertex shader
    String8 vs = generateVertexShader(needs);

@@ -654,8 +676,8 @@ void ProgramCache::useProgram(const Description& description) {
        mCache.add(needs, program);
        time += systemTime();

        // ALOGD(">>> generated new program: needs=%08X, time=%u ms (%d programs)",
        //        needs.mNeeds, uint32_t(ns2ms(time)), mCache.size());
        ALOGV(">>> generated new program: needs=%08X, time=%u ms (%zu programs)", needs.mKey,
              uint32_t(ns2ms(time)), mCache.size());
    }

    // here we have a suitable program for this description
Loading