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 | #include "RenderEngine/RenderEngine.h" |
| 24 | |
| 25 | #include "android-base/stringprintf.h" |
| 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 | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame^] | 49 | void CompositionInfo::dump(const char* tag) const |
| 50 | { |
| 51 | std::string logString; |
| 52 | dump(logString, tag); |
| 53 | ALOGV("%s", logString.c_str()); |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 54 | } |
| 55 | |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame^] | 56 | void CompositionInfo::dumpHwc(std::string& result, const char* tag) const { |
| 57 | if (tag == nullptr) { |
| 58 | result += base::StringPrintf("HWC parameters\n"); |
| 59 | } else { |
| 60 | result += base::StringPrintf("[%s]HWC parameters\n", tag); |
| 61 | } |
| 62 | |
| 63 | result += base::StringPrintf("\thwcLayer=%p\n", static_cast<HWC2::Layer*>(&*hwc.hwcLayer)); |
| 64 | result += base::StringPrintf("\tfence=%p\n", hwc.fence.get()); |
| 65 | result += base::StringPrintf("\tblendMode=%d\n", hwc.blendMode); |
| 66 | result += base::StringPrintf("\ttransform=%d\n", hwc.transform); |
| 67 | result += base::StringPrintf("\tz=%d\n", hwc.z); |
| 68 | result += base::StringPrintf("\ttype=%d\n", hwc.type); |
| 69 | result += base::StringPrintf("\tappId=%d\n", hwc.appId); |
| 70 | result += base::StringPrintf("\tdisplayFrame=%4d %4d %4d %4d\n", hwc.displayFrame.left, hwc.displayFrame.top, hwc.displayFrame.right, hwc.displayFrame.bottom); |
| 71 | result += base::StringPrintf("\talpha=%.3f", hwc.alpha); |
| 72 | 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); |
| 73 | |
| 74 | { |
| 75 | // |
| 76 | // Keep a conversion from std::string to String8 and back until Region can use std::string |
| 77 | // |
| 78 | String8 regionString; |
| 79 | hwc.visibleRegion.dump(regionString, "visibleRegion"); |
| 80 | hwc.surfaceDamage.dump(regionString, "surfaceDamage"); |
| 81 | result += regionString.string(); |
| 82 | } |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 83 | } |
| 84 | |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame^] | 85 | void CompositionInfo::dumpRe(std::string& result, const char* tag) const { |
| 86 | if (tag == nullptr) { |
| 87 | result += base::StringPrintf("RenderEngine parameters:\n"); |
| 88 | } else { |
| 89 | result += base::StringPrintf("[%s]RenderEngine parameters:\n", tag); |
| 90 | } |
| 91 | |
| 92 | Mesh& mesh = layer->getMesh(); |
| 93 | result += base::StringPrintf("\tblackoutLayer=%d\n", re.blackoutLayer); |
| 94 | result += base::StringPrintf("\tclearArea=%d\n", re.clearArea); |
| 95 | result += base::StringPrintf("\tpreMultipliedAlpha=%d\n", re.preMultipliedAlpha); |
| 96 | result += base::StringPrintf("\topaque=%d\n", re.opaque); |
| 97 | result += base::StringPrintf("\tdisableTexture=%d\n", re.disableTexture); |
| 98 | result += base::StringPrintf("\ttexture:name(%d), target(%d), size(%d/%d)\n", re.texture.getTextureName(), re.texture.getTextureTarget(), (unsigned int)re.texture.getWidth(), (unsigned int)re.texture.getHeight()); |
| 99 | result += base::StringPrintf("\tuseIdentityTransform=%d\n", re.useIdentityTransform); |
| 100 | Mesh::VertexArray<vec2> positions(mesh.getPositionArray<vec2>()); |
| 101 | result += base::StringPrintf("\tpositions[(%6.1f,%6.1f), (%6.1f,%6.1f), (%6.1f,%6.1f), (%6.1f,%6.1f)]\n", |
| 102 | positions[0][0], positions[0][1], positions[1][0], positions[1][1], |
| 103 | positions[2][0], positions[2][1], positions[3][0], positions[3][1]); |
| 104 | Mesh::VertexArray<vec2> texCoords(mesh.getTexCoordArray<vec2>()); |
| 105 | result += base::StringPrintf("\ttexCoords[(%6.1f,%6.1f), (%6.1f,%6.1f),(%6.1f,%6.1f),(%6.1f,%6.1f)]\n", |
| 106 | texCoords[0][0], texCoords[0][1], texCoords[1][0], texCoords[1][1], |
| 107 | texCoords[2][0], texCoords[2][1], texCoords[3][0], texCoords[3][1]); |
| 108 | } |
| 109 | |
| 110 | void CompositionInfo::dump(std::string& result, const char* tag) const |
| 111 | { |
| 112 | if (tag == nullptr) { |
| 113 | result += base::StringPrintf("CompositionInfo\n"); |
| 114 | } else { |
| 115 | result += base::StringPrintf("[%s]CompositionInfo\n", tag); |
| 116 | } |
| 117 | result += base::StringPrintf("\tLayerName: %s\n", layerName.c_str()); |
| 118 | result += base::StringPrintf("\tCompositionType: %d\n", compositionType); |
| 119 | result += base::StringPrintf("\tmBuffer = %p\n", mBuffer.get()); |
| 120 | result += base::StringPrintf("\tmBufferSlot=%d\n", mBufferSlot); |
| 121 | result += base::StringPrintf("\tdisplayFrame=%4d %4d %4d %4d\n", hwc.displayFrame.left, hwc.displayFrame.top, hwc.displayFrame.right, hwc.displayFrame.bottom); |
| 122 | result += base::StringPrintf("\talpha=%f\n", hwc.alpha); |
| 123 | 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); |
| 124 | |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 125 | switch (compositionType) { |
| 126 | case HWC2::Composition::Device: |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame^] | 127 | dumpHwc(result, tag); |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 128 | break; |
| 129 | case HWC2::Composition::Client: |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame^] | 130 | dumpRe(result, tag); |
| 131 | break; |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 132 | default: |
| 133 | break; |
| 134 | } |
| 135 | } |
| 136 | |
David Sodman | 7e4ae11 | 2018-02-09 15:02:28 -0800 | [diff] [blame^] | 137 | |
| 138 | |
David Sodman | b8af792 | 2017-12-21 15:17:55 -0800 | [diff] [blame] | 139 | }; // namespace android |