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, |
Alec Mouri | 3e5965f | 2023-04-07 18:00:58 +0000 | [diff] [blame] | 25 | bool hintForSeamlessTransition, |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 26 | 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 Hsu | 70a63e5 | 2023-11-17 19:49:12 +0000 | [diff] [blame^] | 31 | hintForSeamlessTransition, allowSecureLayers)); |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 32 | } |
| 33 | return nullptr; |
| 34 | } |
| 35 | |
| 36 | DisplayRenderArea::DisplayRenderArea(sp<const DisplayDevice> display, const Rect& sourceCrop, |
| 37 | ui::Size reqSize, ui::Dataspace reqDataSpace, |
Melody Hsu | 70a63e5 | 2023-11-17 19:49:12 +0000 | [diff] [blame^] | 38 | bool hintForSeamlessTransition, bool allowSecureLayers) |
Alec Mouri | 3e5965f | 2023-04-07 18:00:58 +0000 | [diff] [blame] | 39 | : RenderArea(reqSize, CaptureFill::OPAQUE, reqDataSpace, hintForSeamlessTransition, |
Melody Hsu | 70a63e5 | 2023-11-17 19:49:12 +0000 | [diff] [blame^] | 40 | allowSecureLayers), |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 41 | mDisplay(std::move(display)), |
chaviw | 70cb6a4 | 2020-07-30 13:57:36 -0700 | [diff] [blame] | 42 | mSourceCrop(sourceCrop) {} |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 43 | |
| 44 | const ui::Transform& DisplayRenderArea::getTransform() const { |
| 45 | return mTransform; |
| 46 | } |
| 47 | |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 48 | bool DisplayRenderArea::isSecure() const { |
| 49 | return mAllowSecureLayers && mDisplay->isSecure(); |
| 50 | } |
| 51 | |
| 52 | sp<const DisplayDevice> DisplayRenderArea::getDisplayDevice() const { |
| 53 | return mDisplay; |
| 54 | } |
| 55 | |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 56 | Rect DisplayRenderArea::getSourceCrop() const { |
| 57 | // use the projected display viewport by default. |
| 58 | if (mSourceCrop.isEmpty()) { |
Marin Shalamanov | 6ad317c | 2020-07-29 23:34:07 +0200 | [diff] [blame] | 59 | return mDisplay->getLayerStackSpaceRect(); |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 60 | } |
Melody Hsu | 70a63e5 | 2023-11-17 19:49:12 +0000 | [diff] [blame^] | 61 | return mSourceCrop; |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 62 | } |
| 63 | |
Patrick Williams | 278a88f | 2023-01-27 16:52:40 -0600 | [diff] [blame] | 64 | } // namespace android |