blob: 6381a44ba84bb1048f17f67f508ec52da1c1db4e [file] [log] [blame]
David Sodmanb8af7922017-12-21 15:17:55 -08001/*
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 Sodman7e4ae112018-02-09 15:02:28 -080023#include "RenderEngine/RenderEngine.h"
24
25#include "android-base/stringprintf.h"
26
27#include <string>
David Sodmanb8af7922017-12-21 15:17:55 -080028
29namespace android {
30
David Sodman2b727ac2017-12-21 14:28:08 -080031LayerBE::LayerBE(Layer* layer, std::string layerName)
David Sodmanb8af7922017-12-21 15:17:55 -080032 : mLayer(layer),
33 mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2) {
David Sodman40a3a5a2018-05-16 11:55:52 -070034 compositionInfo.layer = std::make_shared<LayerBE>(*this);
David Sodman2b727ac2017-12-21 14:28:08 -080035 compositionInfo.layerName = layerName;
David Sodmanb8af7922017-12-21 15:17:55 -080036}
37
David Sodman40a3a5a2018-05-16 11:55:52 -070038LayerBE::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 Sodmanb8af7922017-12-21 15:17:55 -080045void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) {
46 mLayer->onLayerDisplayed(releaseFence);
47}
48
David Sodman7e4ae112018-02-09 15:02:28 -080049void CompositionInfo::dump(const char* tag) const
50{
51 std::string logString;
52 dump(logString, tag);
53 ALOGV("%s", logString.c_str());
David Sodmanb8af7922017-12-21 15:17:55 -080054}
55
David Sodman7e4ae112018-02-09 15:02:28 -080056void 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 Sodmanb8af7922017-12-21 15:17:55 -080083}
84
David Sodman7e4ae112018-02-09 15:02:28 -080085void 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
110void 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 Sodmanb8af7922017-12-21 15:17:55 -0800125 switch (compositionType) {
126 case HWC2::Composition::Device:
David Sodman7e4ae112018-02-09 15:02:28 -0800127 dumpHwc(result, tag);
David Sodmanb8af7922017-12-21 15:17:55 -0800128 break;
129 case HWC2::Composition::Client:
David Sodman7e4ae112018-02-09 15:02:28 -0800130 dumpRe(result, tag);
131 break;
David Sodmanb8af7922017-12-21 15:17:55 -0800132 default:
133 break;
134 }
135}
136
David Sodman7e4ae112018-02-09 15:02:28 -0800137
138
David Sodmanb8af7922017-12-21 15:17:55 -0800139}; // namespace android