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

Commit 6e57f683 authored by Alec Mouri's avatar Alec Mouri
Browse files

First-pass for the new RenderEngine interface.

Includes separate test suite just for renderengine, so that we can test
against the interface directly.

I'll try to sync the interface definition in go/re-interface-cleanup
with whatever we land on here.

TODOs (future cls):
* Adding/deleting textures (move SF texture pool behind renderengine?)
* BufferLayer::bindTextureImage should probably move behind RE since
there's some duplicated code.

Bug: 117103231
Change-Id: Ib155b47c7c2ebbb9a23075a8534bd2842e846b9e
Test: test-renderengine
parent 98604181
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
      "name": "librenderengine_test"
    }
  ]
}
+7 −0
Original line number Diff line number Diff line
@@ -650,6 +650,13 @@ void GLES20RenderEngine::checkErrors() const {
    } while (true);
}

status_t GLES20RenderEngine::drawLayers(const DisplaySettings& /*settings*/,
                                        const std::vector<LayerSettings>& /*layers*/,
                                        ANativeWindowBuffer* const /*buffer*/,
                                        base::unique_fd* /*displayFence*/) const {
    return NO_ERROR;
}

void GLES20RenderEngine::setViewportAndProjection(size_t vpw, size_t vph, Rect sourceCrop,
                                                  ui::Transform::orientation_flags rotation) {
    int32_t l = sourceCrop.left;
+4 −0
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@ public:
    void unbindFrameBuffer(Framebuffer* framebuffer) override;
    void checkErrors() const override;

    status_t drawLayers(const DisplaySettings& settings, const std::vector<LayerSettings>& layers,
                        ANativeWindowBuffer* const buffer,
                        base::unique_fd* displayFence) const override;

    // internal to RenderEngine
    EGLDisplay getEGLDisplay() const { return mEGLDisplay; }
    EGLConfig getEGLConfig() const { return mEGLConfig; }
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <math/mat4.h>
#include <ui/GraphicTypes.h>
#include <ui/Rect.h>
#include <ui/Region.h>

namespace android {
namespace renderengine {

// DisplaySettings contains the settings that are applicable when drawing all
// layers for a given display.
struct DisplaySettings {
    // Rectangle describing the physical display. We will project from the
    // logical clip onto this rectangle.
    Rect physicalDisplay;

    // Rectangle bounded by the x,y- clipping planes in the logical display, so
    // that the orthographic projection matrix can be computed. When
    // constructing this matrix, z-coordinate bound are assumed to be at z=0 and
    // z=1.
    Rect clip;

    // Global transform to apply to all layers.
    mat4 globalTransform;

    // Maximum luminance pulled from the display's HDR capabilities.
    float maxLuminence;

    // Output dataspace that will be populated if wide color gamut is used, or
    // DataSpace::UNKNOWN otherwise.
    ui::Dataspace outputDataspace;

    // Additional color transform to apply in linear space after transforming
    // to the output dataspace.
    mat4 colorTransform;

    // Region that will be cleared to (0, 0, 0, 0) prior to rendering.
    // clearRegion will first be transformed by globalTransform so that it will
    // be in the same coordinate space as the rendered layers.
    Region clearRegion;
};

} // namespace renderengine
} // namespace android
+92 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <math/mat4.h>
#include <math/vec3.h>
#include <renderengine/Texture.h>
#include <ui/FloatRect.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicTypes.h>
#include <ui/Rect.h>
#include <ui/Region.h>
#include <ui/Transform.h>

namespace android {
namespace renderengine {

// Metadata describing the input buffer to render from.
struct Buffer {
    // Buffer containing the image that we will render.
    // If buffer == nullptr, then the rest of the fields in this struct will be
    // ignored.
    sp<GraphicBuffer> buffer;

    // Texture identifier to bind the external texture to.
    // TODO(alecmouri): This is GL-specific...make the type backend-agnostic.
    uint32_t textureName;

    // Whether to use filtering when rendering the texture.
    bool useTextureFiltering;

    // Transform matrix to apply to texture coordinates.
    mat4 textureTransform;

    // Wheteher to use pre-multiplied alpha
    bool usePremultipliedAlpha;

    // HDR color-space setting for Y410.
    bool isY410BT2020;
};

// Metadata describing the layer geometry.
struct Geometry {
    // Boundaries of the layer.
    FloatRect boundaries;

    // Transform matrix to apply to mesh coordinates.
    mat4 positionTransform;
};

// Descriptor of the source pixels for this layer.
struct PixelSource {
    // Source buffer
    Buffer buffer;

    // The solid color with which to fill the layer.
    // This should only be populated if we don't render from an application
    // buffer.
    half3 solidColor;
};

// The settings that RenderEngine requires for correctly rendering a Layer.
struct LayerSettings {
    // Geometry information
    Geometry geometry;

    // Source pixels for this layer.
    PixelSource source;

    // Alpha option to apply to the source pixels
    half alpha;

    // Color space describing how the source pixels should be interpreted.
    ui::Dataspace sourceDataspace;
};

} // namespace renderengine
} // namespace android
Loading