Loading services/surfaceflinger/BufferLayer.cpp +62 −15 Original line number Diff line number Diff line Loading @@ -593,14 +593,32 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) const auto& viewport = displayDevice->getViewport(); Region visible = tr.transform(visibleRegion.intersect(viewport)); auto hwcId = displayDevice->getHwcDisplayId(); auto& hwcInfo = getBE().mHwcLayers[hwcId]; auto& hwcLayer = hwcInfo.layer; auto error = (*hwcLayer)->setVisibleRegion(visible); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set visible region: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); visible.dump(LOG_TAG); } getBE().compositionInfo.hwc.visibleRegion = visible; getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; error = (*hwcLayer)->setSurfaceDamage(surfaceDamageRegion); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set surface damage: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); surfaceDamageRegion.dump(LOG_TAG); } // Sideband layers if (getBE().compositionInfo.hwc.sidebandStream.get()) { setCompositionType(hwcId, HWC2::Composition::Sideband); getBE().compositionInfo.compositionType = HWC2::Composition::Sideband; ALOGV("[%s] Requesting Sideband composition", mName.string()); error = (*hwcLayer)->setSidebandStream(getBE().compositionInfo.hwc.sidebandStream->handle()); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", mName.string(), getBE().compositionInfo.hwc.sidebandStream->handle(), to_string(error).c_str(), static_cast<int32_t>(error)); } return; } Loading @@ -613,13 +631,32 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) setCompositionType(hwcId, HWC2::Composition::Device); } getBE().compositionInfo.hwc.dataspace = mDrawingState.dataSpace; getBE().compositionInfo.hwc.hdrMetadata = mConsumer->getCurrentHdrMetadata(); ALOGV("setPerFrameData: dataspace = %d", mDrawingState.dataSpace); error = (*hwcLayer)->setDataspace(mDrawingState.dataSpace); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mDrawingState.dataSpace, to_string(error).c_str(), static_cast<int32_t>(error)); } const HdrMetadata& metadata = mConsumer->getCurrentHdrMetadata(); error = (*hwcLayer)->setHdrMetadata(metadata); if (error != HWC2::Error::None && error != HWC2::Error::Unsupported) { ALOGE("[%s] Failed to set hdrMetadata: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } uint32_t hwcSlot = 0; sp<GraphicBuffer> hwcBuffer; getBE().mHwcLayers[hwcId].bufferCache.getHwcBuffer(mActiveBufferSlot, mActiveBuffer, &hwcSlot, &hwcBuffer); auto acquireFence = mConsumer->getCurrentFence(); getBE().compositionInfo.mBufferSlot = mActiveBufferSlot; getBE().compositionInfo.mBuffer = mActiveBuffer; getBE().compositionInfo.hwc.fence = acquireFence; error = (*hwcLayer)->setBuffer(hwcSlot, hwcBuffer, acquireFence); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set buffer %p: %s (%d)", mName.string(), getBE().compositionInfo.mBuffer->handle, to_string(error).c_str(), static_cast<int32_t>(error)); } } bool BufferLayer::isOpaque(const Layer::State& s) const { Loading Loading @@ -793,17 +830,27 @@ void BufferLayer::drawWithOpenGL(const RenderArea& renderArea, bool useIdentityT texCoords[2] = vec2(right, 1.0f - bottom); texCoords[3] = vec2(right, 1.0f - top); getBE().compositionInfo.re.preMultipliedAlpha = mPremultipliedAlpha; getBE().compositionInfo.re.opaque = isOpaque(s); getBE().compositionInfo.re.disableTexture = false; getBE().compositionInfo.re.color = getColor(); getBE().compositionInfo.hwc.dataspace = mCurrentState.dataSpace; //getBE().compositionInfo.re.preMultipliedAlpha = mPremultipliedAlpha; //getBE().compositionInfo.re.opaque = isOpaque(s); //getBE().compositionInfo.re.disableTexture = false; //getBE().compositionInfo.re.color = getColor(); //getBE().compositionInfo.hwc.dataspace = mCurrentState.dataSpace; auto& engine(mFlinger->getRenderEngine()); engine.setupLayerBlending(mPremultipliedAlpha, isOpaque(s), false /* disableTexture */, getColor()); engine.setSourceDataSpace(mCurrentState.dataSpace); if (mCurrentState.dataSpace == HAL_DATASPACE_BT2020_ITU_PQ && mConsumer->getCurrentApi() == NATIVE_WINDOW_API_MEDIA && getBE().compositionInfo.mBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102) { getBE().compositionInfo.re.Y410BT2020 = true; engine.setSourceY410BT2020(true); } engine.drawMesh(getBE().mMesh); engine.disableBlending(); engine.setSourceY410BT2020(false); } uint32_t BufferLayer::getProducerStickyTransform() const { Loading services/surfaceflinger/ColorLayer.cpp +26 −6 Original line number Diff line number Diff line Loading @@ -77,18 +77,38 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) { const auto& viewport = displayDevice->getViewport(); Region visible = tr.transform(visibleRegion.intersect(viewport)); auto hwcId = displayDevice->getHwcDisplayId(); getBE().compositionInfo.hwc.visibleRegion = visible; getBE().compositionInfo.hwc.dataspace = mDrawingState.dataSpace; auto& hwcInfo = getBE().mHwcLayers[hwcId]; auto& hwcLayer = hwcInfo.layer; auto error = (*hwcLayer)->setVisibleRegion(visible); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set visible region: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); visible.dump(LOG_TAG); } setCompositionType(hwcId, HWC2::Composition::SolidColor); error = (*hwcLayer)->setDataspace(mDrawingState.dataSpace); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mDrawingState.dataSpace, to_string(error).c_str(), static_cast<int32_t>(error)); } half4 color = getColor(); getBE().compositionInfo.hwc.color = { static_cast<uint8_t>(std::round(255.0f * color.r)), error = (*hwcLayer)->setColor({static_cast<uint8_t>(std::round(255.0f * color.r)), static_cast<uint8_t>(std::round(255.0f * color.g)), static_cast<uint8_t>(std::round(255.0f * color.b)), 255 }; static_cast<uint8_t>(std::round(255.0f * color.b)), 255}); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set color: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } // Clear out the transform, because it doesn't make sense absent a source buffer getBE().compositionInfo.hwc.transform = HWC2::Transform::None; error = (*hwcLayer)->setTransform(HWC2::Transform::None); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to clear transform: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } } // --------------------------------------------------------------------------- Loading services/surfaceflinger/Layer.cpp +71 −21 Original line number Diff line number Diff line Loading @@ -483,9 +483,6 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z const auto hwcId = displayDevice->getHwcDisplayId(); auto& hwcInfo = getBE().mHwcLayers[hwcId]; // Need to program geometry parts getBE().compositionInfo.hwc.skipGeometry = false; // enable this layer hwcInfo.forceClientComposition = false; Loading @@ -493,6 +490,8 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z hwcInfo.forceClientComposition = true; } auto& hwcLayer = hwcInfo.layer; // this gives us only the "orientation" component of the transform const State& s(getDrawingState()); auto blendMode = HWC2::BlendMode::None; Loading @@ -500,7 +499,12 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z blendMode = mPremultipliedAlpha ? HWC2::BlendMode::Premultiplied : HWC2::BlendMode::Coverage; } getBE().compositionInfo.hwc.blendMode = blendMode; auto error = (*hwcLayer)->setBlendMode(blendMode); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set blend mode %s:" " %s (%d)", mName.string(), to_string(blendMode).c_str(), to_string(error).c_str(), static_cast<int32_t>(error)); // apply the layer's transform, followed by the display's global transform // here we're guaranteed that the layer's transform preserves rects Loading Loading @@ -543,15 +547,36 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z } const Transform& tr(displayDevice->getTransform()); Rect transformedFrame = tr.transform(frame); getBE().compositionInfo.hwc.displayFrame = transformedFrame; error = (*hwcLayer)->setDisplayFrame(transformedFrame); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set display frame [%d, %d, %d, %d]: %s (%d)", mName.string(), transformedFrame.left, transformedFrame.top, transformedFrame.right, transformedFrame.bottom, to_string(error).c_str(), static_cast<int32_t>(error)); } else { hwcInfo.displayFrame = transformedFrame; } FloatRect sourceCrop = computeCrop(displayDevice); getBE().compositionInfo.hwc.sourceCrop = sourceCrop; error = (*hwcLayer)->setSourceCrop(sourceCrop); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set source crop [%.3f, %.3f, %.3f, %.3f]: " "%s (%d)", mName.string(), sourceCrop.left, sourceCrop.top, sourceCrop.right, sourceCrop.bottom, to_string(error).c_str(), static_cast<int32_t>(error)); } else { hwcInfo.sourceCrop = sourceCrop; } float alpha = static_cast<float>(getAlpha()); getBE().compositionInfo.hwc.alpha = alpha; error = (*hwcLayer)->setPlaneAlpha(alpha); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set plane alpha %.3f: " "%s (%d)", mName.string(), alpha, to_string(error).c_str(), static_cast<int32_t>(error)); getBE().compositionInfo.hwc.z = z; error = (*hwcLayer)->setZOrder(z); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set Z %u: %s (%d)", mName.string(), z, to_string(error).c_str(), static_cast<int32_t>(error)); int type = s.type; int appId = s.appId; Loading @@ -564,8 +589,9 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z } } getBE().compositionInfo.hwc.type = type; getBE().compositionInfo.hwc.appId = appId; error = (*hwcLayer)->setInfo(type, appId); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set info (%d)", mName.string(), static_cast<int32_t>(error)); /* * Transformations are applied in this order: Loading Loading @@ -608,11 +634,16 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z const uint32_t orientation = transform.getOrientation(); if (orientation & Transform::ROT_INVALID || extremeScaling) { // we can only handle simple transformation getBE().mHwcLayers[hwcId].compositionType = HWC2::Composition::Client; hwcInfo.forceClientComposition = true; } else { auto transform = static_cast<HWC2::Transform>(orientation); hwcInfo.transform = transform; getBE().compositionInfo.hwc.transform = transform; auto error = (*hwcLayer)->setTransform(transform); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set transform %s: " "%s (%d)", mName.string(), to_string(transform).c_str(), to_string(error).c_str(), static_cast<int32_t>(error)); } } Loading Loading @@ -697,12 +728,26 @@ void Layer::clearWithOpenGL(const RenderArea& renderArea) const { clearWithOpenGL(renderArea, 0, 0, 0, 0); } void Layer::setCompositionType(int32_t /*hwcId*/, HWC2::Composition type, bool /*callIntoHwc*/) { if (getBE().compositionInfo.compositionType != type) { ALOGV("setCompositionType: Changing compositionType from %s to %s", to_string(getBE().compositionInfo.compositionType).c_str(), to_string(type).c_str()); getBE().compositionInfo.compositionType = type; void Layer::setCompositionType(int32_t hwcId, HWC2::Composition type, bool callIntoHwc) { if (getBE().mHwcLayers.count(hwcId) == 0) { ALOGE("setCompositionType called without a valid HWC layer"); return; } auto& hwcInfo = getBE().mHwcLayers[hwcId]; auto& hwcLayer = hwcInfo.layer; ALOGV("setCompositionType(%" PRIx64 ", %s, %d)", (*hwcLayer)->getId(), to_string(type).c_str(), static_cast<int>(callIntoHwc)); if (hwcInfo.compositionType != type) { ALOGV(" actually setting"); hwcInfo.compositionType = type; if (callIntoHwc) { auto error = (*hwcLayer)->setCompositionType(type); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set " "composition type %s: %s (%d)", mName.string(), to_string(type).c_str(), to_string(error).c_str(), static_cast<int32_t>(error)); } } } Loading @@ -712,7 +757,11 @@ HWC2::Composition Layer::getCompositionType(int32_t hwcId) const { // have a HWC counterpart, then it will always be Client return HWC2::Composition::Client; } return getBE().compositionInfo.compositionType; if (getBE().mHwcLayers.count(hwcId) == 0) { ALOGE("getCompositionType called with an invalid HWC layer"); return HWC2::Composition::Invalid; } return getBE().mHwcLayers.at(hwcId).compositionType; } void Layer::setClearClientTarget(int32_t hwcId, bool clear) { Loading Loading @@ -1441,11 +1490,12 @@ void Layer::miniDump(String8& result, int32_t hwcId) const { result.appendFormat(" %s\n", name.string()); const Layer::State& layerState(getDrawingState()); const LayerBE::HWCInfo& hwcInfo = getBE().mHwcLayers.at(hwcId); result.appendFormat(" %10d | ", layerState.z); result.appendFormat("%10s | ", to_string(getCompositionType(hwcId)).c_str()); const Rect& frame = getBE().compositionInfo.hwc.displayFrame; const Rect& frame = hwcInfo.displayFrame; result.appendFormat("%4d %4d %4d %4d | ", frame.left, frame.top, frame.right, frame.bottom); const FloatRect& crop = getBE().compositionInfo.hwc.sourceCrop; const FloatRect& crop = hwcInfo.sourceCrop; result.appendFormat("%6.1f %6.1f %6.1f %6.1f\n", crop.left, crop.top, crop.right, crop.bottom); result.append("- - - - - - - - - - - - - - - - - - - - "); Loading services/surfaceflinger/LayerBE.h +0 −3 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ #include <stdint.h> #include <sys/types.h> #include <gui/HdrMetadata.h> #include <ui/Region.h> #include "SurfaceFlinger.h" Loading Loading @@ -66,7 +65,6 @@ struct CompositionInfo { LayerBE* layer = nullptr; struct { std::shared_ptr<LayerContainer> hwcLayer; bool skipGeometry = true; int32_t hwid = -1; sp<Fence> fence; HWC2::BlendMode blendMode = HWC2::BlendMode::Invalid; Loading @@ -82,7 +80,6 @@ struct CompositionInfo { sp<NativeHandle> sidebandStream; android_dataspace dataspace; hwc_color_t color; HdrMetadata hdrMetadata; } hwc; struct { Mesh* mesh; Loading services/surfaceflinger/SurfaceFlinger.cpp +99 −274 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
services/surfaceflinger/BufferLayer.cpp +62 −15 Original line number Diff line number Diff line Loading @@ -593,14 +593,32 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) const auto& viewport = displayDevice->getViewport(); Region visible = tr.transform(visibleRegion.intersect(viewport)); auto hwcId = displayDevice->getHwcDisplayId(); auto& hwcInfo = getBE().mHwcLayers[hwcId]; auto& hwcLayer = hwcInfo.layer; auto error = (*hwcLayer)->setVisibleRegion(visible); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set visible region: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); visible.dump(LOG_TAG); } getBE().compositionInfo.hwc.visibleRegion = visible; getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; error = (*hwcLayer)->setSurfaceDamage(surfaceDamageRegion); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set surface damage: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); surfaceDamageRegion.dump(LOG_TAG); } // Sideband layers if (getBE().compositionInfo.hwc.sidebandStream.get()) { setCompositionType(hwcId, HWC2::Composition::Sideband); getBE().compositionInfo.compositionType = HWC2::Composition::Sideband; ALOGV("[%s] Requesting Sideband composition", mName.string()); error = (*hwcLayer)->setSidebandStream(getBE().compositionInfo.hwc.sidebandStream->handle()); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", mName.string(), getBE().compositionInfo.hwc.sidebandStream->handle(), to_string(error).c_str(), static_cast<int32_t>(error)); } return; } Loading @@ -613,13 +631,32 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) setCompositionType(hwcId, HWC2::Composition::Device); } getBE().compositionInfo.hwc.dataspace = mDrawingState.dataSpace; getBE().compositionInfo.hwc.hdrMetadata = mConsumer->getCurrentHdrMetadata(); ALOGV("setPerFrameData: dataspace = %d", mDrawingState.dataSpace); error = (*hwcLayer)->setDataspace(mDrawingState.dataSpace); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mDrawingState.dataSpace, to_string(error).c_str(), static_cast<int32_t>(error)); } const HdrMetadata& metadata = mConsumer->getCurrentHdrMetadata(); error = (*hwcLayer)->setHdrMetadata(metadata); if (error != HWC2::Error::None && error != HWC2::Error::Unsupported) { ALOGE("[%s] Failed to set hdrMetadata: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } uint32_t hwcSlot = 0; sp<GraphicBuffer> hwcBuffer; getBE().mHwcLayers[hwcId].bufferCache.getHwcBuffer(mActiveBufferSlot, mActiveBuffer, &hwcSlot, &hwcBuffer); auto acquireFence = mConsumer->getCurrentFence(); getBE().compositionInfo.mBufferSlot = mActiveBufferSlot; getBE().compositionInfo.mBuffer = mActiveBuffer; getBE().compositionInfo.hwc.fence = acquireFence; error = (*hwcLayer)->setBuffer(hwcSlot, hwcBuffer, acquireFence); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set buffer %p: %s (%d)", mName.string(), getBE().compositionInfo.mBuffer->handle, to_string(error).c_str(), static_cast<int32_t>(error)); } } bool BufferLayer::isOpaque(const Layer::State& s) const { Loading Loading @@ -793,17 +830,27 @@ void BufferLayer::drawWithOpenGL(const RenderArea& renderArea, bool useIdentityT texCoords[2] = vec2(right, 1.0f - bottom); texCoords[3] = vec2(right, 1.0f - top); getBE().compositionInfo.re.preMultipliedAlpha = mPremultipliedAlpha; getBE().compositionInfo.re.opaque = isOpaque(s); getBE().compositionInfo.re.disableTexture = false; getBE().compositionInfo.re.color = getColor(); getBE().compositionInfo.hwc.dataspace = mCurrentState.dataSpace; //getBE().compositionInfo.re.preMultipliedAlpha = mPremultipliedAlpha; //getBE().compositionInfo.re.opaque = isOpaque(s); //getBE().compositionInfo.re.disableTexture = false; //getBE().compositionInfo.re.color = getColor(); //getBE().compositionInfo.hwc.dataspace = mCurrentState.dataSpace; auto& engine(mFlinger->getRenderEngine()); engine.setupLayerBlending(mPremultipliedAlpha, isOpaque(s), false /* disableTexture */, getColor()); engine.setSourceDataSpace(mCurrentState.dataSpace); if (mCurrentState.dataSpace == HAL_DATASPACE_BT2020_ITU_PQ && mConsumer->getCurrentApi() == NATIVE_WINDOW_API_MEDIA && getBE().compositionInfo.mBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102) { getBE().compositionInfo.re.Y410BT2020 = true; engine.setSourceY410BT2020(true); } engine.drawMesh(getBE().mMesh); engine.disableBlending(); engine.setSourceY410BT2020(false); } uint32_t BufferLayer::getProducerStickyTransform() const { Loading
services/surfaceflinger/ColorLayer.cpp +26 −6 Original line number Diff line number Diff line Loading @@ -77,18 +77,38 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) { const auto& viewport = displayDevice->getViewport(); Region visible = tr.transform(visibleRegion.intersect(viewport)); auto hwcId = displayDevice->getHwcDisplayId(); getBE().compositionInfo.hwc.visibleRegion = visible; getBE().compositionInfo.hwc.dataspace = mDrawingState.dataSpace; auto& hwcInfo = getBE().mHwcLayers[hwcId]; auto& hwcLayer = hwcInfo.layer; auto error = (*hwcLayer)->setVisibleRegion(visible); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set visible region: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); visible.dump(LOG_TAG); } setCompositionType(hwcId, HWC2::Composition::SolidColor); error = (*hwcLayer)->setDataspace(mDrawingState.dataSpace); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mDrawingState.dataSpace, to_string(error).c_str(), static_cast<int32_t>(error)); } half4 color = getColor(); getBE().compositionInfo.hwc.color = { static_cast<uint8_t>(std::round(255.0f * color.r)), error = (*hwcLayer)->setColor({static_cast<uint8_t>(std::round(255.0f * color.r)), static_cast<uint8_t>(std::round(255.0f * color.g)), static_cast<uint8_t>(std::round(255.0f * color.b)), 255 }; static_cast<uint8_t>(std::round(255.0f * color.b)), 255}); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set color: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } // Clear out the transform, because it doesn't make sense absent a source buffer getBE().compositionInfo.hwc.transform = HWC2::Transform::None; error = (*hwcLayer)->setTransform(HWC2::Transform::None); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to clear transform: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } } // --------------------------------------------------------------------------- Loading
services/surfaceflinger/Layer.cpp +71 −21 Original line number Diff line number Diff line Loading @@ -483,9 +483,6 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z const auto hwcId = displayDevice->getHwcDisplayId(); auto& hwcInfo = getBE().mHwcLayers[hwcId]; // Need to program geometry parts getBE().compositionInfo.hwc.skipGeometry = false; // enable this layer hwcInfo.forceClientComposition = false; Loading @@ -493,6 +490,8 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z hwcInfo.forceClientComposition = true; } auto& hwcLayer = hwcInfo.layer; // this gives us only the "orientation" component of the transform const State& s(getDrawingState()); auto blendMode = HWC2::BlendMode::None; Loading @@ -500,7 +499,12 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z blendMode = mPremultipliedAlpha ? HWC2::BlendMode::Premultiplied : HWC2::BlendMode::Coverage; } getBE().compositionInfo.hwc.blendMode = blendMode; auto error = (*hwcLayer)->setBlendMode(blendMode); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set blend mode %s:" " %s (%d)", mName.string(), to_string(blendMode).c_str(), to_string(error).c_str(), static_cast<int32_t>(error)); // apply the layer's transform, followed by the display's global transform // here we're guaranteed that the layer's transform preserves rects Loading Loading @@ -543,15 +547,36 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z } const Transform& tr(displayDevice->getTransform()); Rect transformedFrame = tr.transform(frame); getBE().compositionInfo.hwc.displayFrame = transformedFrame; error = (*hwcLayer)->setDisplayFrame(transformedFrame); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set display frame [%d, %d, %d, %d]: %s (%d)", mName.string(), transformedFrame.left, transformedFrame.top, transformedFrame.right, transformedFrame.bottom, to_string(error).c_str(), static_cast<int32_t>(error)); } else { hwcInfo.displayFrame = transformedFrame; } FloatRect sourceCrop = computeCrop(displayDevice); getBE().compositionInfo.hwc.sourceCrop = sourceCrop; error = (*hwcLayer)->setSourceCrop(sourceCrop); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set source crop [%.3f, %.3f, %.3f, %.3f]: " "%s (%d)", mName.string(), sourceCrop.left, sourceCrop.top, sourceCrop.right, sourceCrop.bottom, to_string(error).c_str(), static_cast<int32_t>(error)); } else { hwcInfo.sourceCrop = sourceCrop; } float alpha = static_cast<float>(getAlpha()); getBE().compositionInfo.hwc.alpha = alpha; error = (*hwcLayer)->setPlaneAlpha(alpha); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set plane alpha %.3f: " "%s (%d)", mName.string(), alpha, to_string(error).c_str(), static_cast<int32_t>(error)); getBE().compositionInfo.hwc.z = z; error = (*hwcLayer)->setZOrder(z); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set Z %u: %s (%d)", mName.string(), z, to_string(error).c_str(), static_cast<int32_t>(error)); int type = s.type; int appId = s.appId; Loading @@ -564,8 +589,9 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z } } getBE().compositionInfo.hwc.type = type; getBE().compositionInfo.hwc.appId = appId; error = (*hwcLayer)->setInfo(type, appId); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set info (%d)", mName.string(), static_cast<int32_t>(error)); /* * Transformations are applied in this order: Loading Loading @@ -608,11 +634,16 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z const uint32_t orientation = transform.getOrientation(); if (orientation & Transform::ROT_INVALID || extremeScaling) { // we can only handle simple transformation getBE().mHwcLayers[hwcId].compositionType = HWC2::Composition::Client; hwcInfo.forceClientComposition = true; } else { auto transform = static_cast<HWC2::Transform>(orientation); hwcInfo.transform = transform; getBE().compositionInfo.hwc.transform = transform; auto error = (*hwcLayer)->setTransform(transform); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set transform %s: " "%s (%d)", mName.string(), to_string(transform).c_str(), to_string(error).c_str(), static_cast<int32_t>(error)); } } Loading Loading @@ -697,12 +728,26 @@ void Layer::clearWithOpenGL(const RenderArea& renderArea) const { clearWithOpenGL(renderArea, 0, 0, 0, 0); } void Layer::setCompositionType(int32_t /*hwcId*/, HWC2::Composition type, bool /*callIntoHwc*/) { if (getBE().compositionInfo.compositionType != type) { ALOGV("setCompositionType: Changing compositionType from %s to %s", to_string(getBE().compositionInfo.compositionType).c_str(), to_string(type).c_str()); getBE().compositionInfo.compositionType = type; void Layer::setCompositionType(int32_t hwcId, HWC2::Composition type, bool callIntoHwc) { if (getBE().mHwcLayers.count(hwcId) == 0) { ALOGE("setCompositionType called without a valid HWC layer"); return; } auto& hwcInfo = getBE().mHwcLayers[hwcId]; auto& hwcLayer = hwcInfo.layer; ALOGV("setCompositionType(%" PRIx64 ", %s, %d)", (*hwcLayer)->getId(), to_string(type).c_str(), static_cast<int>(callIntoHwc)); if (hwcInfo.compositionType != type) { ALOGV(" actually setting"); hwcInfo.compositionType = type; if (callIntoHwc) { auto error = (*hwcLayer)->setCompositionType(type); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set " "composition type %s: %s (%d)", mName.string(), to_string(type).c_str(), to_string(error).c_str(), static_cast<int32_t>(error)); } } } Loading @@ -712,7 +757,11 @@ HWC2::Composition Layer::getCompositionType(int32_t hwcId) const { // have a HWC counterpart, then it will always be Client return HWC2::Composition::Client; } return getBE().compositionInfo.compositionType; if (getBE().mHwcLayers.count(hwcId) == 0) { ALOGE("getCompositionType called with an invalid HWC layer"); return HWC2::Composition::Invalid; } return getBE().mHwcLayers.at(hwcId).compositionType; } void Layer::setClearClientTarget(int32_t hwcId, bool clear) { Loading Loading @@ -1441,11 +1490,12 @@ void Layer::miniDump(String8& result, int32_t hwcId) const { result.appendFormat(" %s\n", name.string()); const Layer::State& layerState(getDrawingState()); const LayerBE::HWCInfo& hwcInfo = getBE().mHwcLayers.at(hwcId); result.appendFormat(" %10d | ", layerState.z); result.appendFormat("%10s | ", to_string(getCompositionType(hwcId)).c_str()); const Rect& frame = getBE().compositionInfo.hwc.displayFrame; const Rect& frame = hwcInfo.displayFrame; result.appendFormat("%4d %4d %4d %4d | ", frame.left, frame.top, frame.right, frame.bottom); const FloatRect& crop = getBE().compositionInfo.hwc.sourceCrop; const FloatRect& crop = hwcInfo.sourceCrop; result.appendFormat("%6.1f %6.1f %6.1f %6.1f\n", crop.left, crop.top, crop.right, crop.bottom); result.append("- - - - - - - - - - - - - - - - - - - - "); Loading
services/surfaceflinger/LayerBE.h +0 −3 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ #include <stdint.h> #include <sys/types.h> #include <gui/HdrMetadata.h> #include <ui/Region.h> #include "SurfaceFlinger.h" Loading Loading @@ -66,7 +65,6 @@ struct CompositionInfo { LayerBE* layer = nullptr; struct { std::shared_ptr<LayerContainer> hwcLayer; bool skipGeometry = true; int32_t hwid = -1; sp<Fence> fence; HWC2::BlendMode blendMode = HWC2::BlendMode::Invalid; Loading @@ -82,7 +80,6 @@ struct CompositionInfo { sp<NativeHandle> sidebandStream; android_dataspace dataspace; hwc_color_t color; HdrMetadata hdrMetadata; } hwc; struct { Mesh* mesh; Loading
services/surfaceflinger/SurfaceFlinger.cpp +99 −274 File changed.Preview size limit exceeded, changes collapsed. Show changes