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

Commit bbd72f67 authored by Melody Hsu's avatar Melody Hsu Committed by Android (Google) Code Review
Browse files

Merge "Extract RenderArea elements into screenshot args" into main

parents 0d5b25bf 5b3d9765
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -206,7 +206,6 @@ filegroup {
        "Display/DisplayModeController.cpp",
        "Display/DisplaySnapshot.cpp",
        "DisplayDevice.cpp",
        "DisplayRenderArea.cpp",
        "Effects/Daltonizer.cpp",
        "FpsReporter.cpp",
        "FrameTracer/FrameTracer.cpp",
@@ -225,12 +224,10 @@ filegroup {
        "Layer.cpp",
        "LayerFE.cpp",
        "LayerProtoHelper.cpp",
        "LayerRenderArea.cpp",
        "LayerVector.cpp",
        "NativeWindowSurface.cpp",
        "RefreshRateOverlay.cpp",
        "RegionSamplingThread.cpp",
        "RenderArea.cpp",
        "Scheduler/EventThread.cpp",
        "Scheduler/FrameRateOverrideMappings.cpp",
        "Scheduler/LayerHistory.cpp",
+0 −62
Original line number Diff line number Diff line
/*
 * Copyright 2020 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.
 */

#include "DisplayRenderArea.h"
#include "DisplayDevice.h"

namespace android {

std::unique_ptr<RenderArea> DisplayRenderArea::create(wp<const DisplayDevice> displayWeak,
                                                      const Rect& sourceCrop, ui::Size reqSize,
                                                      ui::Dataspace reqDataSpace,
                                                      ftl::Flags<Options> options) {
    if (auto display = displayWeak.promote()) {
        // Using new to access a private constructor.
        return std::unique_ptr<DisplayRenderArea>(new DisplayRenderArea(std::move(display),
                                                                        sourceCrop, reqSize,
                                                                        reqDataSpace, options));
    }
    return nullptr;
}

DisplayRenderArea::DisplayRenderArea(sp<const DisplayDevice> display, const Rect& sourceCrop,
                                     ui::Size reqSize, ui::Dataspace reqDataSpace,
                                     ftl::Flags<Options> options)
      : RenderArea(reqSize, CaptureFill::OPAQUE, reqDataSpace, options),
        mDisplay(std::move(display)),
        mSourceCrop(sourceCrop) {}

const ui::Transform& DisplayRenderArea::getTransform() const {
    return mTransform;
}

bool DisplayRenderArea::isSecure() const {
    return mOptions.test(Options::CAPTURE_SECURE_LAYERS) && mDisplay->isSecure();
}

sp<const DisplayDevice> DisplayRenderArea::getDisplayDevice() const {
    return mDisplay;
}

Rect DisplayRenderArea::getSourceCrop() const {
    // use the projected display viewport by default.
    if (mSourceCrop.isEmpty()) {
        return mDisplay->getLayerStackSpaceRect();
    }
    return mSourceCrop;
}

} // namespace android
+0 −48
Original line number Diff line number Diff line
/*
 * Copyright 2020 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 <ui/GraphicTypes.h>
#include <ui/Transform.h>

#include "RenderArea.h"

namespace android {

class DisplayDevice;

class DisplayRenderArea : public RenderArea {
public:
    static std::unique_ptr<RenderArea> create(wp<const DisplayDevice>, const Rect& sourceCrop,
                                              ui::Size reqSize, ui::Dataspace,
                                              ftl::Flags<Options> options);

    const ui::Transform& getTransform() const override;
    bool isSecure() const override;
    sp<const DisplayDevice> getDisplayDevice() const override;
    Rect getSourceCrop() const override;

private:
    DisplayRenderArea(sp<const DisplayDevice>, const Rect& sourceCrop, ui::Size reqSize,
                      ui::Dataspace, ftl::Flags<Options> options);

    const sp<const DisplayDevice> mDisplay;
    const Rect mSourceCrop;
    const ui::Transform mTransform;
};

} // namespace android
+0 −60
Original line number Diff line number Diff line
/*
 * Copyright 2020 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.
 */

#include <ui/GraphicTypes.h>
#include <ui/Transform.h>

#include "DisplayDevice.h"
#include "FrontEnd/LayerCreationArgs.h"
#include "Layer.h"
#include "LayerRenderArea.h"
#include "SurfaceFlinger.h"

namespace android {

LayerRenderArea::LayerRenderArea(sp<Layer> layer, frontend::LayerSnapshot layerSnapshot,
                                 const Rect& crop, ui::Size reqSize, ui::Dataspace reqDataSpace,
                                 const ui::Transform& layerTransform, const Rect& layerBufferSize,
                                 ftl::Flags<RenderArea::Options> options)
      : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, options),
        mLayer(std::move(layer)),
        mLayerSnapshot(std::move(layerSnapshot)),
        mLayerBufferSize(layerBufferSize),
        mCrop(crop),
        mTransform(layerTransform) {}

const ui::Transform& LayerRenderArea::getTransform() const {
    return mTransform;
}

bool LayerRenderArea::isSecure() const {
    return mOptions.test(Options::CAPTURE_SECURE_LAYERS);
}

sp<const DisplayDevice> LayerRenderArea::getDisplayDevice() const {
    return nullptr;
}

Rect LayerRenderArea::getSourceCrop() const {
    if (mCrop.isEmpty()) {
        // TODO this should probably be mBounds instead of just buffer bounds
        return mLayerBufferSize;
    } else {
        return mCrop;
    }
}

} // namespace android
+0 −57
Original line number Diff line number Diff line
/*
 * Copyright 2020 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 <string>

#include <ui/GraphicTypes.h>
#include <ui/Transform.h>
#include <utils/StrongPointer.h>

#include "RenderArea.h"

namespace android {

class DisplayDevice;
class Layer;
class SurfaceFlinger;

class LayerRenderArea : public RenderArea {
public:
    LayerRenderArea(sp<Layer> layer, frontend::LayerSnapshot layerSnapshot, const Rect& crop,
                    ui::Size reqSize, ui::Dataspace reqDataSpace,
                    const ui::Transform& layerTransform, const Rect& layerBufferSize,
                    ftl::Flags<RenderArea::Options> options);

    const ui::Transform& getTransform() const override;
    bool isSecure() const override;
    sp<const DisplayDevice> getDisplayDevice() const override;
    Rect getSourceCrop() const override;

    sp<Layer> getParentLayer() const override { return mLayer; }
    const frontend::LayerSnapshot* getLayerSnapshot() const override { return &mLayerSnapshot; }

private:
    const sp<Layer> mLayer;
    const frontend::LayerSnapshot mLayerSnapshot;
    const Rect mLayerBufferSize;
    const Rect mCrop;

    ui::Transform mTransform;
};

} // namespace android
Loading