Loading services/surfaceflinger/BufferLayer.cpp +53 −9 Original line number Original line Diff line number Diff line Loading @@ -234,17 +234,43 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& display) { const auto& viewport = display->getViewport(); const auto& viewport = display->getViewport(); Region visible = tr.transform(visibleRegion.intersect(viewport)); Region visible = tr.transform(visibleRegion.intersect(viewport)); const auto displayId = display->getId(); const auto displayId = display->getId(); if (!hasHwcLayer(displayId)) { ALOGE("[%s] failed to setPerFrameData: no HWC layer found (%d)", mName.string(), displayId); return; } auto& hwcInfo = getBE().mHwcLayers[displayId]; 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.visibleRegion = visible; 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); } getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; // Sideband layers // Sideband layers if (getBE().compositionInfo.hwc.sidebandStream.get()) { if (getBE().compositionInfo.hwc.sidebandStream.get()) { setCompositionType(displayId, HWC2::Composition::Sideband); setCompositionType(displayId, 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)); } getBE().compositionInfo.compositionType = HWC2::Composition::Sideband; getBE().compositionInfo.compositionType = HWC2::Composition::Sideband; return; return; } } if (getBE().compositionInfo.hwc.skipGeometry) { // Device or Cursor layers // Device or Cursor layers if (mPotentialCursor) { if (mPotentialCursor) { ALOGV("[%s] Requesting Cursor composition", mName.string()); ALOGV("[%s] Requesting Cursor composition", mName.string()); Loading @@ -253,8 +279,26 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& display) { ALOGV("[%s] Requesting Device composition", mName.string()); ALOGV("[%s] Requesting Device composition", mName.string()); setCompositionType(displayId, HWC2::Composition::Device); setCompositionType(displayId, HWC2::Composition::Device); } } ALOGV("setPerFrameData: dataspace = %d", mCurrentDataSpace); error = hwcLayer->setDataspace(mCurrentDataSpace); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mCurrentDataSpace, to_string(error).c_str(), static_cast<int32_t>(error)); } } const HdrMetadata& metadata = getDrawingHdrMetadata(); error = hwcLayer->setPerFrameMetadata(display->getSupportedPerFrameMetadata(), 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)); } error = hwcLayer->setColorTransform(getColorTransform()); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to setColorTransform: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; getBE().compositionInfo.hwc.hdrMetadata = getDrawingHdrMetadata(); getBE().compositionInfo.hwc.hdrMetadata = getDrawingHdrMetadata(); getBE().compositionInfo.hwc.supportedPerFrameMetadata = display->getSupportedPerFrameMetadata(); getBE().compositionInfo.hwc.supportedPerFrameMetadata = display->getSupportedPerFrameMetadata(); Loading services/surfaceflinger/BufferQueueLayer.cpp +15 −1 Original line number Original line Diff line number Diff line Loading @@ -327,8 +327,22 @@ status_t BufferQueueLayer::updateFrameNumber(nsecs_t latchTime) { return NO_ERROR; return NO_ERROR; } } void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>&) { void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>& display) { const auto displayId = display->getId(); auto& hwcInfo = getBE().mHwcLayers[displayId]; auto& hwcLayer = hwcInfo.layer; uint32_t hwcSlot = 0; sp<GraphicBuffer> hwcBuffer; hwcInfo.bufferCache.getHwcBuffer(mActiveBufferSlot, mActiveBuffer, &hwcSlot, &hwcBuffer); auto acquireFence = mConsumer->getCurrentFence(); auto acquireFence = mConsumer->getCurrentFence(); auto 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)); } getBE().compositionInfo.mBufferSlot = mActiveBufferSlot; getBE().compositionInfo.mBufferSlot = mActiveBufferSlot; getBE().compositionInfo.mBuffer = mActiveBuffer; getBE().compositionInfo.mBuffer = mActiveBuffer; getBE().compositionInfo.hwc.fence = acquireFence; getBE().compositionInfo.hwc.fence = acquireFence; Loading services/surfaceflinger/ColorLayer.cpp +48 −4 Original line number Original line Diff line number Diff line Loading @@ -62,20 +62,64 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& display) { const auto& viewport = display->getViewport(); const auto& viewport = display->getViewport(); Region visible = tr.transform(visibleRegion.intersect(viewport)); Region visible = tr.transform(visibleRegion.intersect(viewport)); const auto displayId = display->getId(); const auto displayId = display->getId(); if (!hasHwcLayer(displayId)) { ALOGE("[%s] failed to setPerFrameData: no HWC layer found (%d)", mName.string(), displayId); return; } auto& hwcInfo = getBE().mHwcLayers[displayId]; 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.visibleRegion = visible; getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; setCompositionType(displayId, HWC2::Composition::SolidColor); setCompositionType(displayId, HWC2::Composition::SolidColor); error = hwcLayer->setDataspace(mCurrentDataSpace); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mCurrentDataSpace, to_string(error).c_str(), static_cast<int32_t>(error)); } getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; half4 color = getColor(); half4 color = getColor(); 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}); 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)); } getBE().compositionInfo.hwc.color = { static_cast<uint8_t>(std::round(255.0f * color.r)), getBE().compositionInfo.hwc.color = { 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.g)), static_cast<uint8_t>(std::round(255.0f * color.b)), 255 }; static_cast<uint8_t>(std::round(255.0f * color.b)), 255 }; // Clear out the transform, because it doesn't make sense absent a source buffer // Clear out the transform, because it doesn't make sense absent a source buffer 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)); } getBE().compositionInfo.hwc.transform = HWC2::Transform::None; getBE().compositionInfo.hwc.transform = HWC2::Transform::None; error = hwcLayer->setColorTransform(getColorTransform()); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to setColorTransform: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } getBE().compositionInfo.hwc.colorTransform = getColorTransform(); getBE().compositionInfo.hwc.colorTransform = getColorTransform(); 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); } getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; } } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- Loading services/surfaceflinger/Layer.cpp +60 −19 Original line number Original line Diff line number Diff line Loading @@ -458,18 +458,6 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { } } auto& hwcInfo = getBE().mHwcLayers[displayId]; auto& hwcInfo = getBE().mHwcLayers[displayId]; // Device or Cursor layers if (mPotentialCursor) { ALOGV("[%s] Requesting Cursor composition", mName.string()); setCompositionType(displayId, HWC2::Composition::Cursor); } else { ALOGV("[%s] Requesting Device composition", mName.string()); setCompositionType(displayId, HWC2::Composition::Device); } // Need to program geometry parts getBE().compositionInfo.hwc.skipGeometry = false; // enable this layer // enable this layer hwcInfo.forceClientComposition = false; hwcInfo.forceClientComposition = false; Loading @@ -477,6 +465,8 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { hwcInfo.forceClientComposition = true; hwcInfo.forceClientComposition = true; } } auto& hwcLayer = hwcInfo.layer; // this gives us only the "orientation" component of the transform // this gives us only the "orientation" component of the transform const State& s(getDrawingState()); const State& s(getDrawingState()); auto blendMode = HWC2::BlendMode::None; auto blendMode = HWC2::BlendMode::None; Loading @@ -484,6 +474,12 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { blendMode = blendMode = mPremultipliedAlpha ? HWC2::BlendMode::Premultiplied : HWC2::BlendMode::Coverage; mPremultipliedAlpha ? HWC2::BlendMode::Premultiplied : HWC2::BlendMode::Coverage; } } 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)); getBE().compositionInfo.hwc.blendMode = blendMode; getBE().compositionInfo.hwc.blendMode = blendMode; // apply the layer's transform, followed by the display's global transform // apply the layer's transform, followed by the display's global transform Loading Loading @@ -523,14 +519,39 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { } } const ui::Transform& tr = display->getTransform(); const ui::Transform& tr = display->getTransform(); Rect transformedFrame = tr.transform(frame); Rect transformedFrame = tr.transform(frame); 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; } getBE().compositionInfo.hwc.displayFrame = transformedFrame; getBE().compositionInfo.hwc.displayFrame = transformedFrame; FloatRect sourceCrop = computeCrop(display); FloatRect sourceCrop = computeCrop(display); 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; } getBE().compositionInfo.hwc.sourceCrop = sourceCrop; getBE().compositionInfo.hwc.sourceCrop = sourceCrop; float alpha = static_cast<float>(getAlpha()); float alpha = static_cast<float>(getAlpha()); 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.alpha = alpha; getBE().compositionInfo.hwc.alpha = alpha; 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)); getBE().compositionInfo.hwc.z = z; getBE().compositionInfo.hwc.z = z; int type = s.type; int type = s.type; Loading @@ -544,6 +565,10 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { } } } } error = hwcLayer->setInfo(type, appId); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set info (%d)", mName.string(), static_cast<int32_t>(error)); getBE().compositionInfo.hwc.type = type; getBE().compositionInfo.hwc.type = type; getBE().compositionInfo.hwc.appId = appId; getBE().compositionInfo.hwc.appId = appId; Loading Loading @@ -583,9 +608,16 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { if (orientation & ui::Transform::ROT_INVALID) { if (orientation & ui::Transform::ROT_INVALID) { // we can only handle simple transformation // we can only handle simple transformation hwcInfo.forceClientComposition = true; hwcInfo.forceClientComposition = true; getBE().mHwcLayers[displayId].compositionType = HWC2::Composition::Client; } else { } else { auto transform = static_cast<HWC2::Transform>(orientation); auto transform = static_cast<HWC2::Transform>(orientation); hwcInfo.transform = transform; hwcInfo.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)); getBE().compositionInfo.hwc.transform = transform; getBE().compositionInfo.hwc.transform = transform; } } } } Loading Loading @@ -666,16 +698,25 @@ void Layer::clearWithOpenGL(const RenderArea& renderArea) const { clearWithOpenGL(renderArea, 0, 0, 0, 0); clearWithOpenGL(renderArea, 0, 0, 0, 0); } } void Layer::setCompositionType(int32_t displayId, HWC2::Composition type, bool /*callIntoHwc*/) { void Layer::setCompositionType(int32_t displayId, HWC2::Composition type, bool callIntoHwc) { if (getBE().mHwcLayers.count(displayId) == 0) { if (getBE().mHwcLayers.count(displayId) == 0) { ALOGE("setCompositionType called without a valid HWC layer"); ALOGE("setCompositionType called without a valid HWC layer"); return; return; } else { } if (getBE().mHwcLayers[displayId].compositionType != type) { auto& hwcInfo = getBE().mHwcLayers[displayId]; ALOGV("setCompositionType: Changing compositionType from %s to %s", auto& hwcLayer = hwcInfo.layer; to_string(getBE().mHwcLayers[displayId].compositionType).c_str(), ALOGV("setCompositionType(%" PRIx64 ", %s, %d)", (hwcLayer)->getId(), to_string(type).c_str(), to_string(type).c_str()); static_cast<int>(callIntoHwc)); getBE().mHwcLayers[displayId].compositionType = type; 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 services/surfaceflinger/LayerBE.cpp +1 −3 Original line number Original line Diff line number Diff line Loading @@ -65,10 +65,8 @@ LayerBE::LayerBE(const LayerBE& layer) } } void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) { void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) { if (mLayer) { mLayer->onLayerDisplayed(releaseFence); mLayer->onLayerDisplayed(releaseFence); } } } void LayerBE::clear(renderengine::RenderEngine& engine) { void LayerBE::clear(renderengine::RenderEngine& engine) { engine.setupFillWithColor(0, 0, 0, 0); engine.setupFillWithColor(0, 0, 0, 0); Loading Loading
services/surfaceflinger/BufferLayer.cpp +53 −9 Original line number Original line Diff line number Diff line Loading @@ -234,17 +234,43 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& display) { const auto& viewport = display->getViewport(); const auto& viewport = display->getViewport(); Region visible = tr.transform(visibleRegion.intersect(viewport)); Region visible = tr.transform(visibleRegion.intersect(viewport)); const auto displayId = display->getId(); const auto displayId = display->getId(); if (!hasHwcLayer(displayId)) { ALOGE("[%s] failed to setPerFrameData: no HWC layer found (%d)", mName.string(), displayId); return; } auto& hwcInfo = getBE().mHwcLayers[displayId]; 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.visibleRegion = visible; 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); } getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; // Sideband layers // Sideband layers if (getBE().compositionInfo.hwc.sidebandStream.get()) { if (getBE().compositionInfo.hwc.sidebandStream.get()) { setCompositionType(displayId, HWC2::Composition::Sideband); setCompositionType(displayId, 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)); } getBE().compositionInfo.compositionType = HWC2::Composition::Sideband; getBE().compositionInfo.compositionType = HWC2::Composition::Sideband; return; return; } } if (getBE().compositionInfo.hwc.skipGeometry) { // Device or Cursor layers // Device or Cursor layers if (mPotentialCursor) { if (mPotentialCursor) { ALOGV("[%s] Requesting Cursor composition", mName.string()); ALOGV("[%s] Requesting Cursor composition", mName.string()); Loading @@ -253,8 +279,26 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& display) { ALOGV("[%s] Requesting Device composition", mName.string()); ALOGV("[%s] Requesting Device composition", mName.string()); setCompositionType(displayId, HWC2::Composition::Device); setCompositionType(displayId, HWC2::Composition::Device); } } ALOGV("setPerFrameData: dataspace = %d", mCurrentDataSpace); error = hwcLayer->setDataspace(mCurrentDataSpace); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mCurrentDataSpace, to_string(error).c_str(), static_cast<int32_t>(error)); } } const HdrMetadata& metadata = getDrawingHdrMetadata(); error = hwcLayer->setPerFrameMetadata(display->getSupportedPerFrameMetadata(), 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)); } error = hwcLayer->setColorTransform(getColorTransform()); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to setColorTransform: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; getBE().compositionInfo.hwc.hdrMetadata = getDrawingHdrMetadata(); getBE().compositionInfo.hwc.hdrMetadata = getDrawingHdrMetadata(); getBE().compositionInfo.hwc.supportedPerFrameMetadata = display->getSupportedPerFrameMetadata(); getBE().compositionInfo.hwc.supportedPerFrameMetadata = display->getSupportedPerFrameMetadata(); Loading
services/surfaceflinger/BufferQueueLayer.cpp +15 −1 Original line number Original line Diff line number Diff line Loading @@ -327,8 +327,22 @@ status_t BufferQueueLayer::updateFrameNumber(nsecs_t latchTime) { return NO_ERROR; return NO_ERROR; } } void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>&) { void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>& display) { const auto displayId = display->getId(); auto& hwcInfo = getBE().mHwcLayers[displayId]; auto& hwcLayer = hwcInfo.layer; uint32_t hwcSlot = 0; sp<GraphicBuffer> hwcBuffer; hwcInfo.bufferCache.getHwcBuffer(mActiveBufferSlot, mActiveBuffer, &hwcSlot, &hwcBuffer); auto acquireFence = mConsumer->getCurrentFence(); auto acquireFence = mConsumer->getCurrentFence(); auto 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)); } getBE().compositionInfo.mBufferSlot = mActiveBufferSlot; getBE().compositionInfo.mBufferSlot = mActiveBufferSlot; getBE().compositionInfo.mBuffer = mActiveBuffer; getBE().compositionInfo.mBuffer = mActiveBuffer; getBE().compositionInfo.hwc.fence = acquireFence; getBE().compositionInfo.hwc.fence = acquireFence; Loading
services/surfaceflinger/ColorLayer.cpp +48 −4 Original line number Original line Diff line number Diff line Loading @@ -62,20 +62,64 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& display) { const auto& viewport = display->getViewport(); const auto& viewport = display->getViewport(); Region visible = tr.transform(visibleRegion.intersect(viewport)); Region visible = tr.transform(visibleRegion.intersect(viewport)); const auto displayId = display->getId(); const auto displayId = display->getId(); if (!hasHwcLayer(displayId)) { ALOGE("[%s] failed to setPerFrameData: no HWC layer found (%d)", mName.string(), displayId); return; } auto& hwcInfo = getBE().mHwcLayers[displayId]; 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.visibleRegion = visible; getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; setCompositionType(displayId, HWC2::Composition::SolidColor); setCompositionType(displayId, HWC2::Composition::SolidColor); error = hwcLayer->setDataspace(mCurrentDataSpace); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mCurrentDataSpace, to_string(error).c_str(), static_cast<int32_t>(error)); } getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; half4 color = getColor(); half4 color = getColor(); 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}); 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)); } getBE().compositionInfo.hwc.color = { static_cast<uint8_t>(std::round(255.0f * color.r)), getBE().compositionInfo.hwc.color = { 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.g)), static_cast<uint8_t>(std::round(255.0f * color.b)), 255 }; static_cast<uint8_t>(std::round(255.0f * color.b)), 255 }; // Clear out the transform, because it doesn't make sense absent a source buffer // Clear out the transform, because it doesn't make sense absent a source buffer 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)); } getBE().compositionInfo.hwc.transform = HWC2::Transform::None; getBE().compositionInfo.hwc.transform = HWC2::Transform::None; error = hwcLayer->setColorTransform(getColorTransform()); if (error != HWC2::Error::None) { ALOGE("[%s] Failed to setColorTransform: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } getBE().compositionInfo.hwc.colorTransform = getColorTransform(); getBE().compositionInfo.hwc.colorTransform = getColorTransform(); 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); } getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; } } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- Loading
services/surfaceflinger/Layer.cpp +60 −19 Original line number Original line Diff line number Diff line Loading @@ -458,18 +458,6 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { } } auto& hwcInfo = getBE().mHwcLayers[displayId]; auto& hwcInfo = getBE().mHwcLayers[displayId]; // Device or Cursor layers if (mPotentialCursor) { ALOGV("[%s] Requesting Cursor composition", mName.string()); setCompositionType(displayId, HWC2::Composition::Cursor); } else { ALOGV("[%s] Requesting Device composition", mName.string()); setCompositionType(displayId, HWC2::Composition::Device); } // Need to program geometry parts getBE().compositionInfo.hwc.skipGeometry = false; // enable this layer // enable this layer hwcInfo.forceClientComposition = false; hwcInfo.forceClientComposition = false; Loading @@ -477,6 +465,8 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { hwcInfo.forceClientComposition = true; hwcInfo.forceClientComposition = true; } } auto& hwcLayer = hwcInfo.layer; // this gives us only the "orientation" component of the transform // this gives us only the "orientation" component of the transform const State& s(getDrawingState()); const State& s(getDrawingState()); auto blendMode = HWC2::BlendMode::None; auto blendMode = HWC2::BlendMode::None; Loading @@ -484,6 +474,12 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { blendMode = blendMode = mPremultipliedAlpha ? HWC2::BlendMode::Premultiplied : HWC2::BlendMode::Coverage; mPremultipliedAlpha ? HWC2::BlendMode::Premultiplied : HWC2::BlendMode::Coverage; } } 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)); getBE().compositionInfo.hwc.blendMode = blendMode; getBE().compositionInfo.hwc.blendMode = blendMode; // apply the layer's transform, followed by the display's global transform // apply the layer's transform, followed by the display's global transform Loading Loading @@ -523,14 +519,39 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { } } const ui::Transform& tr = display->getTransform(); const ui::Transform& tr = display->getTransform(); Rect transformedFrame = tr.transform(frame); Rect transformedFrame = tr.transform(frame); 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; } getBE().compositionInfo.hwc.displayFrame = transformedFrame; getBE().compositionInfo.hwc.displayFrame = transformedFrame; FloatRect sourceCrop = computeCrop(display); FloatRect sourceCrop = computeCrop(display); 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; } getBE().compositionInfo.hwc.sourceCrop = sourceCrop; getBE().compositionInfo.hwc.sourceCrop = sourceCrop; float alpha = static_cast<float>(getAlpha()); float alpha = static_cast<float>(getAlpha()); 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.alpha = alpha; getBE().compositionInfo.hwc.alpha = alpha; 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)); getBE().compositionInfo.hwc.z = z; getBE().compositionInfo.hwc.z = z; int type = s.type; int type = s.type; Loading @@ -544,6 +565,10 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { } } } } error = hwcLayer->setInfo(type, appId); ALOGE_IF(error != HWC2::Error::None, "[%s] Failed to set info (%d)", mName.string(), static_cast<int32_t>(error)); getBE().compositionInfo.hwc.type = type; getBE().compositionInfo.hwc.type = type; getBE().compositionInfo.hwc.appId = appId; getBE().compositionInfo.hwc.appId = appId; Loading Loading @@ -583,9 +608,16 @@ void Layer::setGeometry(const sp<const DisplayDevice>& display, uint32_t z) { if (orientation & ui::Transform::ROT_INVALID) { if (orientation & ui::Transform::ROT_INVALID) { // we can only handle simple transformation // we can only handle simple transformation hwcInfo.forceClientComposition = true; hwcInfo.forceClientComposition = true; getBE().mHwcLayers[displayId].compositionType = HWC2::Composition::Client; } else { } else { auto transform = static_cast<HWC2::Transform>(orientation); auto transform = static_cast<HWC2::Transform>(orientation); hwcInfo.transform = transform; hwcInfo.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)); getBE().compositionInfo.hwc.transform = transform; getBE().compositionInfo.hwc.transform = transform; } } } } Loading Loading @@ -666,16 +698,25 @@ void Layer::clearWithOpenGL(const RenderArea& renderArea) const { clearWithOpenGL(renderArea, 0, 0, 0, 0); clearWithOpenGL(renderArea, 0, 0, 0, 0); } } void Layer::setCompositionType(int32_t displayId, HWC2::Composition type, bool /*callIntoHwc*/) { void Layer::setCompositionType(int32_t displayId, HWC2::Composition type, bool callIntoHwc) { if (getBE().mHwcLayers.count(displayId) == 0) { if (getBE().mHwcLayers.count(displayId) == 0) { ALOGE("setCompositionType called without a valid HWC layer"); ALOGE("setCompositionType called without a valid HWC layer"); return; return; } else { } if (getBE().mHwcLayers[displayId].compositionType != type) { auto& hwcInfo = getBE().mHwcLayers[displayId]; ALOGV("setCompositionType: Changing compositionType from %s to %s", auto& hwcLayer = hwcInfo.layer; to_string(getBE().mHwcLayers[displayId].compositionType).c_str(), ALOGV("setCompositionType(%" PRIx64 ", %s, %d)", (hwcLayer)->getId(), to_string(type).c_str(), to_string(type).c_str()); static_cast<int>(callIntoHwc)); getBE().mHwcLayers[displayId].compositionType = type; 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
services/surfaceflinger/LayerBE.cpp +1 −3 Original line number Original line Diff line number Diff line Loading @@ -65,10 +65,8 @@ LayerBE::LayerBE(const LayerBE& layer) } } void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) { void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) { if (mLayer) { mLayer->onLayerDisplayed(releaseFence); mLayer->onLayerDisplayed(releaseFence); } } } void LayerBE::clear(renderengine::RenderEngine& engine) { void LayerBE::clear(renderengine::RenderEngine& engine) { engine.setupFillWithColor(0, 0, 0, 0); engine.setupFillWithColor(0, 0, 0, 0); Loading