David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | #define LOG_NDEBUG 0 |
| 18 | #undef LOG_TAG |
| 19 | #define LOG_TAG "LayerBE" |
| 20 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 21 | |
| 22 | #include "Layer.h" |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 23 | |
Peiyong Lin | cbc184f | 2018-08-22 13:24:10 -0700 | [diff] [blame] | 24 | #include <android-base/stringprintf.h> |
| 25 | #include <renderengine/RenderEngine.h> |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 26 | |
| 27 | #include <string> |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 28 | |
| 29 | namespace android { |
| 30 | |
David Sodman | 2b727ac | 2017-12-21 14:28:08 -0800 | [diff] [blame] | 31 | LayerBE::LayerBE(Layer* layer, std::string layerName) |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 32 | : mLayer(layer), |
| 33 | mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2) { |
David Sodman | 40a3a5a | 2018-05-16 11:55:52 -0700 | [diff] [blame] | 34 | compositionInfo.layer = std::make_shared<LayerBE>(*this); |
David Sodman | 2b727ac | 2017-12-21 14:28:08 -0800 | [diff] [blame] | 35 | compositionInfo.layerName = layerName; |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 36 | } |
| 37 | |
David Sodman | 40a3a5a | 2018-05-16 11:55:52 -0700 | [diff] [blame] | 38 | LayerBE::LayerBE(const LayerBE& layer) |
| 39 | : mLayer(layer.mLayer), |
| 40 | mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2) { |
| 41 | compositionInfo.layer = layer.compositionInfo.layer; |
| 42 | compositionInfo.layerName = layer.mLayer->getName().string(); |
| 43 | } |
| 44 | |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 45 | void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) { |
| 46 | mLayer->onLayerDisplayed(releaseFence); |
| 47 | } |
| 48 | |
David Sodman | fb95bcc | 2017-12-22 15:45:30 -0800 | [diff] [blame^] | 49 | void LayerBE::clear(RE::RenderEngine& engine) { |
| 50 | engine.setupFillWithColor(0, 0, 0, 0); |
| 51 | engine.drawMesh(mMesh); |
| 52 | } |
| 53 | |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 54 | void CompositionInfo::dump(const char* tag) const |
| 55 | { |
| 56 | std::string logString; |
| 57 | dump(logString, tag); |
| 58 | ALOGV("%s", logString.c_str()); |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 59 | } |
| 60 | |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 61 | void CompositionInfo::dumpHwc(std::string& result, const char* tag) const { |
| 62 | if (tag == nullptr) { |
| 63 | result += base::StringPrintf("HWC parameters\n"); |
| 64 | } else { |
| 65 | result += base::StringPrintf("[%s]HWC parameters\n", tag); |
| 66 | } |
| 67 | |
| 68 | result += base::StringPrintf("\thwcLayer=%p\n", static_cast<HWC2::Layer*>(&*hwc.hwcLayer)); |
| 69 | result += base::StringPrintf("\tfence=%p\n", hwc.fence.get()); |
| 70 | result += base::StringPrintf("\tblendMode=%d\n", hwc.blendMode); |
| 71 | result += base::StringPrintf("\ttransform=%d\n", hwc.transform); |
| 72 | result += base::StringPrintf("\tz=%d\n", hwc.z); |
| 73 | result += base::StringPrintf("\ttype=%d\n", hwc.type); |
| 74 | result += base::StringPrintf("\tappId=%d\n", hwc.appId); |
| 75 | result += base::StringPrintf("\tdisplayFrame=%4d %4d %4d %4d\n", hwc.displayFrame.left, hwc.displayFrame.top, hwc.displayFrame.right, hwc.displayFrame.bottom); |
| 76 | result += base::StringPrintf("\talpha=%.3f", hwc.alpha); |
| 77 | result += base::StringPrintf("\tsourceCrop=%6.1f %6.1f %6.1f %6.1f\n", hwc.sourceCrop.left, hwc.sourceCrop.top, hwc.sourceCrop.right, hwc.sourceCrop.bottom); |
| 78 | |
| 79 | { |
| 80 | // |
| 81 | // Keep a conversion from std::string to String8 and back until Region can use std::string |
| 82 | // |
| 83 | String8 regionString; |
| 84 | hwc.visibleRegion.dump(regionString, "visibleRegion"); |
| 85 | hwc.surfaceDamage.dump(regionString, "surfaceDamage"); |
| 86 | result += regionString.string(); |
| 87 | } |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 88 | } |
| 89 | |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 90 | void CompositionInfo::dumpRe(std::string& result, const char* tag) const { |
| 91 | if (tag == nullptr) { |
| 92 | result += base::StringPrintf("RenderEngine parameters:\n"); |
| 93 | } else { |
| 94 | result += base::StringPrintf("[%s]RenderEngine parameters:\n", tag); |
| 95 | } |
| 96 | |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 97 | result += base::StringPrintf("\tblackoutLayer=%d\n", re.blackoutLayer); |
| 98 | result += base::StringPrintf("\tclearArea=%d\n", re.clearArea); |
| 99 | result += base::StringPrintf("\tpreMultipliedAlpha=%d\n", re.preMultipliedAlpha); |
| 100 | result += base::StringPrintf("\topaque=%d\n", re.opaque); |
| 101 | result += base::StringPrintf("\tdisableTexture=%d\n", re.disableTexture); |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 102 | result += base::StringPrintf("\tuseIdentityTransform=%d\n", re.useIdentityTransform); |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | void CompositionInfo::dump(std::string& result, const char* tag) const |
| 106 | { |
| 107 | if (tag == nullptr) { |
| 108 | result += base::StringPrintf("CompositionInfo\n"); |
| 109 | } else { |
| 110 | result += base::StringPrintf("[%s]CompositionInfo\n", tag); |
| 111 | } |
| 112 | result += base::StringPrintf("\tLayerName: %s\n", layerName.c_str()); |
| 113 | result += base::StringPrintf("\tCompositionType: %d\n", compositionType); |
| 114 | result += base::StringPrintf("\tmBuffer = %p\n", mBuffer.get()); |
| 115 | result += base::StringPrintf("\tmBufferSlot=%d\n", mBufferSlot); |
| 116 | result += base::StringPrintf("\tdisplayFrame=%4d %4d %4d %4d\n", hwc.displayFrame.left, hwc.displayFrame.top, hwc.displayFrame.right, hwc.displayFrame.bottom); |
| 117 | result += base::StringPrintf("\talpha=%f\n", hwc.alpha); |
| 118 | result += base::StringPrintf("\tsourceCrop=%6.1f %6.1f %6.1f %6.1f\n", hwc.sourceCrop.left, hwc.sourceCrop.top, hwc.sourceCrop.right, hwc.sourceCrop.bottom); |
| 119 | |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 120 | switch (compositionType) { |
| 121 | case HWC2::Composition::Device: |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 122 | dumpHwc(result, tag); |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 123 | break; |
| 124 | case HWC2::Composition::Client: |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame] | 125 | dumpRe(result, tag); |
| 126 | break; |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 127 | default: |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 132 | }; // namespace android |