Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2019 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 <cinttypes> |
| 18 | |
| 19 | #include <compositionengine/CompositionEngine.h> |
| 20 | #include <compositionengine/DisplayCreationArgs.h> |
| 21 | #include <compositionengine/impl/Display.h> |
| 22 | |
| 23 | #include "DisplayHardware/HWComposer.h" |
| 24 | |
| 25 | namespace android::compositionengine::impl { |
| 26 | |
| 27 | std::shared_ptr<compositionengine::Display> createDisplay( |
| 28 | const compositionengine::CompositionEngine& compositionEngine, |
| 29 | compositionengine::DisplayCreationArgs&& args) { |
| 30 | return std::make_shared<Display>(compositionEngine, std::move(args)); |
| 31 | } |
| 32 | |
| 33 | Display::Display(const CompositionEngine& compositionEngine, DisplayCreationArgs&& args) |
| 34 | : mCompositionEngine(compositionEngine), |
| 35 | mIsSecure(args.isSecure), |
| 36 | mIsVirtual(args.isVirtual), |
| 37 | mId(args.displayId) {} |
| 38 | |
| 39 | Display::~Display() = default; |
| 40 | |
| 41 | const std::optional<DisplayId>& Display::getId() const { |
| 42 | return mId; |
| 43 | } |
| 44 | |
| 45 | bool Display::isSecure() const { |
| 46 | return mIsSecure; |
| 47 | } |
| 48 | |
| 49 | bool Display::isVirtual() const { |
| 50 | return mIsVirtual; |
| 51 | } |
| 52 | |
| 53 | void Display::disconnect() { |
| 54 | if (!mId) { |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | auto& hwc = mCompositionEngine.getHwComposer(); |
| 59 | hwc.disconnectDisplay(*mId); |
| 60 | mId.reset(); |
| 61 | } |
| 62 | |
| 63 | } // namespace android::compositionengine::impl |