Loading services/surfaceflinger/BufferLayer.cpp +9 −47 Original line number Original line Diff line number Diff line Loading @@ -242,43 +242,17 @@ 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 @@ -287,20 +261,8 @@ 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)); } 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 +1 −15 Original line number Original line Diff line number Diff line Loading @@ -337,22 +337,8 @@ status_t BufferQueueLayer::updateFrameNumber(nsecs_t latchTime) { return NO_ERROR; return NO_ERROR; } } void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>& display) { void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>&) { 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 +1 −31 Original line number Original line Diff line number Diff line Loading @@ -65,48 +65,18 @@ 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; } } Loading services/surfaceflinger/DisplayHardware/HWComposer.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -498,7 +498,6 @@ status_t HWComposer::prepare(DisplayDevice& display, validateChange(compositionInfo.compositionType, validateChange(compositionInfo.compositionType, changedTypes[&*hwcLayer]); changedTypes[&*hwcLayer]); compositionInfo.compositionType = changedTypes[&*hwcLayer]; compositionInfo.compositionType = changedTypes[&*hwcLayer]; compositionInfo.layer->mLayer->setCompositionType(displayId, compositionInfo.compositionType, false); } } switch (compositionInfo.compositionType) { switch (compositionInfo.compositionType) { Loading services/surfaceflinger/Layer.cpp +21 −61 Original line number Original line Diff line number Diff line Loading @@ -494,6 +494,18 @@ 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 @@ -501,8 +513,6 @@ 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 @@ -510,12 +520,6 @@ 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 @@ -561,39 +565,14 @@ 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 @@ -607,10 +586,6 @@ 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 @@ -650,16 +625,9 @@ 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 @@ -745,28 +713,20 @@ void Layer::clearWithOpenGL(const RenderArea& renderArea, float red, float green } } void Layer::clearWithOpenGL(const RenderArea& renderArea) const { void Layer::clearWithOpenGL(const RenderArea& renderArea) const { clearWithOpenGL(renderArea, 0, 0, 0, 0); getBE().compositionInfo.firstClear = true; computeGeometry(renderArea, getBE().mMesh, false); } } 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 { auto& hwcInfo = getBE().mHwcLayers[displayId]; if (getBE().mHwcLayers[displayId].compositionType != type) { auto& hwcLayer = hwcInfo.layer; ALOGV("setCompositionType: Changing compositionType from %s to %s", ALOGV("setCompositionType(%" PRIx64 ", %s, %d)", (hwcLayer)->getId(), to_string(type).c_str(), to_string(getBE().mHwcLayers[displayId].compositionType).c_str(), static_cast<int>(callIntoHwc)); to_string(type).c_str()); if (hwcInfo.compositionType != type) { getBE().mHwcLayers[displayId].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 Loading
services/surfaceflinger/BufferLayer.cpp +9 −47 Original line number Original line Diff line number Diff line Loading @@ -242,43 +242,17 @@ 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 @@ -287,20 +261,8 @@ 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)); } 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 +1 −15 Original line number Original line Diff line number Diff line Loading @@ -337,22 +337,8 @@ status_t BufferQueueLayer::updateFrameNumber(nsecs_t latchTime) { return NO_ERROR; return NO_ERROR; } } void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>& display) { void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>&) { 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 +1 −31 Original line number Original line Diff line number Diff line Loading @@ -65,48 +65,18 @@ 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; } } Loading
services/surfaceflinger/DisplayHardware/HWComposer.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -498,7 +498,6 @@ status_t HWComposer::prepare(DisplayDevice& display, validateChange(compositionInfo.compositionType, validateChange(compositionInfo.compositionType, changedTypes[&*hwcLayer]); changedTypes[&*hwcLayer]); compositionInfo.compositionType = changedTypes[&*hwcLayer]; compositionInfo.compositionType = changedTypes[&*hwcLayer]; compositionInfo.layer->mLayer->setCompositionType(displayId, compositionInfo.compositionType, false); } } switch (compositionInfo.compositionType) { switch (compositionInfo.compositionType) { Loading
services/surfaceflinger/Layer.cpp +21 −61 Original line number Original line Diff line number Diff line Loading @@ -494,6 +494,18 @@ 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 @@ -501,8 +513,6 @@ 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 @@ -510,12 +520,6 @@ 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 @@ -561,39 +565,14 @@ 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 @@ -607,10 +586,6 @@ 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 @@ -650,16 +625,9 @@ 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 @@ -745,28 +713,20 @@ void Layer::clearWithOpenGL(const RenderArea& renderArea, float red, float green } } void Layer::clearWithOpenGL(const RenderArea& renderArea) const { void Layer::clearWithOpenGL(const RenderArea& renderArea) const { clearWithOpenGL(renderArea, 0, 0, 0, 0); getBE().compositionInfo.firstClear = true; computeGeometry(renderArea, getBE().mMesh, false); } } 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 { auto& hwcInfo = getBE().mHwcLayers[displayId]; if (getBE().mHwcLayers[displayId].compositionType != type) { auto& hwcLayer = hwcInfo.layer; ALOGV("setCompositionType: Changing compositionType from %s to %s", ALOGV("setCompositionType(%" PRIx64 ", %s, %d)", (hwcLayer)->getId(), to_string(type).c_str(), to_string(getBE().mHwcLayers[displayId].compositionType).c_str(), static_cast<int>(callIntoHwc)); to_string(type).c_str()); if (hwcInfo.compositionType != type) { getBE().mHwcLayers[displayId].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