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 <ui/GraphicTypes.h> 18 #include <ui/Transform.h> 19 20 #include "DisplayDevice.h" 21 #include "FrontEnd/LayerCreationArgs.h" 22 #include "Layer.h" 23 #include "LayerRenderArea.h" 24 #include "SurfaceFlinger.h" 25 26 namespace android { 27 LayerRenderArea(sp<Layer> layer,frontend::LayerSnapshot layerSnapshot,const Rect & crop,ui::Size reqSize,ui::Dataspace reqDataSpace,const ui::Transform & layerTransform,const Rect & layerBufferSize,ftl::Flags<RenderArea::Options> options)28 LayerRenderArea::LayerRenderArea(sp<Layer> layer, frontend::LayerSnapshot layerSnapshot, 29 const Rect& crop, ui::Size reqSize, ui::Dataspace reqDataSpace, 30 const ui::Transform& layerTransform, const Rect& layerBufferSize, 31 ftl::Flags<RenderArea::Options> options) 32 : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, options), 33 mLayer(std::move(layer)), 34 mLayerSnapshot(std::move(layerSnapshot)), 35 mLayerBufferSize(layerBufferSize), 36 mCrop(crop), 37 mTransform(layerTransform) {} 38 getTransform() const39 const ui::Transform& LayerRenderArea::getTransform() const { 40 return mTransform; 41 } 42 isSecure() const43 bool LayerRenderArea::isSecure() const { 44 return mOptions.test(Options::CAPTURE_SECURE_LAYERS); 45 } 46 getDisplayDevice() const47 sp<const DisplayDevice> LayerRenderArea::getDisplayDevice() const { 48 return nullptr; 49 } 50 getSourceCrop() const51 Rect LayerRenderArea::getSourceCrop() const { 52 if (mCrop.isEmpty()) { 53 // TODO this should probably be mBounds instead of just buffer bounds 54 return mLayerBufferSize; 55 } else { 56 return mCrop; 57 } 58 } 59 60 } // namespace android 61