diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 0345bafee6..93a5b57563 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -5671,8 +5671,9 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea, const auto reqWidth = renderArea.getReqWidth(); const auto reqHeight = renderArea.getReqHeight(); - const auto sourceCrop = renderArea.getSourceCrop(); const auto rotation = renderArea.getRotationFlags(); + const auto transform = renderArea.getTransform(); + const auto sourceCrop = renderArea.getSourceCrop(); renderengine::DisplaySettings clientCompositionDisplay; std::vector<renderengine::LayerSettings> clientCompositionLayers; @@ -5680,31 +5681,34 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea, // assume that bounds are never offset, and that they are the same as the // buffer bounds. clientCompositionDisplay.physicalDisplay = Rect(reqWidth, reqHeight); - ui::Transform transform = renderArea.getTransform(); + clientCompositionDisplay.clip = sourceCrop; clientCompositionDisplay.globalTransform = transform.asMatrix4(); + + // Now take into account the rotation flag. We append a transform that + // rotates the layer stack about the origin, then translate by buffer + // boundaries to be in the right quadrant. mat4 rotMatrix; - // Displacement for repositioning the clipping rectangle after rotating it - // with the rotation hint. int displacementX = 0; int displacementY = 0; float rot90InRadians = 2.0f * static_cast<float>(M_PI) / 4.0f; switch (rotation) { case ui::Transform::ROT_90: rotMatrix = mat4::rotate(rot90InRadians, vec3(0, 0, 1)); - displacementX = reqWidth; + displacementX = renderArea.getBounds().getHeight(); break; case ui::Transform::ROT_180: rotMatrix = mat4::rotate(rot90InRadians * 2.0f, vec3(0, 0, 1)); - displacementX = reqWidth; - displacementY = reqHeight; + displacementY = renderArea.getBounds().getWidth(); + displacementX = renderArea.getBounds().getHeight(); break; case ui::Transform::ROT_270: rotMatrix = mat4::rotate(rot90InRadians * 3.0f, vec3(0, 0, 1)); - displacementY = reqHeight; + displacementY = renderArea.getBounds().getWidth(); break; default: break; } + // We need to transform the clipping window into the right spot. // First, rotate the clipping rectangle by the rotation hint to get the // right orientation @@ -5720,15 +5724,14 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea, // Now reposition the clipping rectangle with the displacement vector // computed above. const mat4 displacementMat = mat4::translate(vec4(displacementX, displacementY, 0, 1)); - clientCompositionDisplay.clip = Rect(newClipLeft + displacementX, newClipTop + displacementY, newClipRight + displacementX, newClipBottom + displacementY); - // We need to perform the same transformation in layer space, so propagate - // it to the global transform. mat4 clipTransform = displacementMat * rotMatrix; - clientCompositionDisplay.globalTransform *= clipTransform; + clientCompositionDisplay.globalTransform = + clipTransform * clientCompositionDisplay.globalTransform; + clientCompositionDisplay.outputDataspace = renderArea.getReqDataSpace(); clientCompositionDisplay.maxLuminance = DisplayDevice::sDefaultMaxLumiance; |