surfaceflinger: fix captureScreen for landscape LCM

Make DisplayRenderArea::getSourceCrop return the display scissor
when the source crop is empty.  Force the source crop to be empty in
captureScreen.  This makes sure the install orientation is applied
on the source crop once, not twice.

Bug: 113041375
Test: force primaryDisplayOrientation, rotate screen, and switch
      apps
Change-Id: I15006f867ff2d4a92ebccb1334ce59ab32abe69a
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 95dc554..ed73671 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -355,10 +355,14 @@
     bool isSecure() const override { return mDevice->isSecure(); }
 
     bool needsFiltering() const override {
+        // check if the projection from the logical display to the physical
+        // display needs filtering
         if (mDevice->needsFiltering()) {
             return true;
         }
 
+        // check if the projection from the logical render area (i.e., the
+        // physical display) to the physical render area requires filtering
         const Rect sourceCrop = getSourceCrop();
         int width = sourceCrop.width();
         int height = sourceCrop.height();
@@ -369,11 +373,17 @@
     }
 
     Rect getSourceCrop() const override {
+        // use the (projected) logical display viewport by default
+        if (mSourceCrop.isEmpty()) {
+            return mDevice->getScissor();
+        }
+
         const int orientation = mDevice->getInstallOrientation();
         if (orientation == DisplayState::eOrientationDefault) {
             return mSourceCrop;
         }
 
+        // Install orientation is transparent to the callers.  Apply it now.
         uint32_t flags = 0x00;
         switch (orientation) {
             case DisplayState::eOrientation90:
@@ -392,6 +402,8 @@
     }
 
 private:
+    // Install orientation is transparent to the callers.  We need to cancel
+    // it out by modifying rotation flags.
     static ui::Transform::orientation_flags getDisplayRotation(
             ui::Transform::orientation_flags rotation, int orientation) {
         if (orientation == DisplayState::eOrientationDefault) {