Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | namespace android { |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 21 | |
| 22 | std::unique_ptr<RenderArea> DisplayRenderArea::create(wp<const DisplayDevice> displayWeak, |
| 23 | const Rect& sourceCrop, ui::Size reqSize, |
| 24 | ui::Dataspace reqDataSpace, |
Vishnu Nair | 96a5aaf | 2024-06-26 17:17:51 -0700 | [diff] [blame^] | 25 | ftl::Flags<Options> options) { |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 26 | if (auto display = displayWeak.promote()) { |
| 27 | // Using new to access a private constructor. |
Vishnu Nair | 96a5aaf | 2024-06-26 17:17:51 -0700 | [diff] [blame^] | 28 | return std::unique_ptr<DisplayRenderArea>(new DisplayRenderArea(std::move(display), |
| 29 | sourceCrop, reqSize, |
| 30 | reqDataSpace, options)); |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 31 | } |
| 32 | return nullptr; |
| 33 | } |
| 34 | |
| 35 | DisplayRenderArea::DisplayRenderArea(sp<const DisplayDevice> display, const Rect& sourceCrop, |
| 36 | ui::Size reqSize, ui::Dataspace reqDataSpace, |
Vishnu Nair | 96a5aaf | 2024-06-26 17:17:51 -0700 | [diff] [blame^] | 37 | ftl::Flags<Options> options) |
| 38 | : RenderArea(reqSize, CaptureFill::OPAQUE, reqDataSpace, options), |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 39 | mDisplay(std::move(display)), |
chaviw | 70cb6a4 | 2020-07-30 13:57:36 -0700 | [diff] [blame] | 40 | mSourceCrop(sourceCrop) {} |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 41 | |
| 42 | const ui::Transform& DisplayRenderArea::getTransform() const { |
| 43 | return mTransform; |
| 44 | } |
| 45 | |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 46 | bool DisplayRenderArea::isSecure() const { |
Vishnu Nair | 96a5aaf | 2024-06-26 17:17:51 -0700 | [diff] [blame^] | 47 | return mOptions.test(Options::CAPTURE_SECURE_LAYERS) && mDisplay->isSecure(); |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | sp<const DisplayDevice> DisplayRenderArea::getDisplayDevice() const { |
| 51 | return mDisplay; |
| 52 | } |
| 53 | |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 54 | Rect DisplayRenderArea::getSourceCrop() const { |
| 55 | // use the projected display viewport by default. |
| 56 | if (mSourceCrop.isEmpty()) { |
Marin Shalamanov | 6ad317c | 2020-07-29 23:34:07 +0200 | [diff] [blame] | 57 | return mDisplay->getLayerStackSpaceRect(); |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 58 | } |
Melody Hsu | 70a63e5 | 2023-11-17 19:49:12 +0000 | [diff] [blame] | 59 | return mSourceCrop; |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 60 | } |
| 61 | |
Patrick Williams | 278a88f | 2023-01-27 16:52:40 -0600 | [diff] [blame] | 62 | } // namespace android |