blob: f323ce7284595843adf06fe9d468009bb26a2daa [file] [log] [blame]
Marin Shalamanovf6b5d182020-06-12 02:08:51 +02001/*
2 * Copyright 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <ui/GraphicTypes.h>
18#include <ui/Transform.h>
19
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020020#include "DisplayDevice.h"
Vishnu Naircb8be502022-10-12 19:03:23 +000021#include "FrontEnd/LayerCreationArgs.h"
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020022#include "Layer.h"
23#include "LayerRenderArea.h"
24#include "SurfaceFlinger.h"
25
26namespace android {
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020027
Melody Hsu50c151a2024-05-14 06:11:12 +000028LayerRenderArea::LayerRenderArea(sp<Layer> layer, frontend::LayerSnapshot layerSnapshot,
29 const Rect& crop, ui::Size reqSize, ui::Dataspace reqDataSpace,
30 bool allowSecureLayers, const ui::Transform& layerTransform,
31 const Rect& layerBufferSize, bool hintForSeamlessTransition)
Alec Mouri3e5965f2023-04-07 18:00:58 +000032 : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, hintForSeamlessTransition,
33 allowSecureLayers),
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020034 mLayer(std::move(layer)),
Melody Hsu50c151a2024-05-14 06:11:12 +000035 mLayerSnapshot(std::move(layerSnapshot)),
Vishnu Nair36d5f8e2023-03-19 13:31:35 -070036 mLayerBufferSize(layerBufferSize),
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020037 mCrop(crop),
Melody Hsu9db32ff2024-04-17 19:52:55 +000038 mTransform(layerTransform) {}
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020039
40const ui::Transform& LayerRenderArea::getTransform() const {
41 return mTransform;
42}
43
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020044bool LayerRenderArea::isSecure() const {
chaviw70cb6a42020-07-30 13:57:36 -070045 return mAllowSecureLayers;
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020046}
47
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020048sp<const DisplayDevice> LayerRenderArea::getDisplayDevice() const {
49 return nullptr;
50}
51
52Rect LayerRenderArea::getSourceCrop() const {
53 if (mCrop.isEmpty()) {
Vishnu Nair36d5f8e2023-03-19 13:31:35 -070054 // TODO this should probably be mBounds instead of just buffer bounds
55 return mLayerBufferSize;
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020056 } else {
57 return mCrop;
58 }
59}
60
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020061} // namespace android