blob: 55b395b4582c6a8c9a66eb46cb79c4c0081556ca [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 "DisplayRenderArea.h"
18#include "DisplayDevice.h"
19
20namespace android {
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020021
22std::unique_ptr<RenderArea> DisplayRenderArea::create(wp<const DisplayDevice> displayWeak,
23 const Rect& sourceCrop, ui::Size reqSize,
24 ui::Dataspace reqDataSpace,
Alec Mouri3e5965f2023-04-07 18:00:58 +000025 bool hintForSeamlessTransition,
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020026 bool allowSecureLayers) {
27 if (auto display = displayWeak.promote()) {
28 // Using new to access a private constructor.
29 return std::unique_ptr<DisplayRenderArea>(
30 new DisplayRenderArea(std::move(display), sourceCrop, reqSize, reqDataSpace,
Melody Hsu70a63e52023-11-17 19:49:12 +000031 hintForSeamlessTransition, allowSecureLayers));
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020032 }
33 return nullptr;
34}
35
36DisplayRenderArea::DisplayRenderArea(sp<const DisplayDevice> display, const Rect& sourceCrop,
37 ui::Size reqSize, ui::Dataspace reqDataSpace,
Melody Hsu70a63e52023-11-17 19:49:12 +000038 bool hintForSeamlessTransition, bool allowSecureLayers)
Alec Mouri3e5965f2023-04-07 18:00:58 +000039 : RenderArea(reqSize, CaptureFill::OPAQUE, reqDataSpace, hintForSeamlessTransition,
Melody Hsu70a63e52023-11-17 19:49:12 +000040 allowSecureLayers),
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020041 mDisplay(std::move(display)),
chaviw70cb6a42020-07-30 13:57:36 -070042 mSourceCrop(sourceCrop) {}
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020043
44const ui::Transform& DisplayRenderArea::getTransform() const {
45 return mTransform;
46}
47
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020048bool DisplayRenderArea::isSecure() const {
49 return mAllowSecureLayers && mDisplay->isSecure();
50}
51
52sp<const DisplayDevice> DisplayRenderArea::getDisplayDevice() const {
53 return mDisplay;
54}
55
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020056Rect DisplayRenderArea::getSourceCrop() const {
57 // use the projected display viewport by default.
58 if (mSourceCrop.isEmpty()) {
Marin Shalamanov6ad317c2020-07-29 23:34:07 +020059 return mDisplay->getLayerStackSpaceRect();
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020060 }
Melody Hsu70a63e52023-11-17 19:49:12 +000061 return mSourceCrop;
Marin Shalamanovf6b5d182020-06-12 02:08:51 +020062}
63
Patrick Williams278a88f2023-01-27 16:52:40 -060064} // namespace android