blob: 9c6534e0d981287015e99a9b1d4656c7d782431e [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
Peiyong Lincbc184f2018-08-22 13:24:10 -070024#include <android-base/stringprintf.h>
25#include <renderengine/RenderEngine.h>
David Sodman7e4ae112018-02-09 15:02:28 -080026
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 Sodmanfb95bcc2017-12-22 15:45:30 -080049void LayerBE::clear(RE::RenderEngine& engine) {
50 engine.setupFillWithColor(0, 0, 0, 0);
51 engine.drawMesh(mMesh);
52}
53
David Sodman7e4ae112018-02-09 15:02:28 -080054void CompositionInfo::dump(const char* tag) const
55{
56 std::string logString;
57 dump(logString, tag);
58 ALOGV("%s", logString.c_str());
David Sodmanb8af7922017-12-21 15:17:55 -080059}
60
David Sodman7e4ae112018-02-09 15:02:28 -080061void 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 Sodmanb8af7922017-12-21 15:17:55 -080088}
89
David Sodman7e4ae112018-02-09 15:02:28 -080090void 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 Sodman7e4ae112018-02-09 15:02:28 -080097 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 Sodman7e4ae112018-02-09 15:02:28 -0800102 result += base::StringPrintf("\tuseIdentityTransform=%d\n", re.useIdentityTransform);
David Sodman7e4ae112018-02-09 15:02:28 -0800103}
104
105void 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 Sodmanb8af7922017-12-21 15:17:55 -0800120 switch (compositionType) {
121 case HWC2::Composition::Device:
David Sodman7e4ae112018-02-09 15:02:28 -0800122 dumpHwc(result, tag);
David Sodmanb8af7922017-12-21 15:17:55 -0800123 break;
124 case HWC2::Composition::Client:
David Sodman7e4ae112018-02-09 15:02:28 -0800125 dumpRe(result, tag);
126 break;
David Sodmanb8af7922017-12-21 15:17:55 -0800127 default:
128 break;
129 }
130}
131
David Sodmanb8af7922017-12-21 15:17:55 -0800132}; // namespace android