| Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [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 |  | 
| Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 17 | #include <android-base/stringprintf.h> | 
| Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [diff] [blame] | 18 | #include <compositionengine/CompositionEngine.h> | 
|  | 19 | #include <compositionengine/LayerCreationArgs.h> | 
|  | 20 | #include <compositionengine/LayerFE.h> | 
|  | 21 | #include <compositionengine/impl/Layer.h> | 
|  | 22 |  | 
|  | 23 | namespace android::compositionengine { | 
|  | 24 |  | 
|  | 25 | Layer::~Layer() = default; | 
|  | 26 |  | 
|  | 27 | namespace impl { | 
|  | 28 |  | 
|  | 29 | std::shared_ptr<compositionengine::Layer> createLayer( | 
|  | 30 | const compositionengine::CompositionEngine& compositionEngine, | 
|  | 31 | compositionengine::LayerCreationArgs&& args) { | 
|  | 32 | return std::make_shared<Layer>(compositionEngine, std::move(args)); | 
|  | 33 | } | 
|  | 34 |  | 
|  | 35 | Layer::Layer(const CompositionEngine& compositionEngine, LayerCreationArgs&& args) | 
|  | 36 | : mCompositionEngine(compositionEngine), mLayerFE(args.layerFE) { | 
|  | 37 | static_cast<void>(mCompositionEngine); // Temporary use to prevent an unused warning | 
|  | 38 | } | 
|  | 39 |  | 
|  | 40 | Layer::~Layer() = default; | 
|  | 41 |  | 
|  | 42 | sp<LayerFE> Layer::getLayerFE() const { | 
|  | 43 | return mLayerFE.promote(); | 
|  | 44 | } | 
|  | 45 |  | 
| Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 46 | const LayerCompositionState& Layer::getState() const { | 
|  | 47 | return mState; | 
|  | 48 | } | 
|  | 49 |  | 
|  | 50 | LayerCompositionState& Layer::editState() { | 
|  | 51 | return mState; | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | void Layer::dump(std::string& out) const { | 
| Lloyd Pique | 207def9 | 2019-02-28 16:09:52 -0800 | [diff] [blame] | 55 | auto layerFE = getLayerFE(); | 
|  | 56 | android::base::StringAppendF(&out, "* compositionengine::Layer %p (%s)\n", this, | 
|  | 57 | layerFE ? layerFE->getDebugName() : "<unknown>"); | 
| Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 58 | mState.dump(out); | 
|  | 59 | } | 
|  | 60 |  | 
| Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [diff] [blame] | 61 | } // namespace impl | 
|  | 62 | } // namespace android::compositionengine |