[SF, CE] Rename viewport, frame and destinationClip
This change introduces a new class ProjectionSpace and uses
it in OutputCompositionState to describe the layer stack space,
the physical display space and the oriented display space.
We rename viewport to layerStackSpaceRect, frame to
orientedDisplaySpaceRect and destinationClip displaySpaceRect.
This aims to provide better readibility of the code and
it's also consistent with SurfaceControl.setDisplayProjction
where layerStackRect and displayRect are used for viewport
and frame.
Bug: 161793589
Bug: 160404780
Test: m && flash device
Test: atest libsurfaceflinger_unittest libcompositionengine_test
Test: adb shell dumpsys SurfaceFlinger
Change-Id: Iee20b908157cbef4de4d9addf429f98356ec942d
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 7742503..725d3cd 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -61,7 +61,7 @@
output.writeUint32(transform);
output.writeBool(transformToDisplayInverse);
output.write(crop);
- output.write(frame);
+ output.write(orientedDisplaySpaceRect);
if (buffer) {
output.writeBool(true);
output.write(*buffer);
@@ -159,7 +159,7 @@
transform = input.readUint32();
transformToDisplayInverse = input.readBool();
input.read(crop);
- input.read(frame);
+ input.read(orientedDisplaySpaceRect);
buffer = new GraphicBuffer();
if (input.readBool()) {
input.read(*buffer);
@@ -216,15 +216,13 @@
return state.read(input);
}
-
-DisplayState::DisplayState() :
- what(0),
- layerStack(0),
- viewport(Rect::EMPTY_RECT),
- frame(Rect::EMPTY_RECT),
- width(0),
- height(0) {
-}
+DisplayState::DisplayState()
+ : what(0),
+ layerStack(0),
+ layerStackSpaceRect(Rect::EMPTY_RECT),
+ orientedDisplaySpaceRect(Rect::EMPTY_RECT),
+ width(0),
+ height(0) {}
status_t DisplayState::write(Parcel& output) const {
output.writeStrongBinder(token);
@@ -232,8 +230,8 @@
output.writeUint32(what);
output.writeUint32(layerStack);
output.writeUint32(toRotationInt(orientation));
- output.write(viewport);
- output.write(frame);
+ output.write(layerStackSpaceRect);
+ output.write(orientedDisplaySpaceRect);
output.writeUint32(width);
output.writeUint32(height);
return NO_ERROR;
@@ -245,8 +243,8 @@
what = input.readUint32();
layerStack = input.readUint32();
orientation = ui::toRotation(input.readUint32());
- input.read(viewport);
- input.read(frame);
+ input.read(layerStackSpaceRect);
+ input.read(orientedDisplaySpaceRect);
width = input.readUint32();
height = input.readUint32();
return NO_ERROR;
@@ -264,8 +262,8 @@
if (other.what & eDisplayProjectionChanged) {
what |= eDisplayProjectionChanged;
orientation = other.orientation;
- viewport = other.viewport;
- frame = other.frame;
+ layerStackSpaceRect = other.layerStackSpaceRect;
+ orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
}
if (other.what & eDisplaySizeChanged) {
what |= eDisplaySizeChanged;
@@ -368,7 +366,7 @@
}
if (other.what & eFrameChanged) {
what |= eFrameChanged;
- frame = other.frame;
+ orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
}
if (other.what & eBufferChanged) {
what |= eBufferChanged;
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index b51bf1f..62a3c45 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1137,7 +1137,7 @@
return *this;
}
s->what |= layer_state_t::eFrameChanged;
- s->frame = frame;
+ s->orientedDisplaySpaceRect = frame;
registerSurfaceControlForCallback(sc);
return *this;
@@ -1545,8 +1545,8 @@
const Rect& displayRect) {
DisplayState& s(getDisplayState(token));
s.orientation = orientation;
- s.viewport = layerStackRect;
- s.frame = displayRect;
+ s.layerStackSpaceRect = layerStackRect;
+ s.orientedDisplaySpaceRect = displayRect;
s.what |= DisplayState::eDisplayProjectionChanged;
mForceSynchronous = true; // TODO: do we actually still need this?
}
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 6a304ef..187e478 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -129,7 +129,7 @@
transform(0),
transformToDisplayInverse(false),
crop(Rect::INVALID_RECT),
- frame(Rect::INVALID_RECT),
+ orientedDisplaySpaceRect(Rect::INVALID_RECT),
dataspace(ui::Dataspace::UNKNOWN),
surfaceDamageRegion(),
api(-1),
@@ -192,7 +192,7 @@
uint32_t transform;
bool transformToDisplayInverse;
Rect crop;
- Rect frame;
+ Rect orientedDisplaySpaceRect;
sp<GraphicBuffer> buffer;
sp<Fence> acquireFence;
ui::Dataspace dataspace;
@@ -265,18 +265,18 @@
// These states define how layers are projected onto the physical display.
//
- // Layers are first clipped to `viewport'. They are then translated and
- // scaled from `viewport' to `frame'. Finally, they are rotated according
- // to `orientation', `width', and `height'.
+ // Layers are first clipped to `layerStackSpaceRect'. They are then translated and
+ // scaled from `layerStackSpaceRect' to `orientedDisplaySpaceRect'. Finally, they are rotated
+ // according to `orientation', `width', and `height'.
//
- // For example, assume viewport is Rect(0, 0, 200, 100), frame is Rect(20,
- // 10, 420, 210), and the size of the display is WxH. When orientation is
- // 0, layers will be scaled by a factor of 2 and translated by (20, 10).
- // When orientation is 1, layers will be additionally rotated by 90
- // degrees around the origin clockwise and translated by (W, 0).
+ // For example, assume layerStackSpaceRect is Rect(0, 0, 200, 100), orientedDisplaySpaceRect is
+ // Rect(20, 10, 420, 210), and the size of the display is WxH. When orientation is 0, layers
+ // will be scaled by a factor of 2 and translated by (20, 10). When orientation is 1, layers
+ // will be additionally rotated by 90 degrees around the origin clockwise and translated by (W,
+ // 0).
ui::Rotation orientation = ui::ROTATION_0;
- Rect viewport;
- Rect frame;
+ Rect layerStackSpaceRect;
+ Rect orientedDisplaySpaceRect;
uint32_t width, height;
diff --git a/libs/ui/DebugUtils.cpp b/libs/ui/DebugUtils.cpp
index f394635..1f006ce 100644
--- a/libs/ui/DebugUtils.cpp
+++ b/libs/ui/DebugUtils.cpp
@@ -321,10 +321,6 @@
return std::string("Unknown RenderIntent");
}
-std::string to_string(const android::Rect& rect) {
- return StringPrintf("(%4d,%4d,%4d,%4d)", rect.left, rect.top, rect.right, rect.bottom);
-}
-
std::string toString(const android::DeviceProductInfo::ManufactureOrModelDate& date) {
using ModelYear = android::DeviceProductInfo::ModelYear;
using ManufactureYear = android::DeviceProductInfo::ManufactureYear;
diff --git a/libs/ui/Rect.cpp b/libs/ui/Rect.cpp
index 13fed3a..a8d6285 100644
--- a/libs/ui/Rect.cpp
+++ b/libs/ui/Rect.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <android-base/stringprintf.h>
#include <system/graphics.h>
#include <ui/Rect.h>
@@ -149,4 +150,13 @@
return result;
}
+std::string to_string(const android::Rect& rect) {
+ return android::base::StringPrintf("Rect(%d, %d, %d, %d)", rect.left, rect.top, rect.right,
+ rect.bottom);
+}
+
+void PrintTo(const Rect& rect, ::std::ostream* os) {
+ *os << to_string(rect);
+}
+
}; // namespace android
diff --git a/libs/ui/include/ui/DebugUtils.h b/libs/ui/include/ui/DebugUtils.h
index 4685575..18cd487 100644
--- a/libs/ui/include/ui/DebugUtils.h
+++ b/libs/ui/include/ui/DebugUtils.h
@@ -34,5 +34,4 @@
std::string decodeColorTransform(android_color_transform colorTransform);
std::string decodePixelFormat(android::PixelFormat format);
std::string decodeRenderIntent(android::ui::RenderIntent renderIntent);
-std::string to_string(const android::Rect& rect);
std::string toString(const android::DeviceProductInfo&);
diff --git a/libs/ui/include/ui/DisplayState.h b/libs/ui/include/ui/DisplayState.h
index 64efc84..70a0d50 100644
--- a/libs/ui/include/ui/DisplayState.h
+++ b/libs/ui/include/ui/DisplayState.h
@@ -32,7 +32,7 @@
struct DisplayState {
LayerStack layerStack = NO_LAYER_STACK;
Rotation orientation = ROTATION_0;
- Size viewport;
+ Size layerStackSpaceRect;
};
static_assert(std::is_trivially_copyable_v<DisplayState>);
diff --git a/libs/ui/include/ui/Rect.h b/libs/ui/include/ui/Rect.h
index 2f2229e..6670dc0 100644
--- a/libs/ui/include/ui/Rect.h
+++ b/libs/ui/include/ui/Rect.h
@@ -19,10 +19,10 @@
#include <ostream>
+#include <log/log.h>
#include <utils/Flattenable.h>
#include <utils/Log.h>
#include <utils/TypeHelpers.h>
-#include <log/log.h>
#include <ui/FloatRect.h>
#include <ui/Point.h>
@@ -216,11 +216,10 @@
}
};
+std::string to_string(const android::Rect& rect);
+
// Defining PrintTo helps with Google Tests.
-static inline void PrintTo(const Rect& rect, ::std::ostream* os) {
- *os << "Rect(" << rect.left << ", " << rect.top << ", " << rect.right << ", " << rect.bottom
- << ")";
-}
+void PrintTo(const Rect& rect, ::std::ostream* os);
ANDROID_BASIC_TYPES_TRAITS(Rect)
diff --git a/libs/ui/include/ui/Rotation.h b/libs/ui/include/ui/Rotation.h
index 89008f6..83d431d 100644
--- a/libs/ui/include/ui/Rotation.h
+++ b/libs/ui/include/ui/Rotation.h
@@ -41,6 +41,15 @@
return toRotation((toRotationInt(lhs) + toRotationInt(rhs)) % N);
}
+constexpr Rotation operator-(Rotation lhs, Rotation rhs) {
+ constexpr auto N = toRotationInt(ROTATION_270) + 1;
+ return toRotation((N + toRotationInt(lhs) - toRotationInt(rhs)) % N);
+}
+
+constexpr Rotation operator-(Rotation rotation) {
+ return ROTATION_0 - rotation;
+}
+
constexpr const char* toCString(Rotation rotation) {
switch (rotation) {
case ROTATION_0:
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
index 26299e9..6cc7a53 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
@@ -163,11 +163,12 @@
virtual void setCompositionEnabled(bool) = 0;
// Sets the projection state to use
- virtual void setProjection(const ui::Transform&, uint32_t orientation, const Rect& frame,
- const Rect& viewport, const Rect& destinationClip,
+ virtual void setProjection(const ui::Transform&, uint32_t orientation,
+ const Rect& orientedDisplaySpaceRect,
+ const Rect& layerStackSpaceRect, const Rect& displaySpaceRect,
bool needsFiltering) = 0;
// Sets the bounds to use
- virtual void setBounds(const ui::Size&) = 0;
+ virtual void setDisplaySpaceSize(const ui::Size&) = 0;
// Sets the layer stack filtering settings for this output. See
// belongsInOutput for full details.
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/ProjectionSpace.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/ProjectionSpace.h
new file mode 100644
index 0000000..9d15665
--- /dev/null
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/ProjectionSpace.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <ostream>
+
+#include <android-base/stringprintf.h>
+#include <ui/Rect.h>
+#include <ui/Rotation.h>
+#include <ui/Transform.h>
+
+namespace android {
+namespace compositionengine {
+
+// Geometrical space to which content is projected.
+// For example, this can be the layer space or the physical display space.
+struct ProjectionSpace {
+ ProjectionSpace() = default;
+ ProjectionSpace(ui::Size size, Rect content)
+ : bounds(std::move(size)), content(std::move(content)) {}
+
+ // Bounds of this space. Always starts at (0,0).
+ Rect bounds;
+
+ // Rect onto which content is projected.
+ Rect content;
+};
+
+} // namespace compositionengine
+
+inline std::string to_string(const android::compositionengine::ProjectionSpace& space) {
+ return android::base::StringPrintf("ProjectionSpace(bounds = %s, content = %s)",
+ to_string(space.bounds).c_str(),
+ to_string(space.content).c_str());
+}
+
+// Defining PrintTo helps with Google Tests.
+inline void PrintTo(const android::compositionengine::ProjectionSpace& space, ::std::ostream* os) {
+ *os << to_string(space);
+}
+
+} // namespace android
\ No newline at end of file
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
index 0ac2545..57b7a97 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
@@ -38,10 +38,10 @@
bool isValid() const override;
std::optional<DisplayId> getDisplayId() const override;
void setCompositionEnabled(bool) override;
- void setProjection(const ui::Transform&, uint32_t orientation, const Rect& frame,
- const Rect& viewport, const Rect& destinationClip,
- bool needsFiltering) override;
- void setBounds(const ui::Size&) override;
+ void setProjection(const ui::Transform&, uint32_t orientation,
+ const Rect& orientedDisplaySpaceRect, const Rect& layerStackSpaceRect,
+ const Rect& displaySpaceRect, bool needsFiltering) override;
+ void setDisplaySpaceSize(const ui::Size&) override;
void setLayerStackFilter(uint32_t layerStackId, bool isInternal) override;
void setColorTransform(const compositionengine::CompositionRefreshArgs&) override;
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputCompositionState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputCompositionState.h
index 7120a48..462d952 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputCompositionState.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputCompositionState.h
@@ -29,6 +29,7 @@
// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop // ignored "-Wconversion"
+#include <compositionengine/ProjectionSpace.h>
#include <ui/Rect.h>
#include <ui/Region.h>
#include <ui/Transform.h>
@@ -50,8 +51,7 @@
// If true, the current frame on this output uses device composition
bool usesDeviceComposition{false};
- // If true, the client target should be flipped when performing client
- // composition
+ // If true, the client target should be flipped when performing client composition
bool flipClientTarget{false};
// If true, the current frame reused the buffer from a previous client composition
@@ -63,25 +63,26 @@
// The layer stack to display on this display
uint32_t layerStackId{~0u};
- // The physical space screen bounds
- Rect bounds;
+ // The common space for all layers in the layer stack. layerStackSpace.content is the Rect
+ // which gets projected on the display. The content in this space is always in a single
+ // orientation.
+ ProjectionSpace layerStackSpace;
- // The logical to physical transformation to use
+ // Oriented physical display space. It will have the same size as displaySpace oriented to
+ // match the orientation of layerStackSpace. The content in this space is always in a single
+ // orientation.
+ ProjectionSpace orientedDisplaySpace;
+
+ // The space of the physical display. It is as big as the currently active display mode. The
+ // content in this space can be rotated.
+ ProjectionSpace displaySpace;
+
+ // Transformation from layerStackSpace to displaySpace
ui::Transform transform;
- // The physical orientation of the display, expressed as ui::Transform
- // orientation flags.
+ // The physical orientation of the display, expressed as ui::Transform orientation flags.
uint32_t orientation{0};
- // The logical space user visible bounds
- Rect frame;
-
- // The logical space user viewport rectangle
- Rect viewport;
-
- // The physical space destination clip rectangle
- Rect destinationClip;
-
// If true, RenderEngine filtering should be enabled
bool needsFiltering{false};
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
index c4dff73..375d334 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
@@ -38,7 +38,7 @@
MOCK_METHOD1(setCompositionEnabled, void(bool));
MOCK_METHOD6(setProjection,
void(const ui::Transform&, uint32_t, const Rect&, const Rect&, const Rect&, bool));
- MOCK_METHOD1(setBounds, void(const ui::Size&));
+ MOCK_METHOD1(setDisplaySpaceSize, void(const ui::Size&));
MOCK_METHOD2(setLayerStackFilter, void(uint32_t, bool));
MOCK_METHOD1(setColorTransform, void(const compositionengine::CompositionRefreshArgs&));
diff --git a/services/surfaceflinger/CompositionEngine/src/DumpHelpers.cpp b/services/surfaceflinger/CompositionEngine/src/DumpHelpers.cpp
index 9598430..9d1bb02 100644
--- a/services/surfaceflinger/CompositionEngine/src/DumpHelpers.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/DumpHelpers.cpp
@@ -77,6 +77,7 @@
void dumpVal(std::string& out, const char* name, const ui::Transform& transform) {
transform.dump(out, name);
+ out.append(" ");
}
void dumpVal(std::string& out, const char* name, const ui::Size& size) {
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 670b969..9e0a43a 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -105,24 +105,32 @@
dirtyEntireOutput();
}
-void Output::setProjection(const ui::Transform& transform, uint32_t orientation, const Rect& frame,
- const Rect& viewport, const Rect& destinationClip, bool needsFiltering) {
+void Output::setProjection(const ui::Transform& transform, uint32_t orientation,
+ const Rect& orientedDisplaySpaceRect, const Rect& layerStackSpaceRect,
+ const Rect& displaySpaceRect, bool needsFiltering) {
auto& outputState = editState();
outputState.transform = transform;
outputState.orientation = orientation;
- outputState.destinationClip = destinationClip;
- outputState.frame = frame;
- outputState.viewport = viewport;
+ outputState.displaySpace.content = displaySpaceRect;
+ // outputState.displaySpace.bounds should be already set from setDisplaySpaceSize().
+ outputState.orientedDisplaySpace.content = orientedDisplaySpaceRect;
+
+ ui::Size orientedSize = outputState.displaySpace.bounds.getSize();
+ if (orientation == ui::Transform::ROT_90 || orientation == ui::Transform::ROT_270) {
+ std::swap(orientedSize.width, orientedSize.height);
+ }
+ outputState.orientedDisplaySpace.bounds = Rect(orientedSize);
+
+ outputState.layerStackSpace.content = layerStackSpaceRect;
+ outputState.layerStackSpace.bounds = layerStackSpaceRect;
outputState.needsFiltering = needsFiltering;
dirtyEntireOutput();
}
-// TODO(b/121291683): Rename setSize() once more is moved.
-void Output::setBounds(const ui::Size& size) {
+void Output::setDisplaySpaceSize(const ui::Size& size) {
mRenderSurface->setDisplaySize(size);
- // TODO(b/121291683): Rename outputState.size once more is moved.
- editState().bounds = Rect(mRenderSurface->getSize());
+ editState().displaySpace.bounds = Rect(mRenderSurface->getSize());
dirtyEntireOutput();
}
@@ -230,7 +238,7 @@
void Output::setRenderSurface(std::unique_ptr<compositionengine::RenderSurface> surface) {
mRenderSurface = std::move(surface);
- editState().bounds = Rect(mRenderSurface->getSize());
+ editState().displaySpace.bounds = Rect(mRenderSurface->getSize());
dirtyEntireOutput();
}
@@ -249,7 +257,7 @@
Region Output::getDirtyRegion(bool repaintEverything) const {
const auto& outputState = getState();
- Region dirty(outputState.viewport);
+ Region dirty(outputState.layerStackSpace.content);
if (!repaintEverything) {
dirty.andSelf(outputState.dirtyRegion);
}
@@ -334,7 +342,7 @@
// Compute the resulting coverage for this output, and store it for later
const ui::Transform& tr = outputState.transform;
- Region undefinedRegion{outputState.bounds};
+ Region undefinedRegion{outputState.displaySpace.bounds};
undefinedRegion.subtractSelf(tr.transform(coverage.aboveOpaqueLayers));
outputState.undefinedRegion = undefinedRegion;
@@ -537,7 +545,7 @@
// TODO(b/121291683): Why does this not use visibleRegion? (see outputSpaceVisibleRegion below)
const auto& outputState = getState();
Region drawRegion(outputState.transform.transform(visibleNonTransparentRegion));
- drawRegion.andSelf(outputState.bounds);
+ drawRegion.andSelf(outputState.displaySpace.bounds);
if (drawRegion.isEmpty()) {
return;
}
@@ -554,8 +562,8 @@
outputLayerState.visibleRegion = visibleRegion;
outputLayerState.visibleNonTransparentRegion = visibleNonTransparentRegion;
outputLayerState.coveredRegion = coveredRegion;
- outputLayerState.outputSpaceVisibleRegion =
- outputState.transform.transform(visibleNonShadowRegion.intersect(outputState.viewport));
+ outputLayerState.outputSpaceVisibleRegion = outputState.transform.transform(
+ visibleNonShadowRegion.intersect(outputState.layerStackSpace.content));
outputLayerState.shadowRegion = shadowRegion;
}
@@ -860,8 +868,8 @@
ALOGV("hasClientComposition");
renderengine::DisplaySettings clientCompositionDisplay;
- clientCompositionDisplay.physicalDisplay = outputState.destinationClip;
- clientCompositionDisplay.clip = outputState.viewport;
+ clientCompositionDisplay.physicalDisplay = outputState.displaySpace.content;
+ clientCompositionDisplay.clip = outputState.layerStackSpace.content;
clientCompositionDisplay.orientation = outputState.orientation;
clientCompositionDisplay.outputDataspace = mDisplayColorProfile->hasWideColorGamut()
? outputState.dataspace
@@ -945,7 +953,7 @@
ALOGV("Rendering client layers");
const auto& outputState = getState();
- const Region viewportRegion(outputState.viewport);
+ const Region viewportRegion(outputState.layerStackSpace.content);
bool firstLayer = true;
// Used when a layer clears part of the buffer.
Region stubRegion;
@@ -981,17 +989,17 @@
!layerState.visibleRegion.subtract(layerState.shadowRegion).isEmpty();
if (clientComposition || clearClientComposition) {
- compositionengine::LayerFE::ClientCompositionTargetSettings targetSettings{
- clip,
- layer->needsFiltering() || outputState.needsFiltering,
- outputState.isSecure,
- supportsProtectedContent,
- clientComposition ? clearRegion : stubRegion,
- outputState.viewport,
- outputDataspace,
- realContentIsVisible,
- !clientComposition, /* clearContent */
- };
+ compositionengine::LayerFE::ClientCompositionTargetSettings
+ targetSettings{.clip = clip,
+ .needsFiltering =
+ layer->needsFiltering() || outputState.needsFiltering,
+ .isSecure = outputState.isSecure,
+ .supportsProtectedContent = supportsProtectedContent,
+ .clearRegion = clientComposition ? clearRegion : stubRegion,
+ .viewport = outputState.layerStackSpace.content,
+ .dataspace = outputDataspace,
+ .realContentIsVisible = realContentIsVisible,
+ .clearContent = !clientComposition};
std::vector<LayerFE::LayerSettings> results =
layerFE.prepareClientCompositionList(targetSettings);
if (realContentIsVisible && !results.empty()) {
@@ -1088,7 +1096,7 @@
void Output::dirtyEntireOutput() {
auto& outputState = editState();
- outputState.dirtyRegion.set(outputState.bounds);
+ outputState.dirtyRegion.set(outputState.displaySpace.bounds);
}
void Output::chooseCompositionStrategy() {
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputCompositionState.cpp b/services/surfaceflinger/CompositionEngine/src/OutputCompositionState.cpp
index f3b2da1..776fdde 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputCompositionState.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputCompositionState.cpp
@@ -37,11 +37,12 @@
dumpVal(out, "transform", transform);
out.append("\n ");
-
- dumpVal(out, "bounds", bounds);
- dumpVal(out, "frame", frame);
- dumpVal(out, "viewport", viewport);
- dumpVal(out, "destinationClip", destinationClip);
+ dumpVal(out, "layerStackSpace", to_string(layerStackSpace));
+ out.append("\n ");
+ dumpVal(out, "orientedDisplaySpace", to_string(orientedDisplaySpace));
+ out.append("\n ");
+ dumpVal(out, "displaySpace", to_string(displaySpace));
+ out.append("\n ");
dumpVal(out, "needsFiltering", needsFiltering);
out.append("\n ");
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 1faf775..376b4b3 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -77,7 +77,7 @@
FloatRect activeCropFloat =
reduce(layerState.geomLayerBounds, layerState.transparentRegionHint);
- const Rect& viewport = getOutput().getState().viewport;
+ const Rect& viewport = getOutput().getState().layerStackSpace.content;
const ui::Transform& layerTransform = layerState.geomLayerTransform;
const ui::Transform& inverseLayerTransform = layerState.geomInverseLayerTransform;
// Transform to screen space.
@@ -189,7 +189,7 @@
Rect activeCrop = layerState.geomCrop;
if (!activeCrop.isEmpty() && bufferSize.isValid()) {
activeCrop = layerTransform.transform(activeCrop);
- if (!activeCrop.intersect(outputState.viewport, &activeCrop)) {
+ if (!activeCrop.intersect(outputState.layerStackSpace.content, &activeCrop)) {
activeCrop.clear();
}
activeCrop = inverseLayerTransform.transform(activeCrop, true);
@@ -215,7 +215,7 @@
// transformation. We then round upon constructing 'frame'.
Rect frame{
layerTransform.transform(reduce(layerState.geomLayerBounds, activeTransparentRegion))};
- if (!frame.intersect(outputState.viewport, &frame)) {
+ if (!frame.intersect(outputState.layerStackSpace.content, &frame)) {
frame.clear();
}
const ui::Transform displayTransform{outputState.transform};
@@ -568,7 +568,7 @@
const auto& outputState = getOutput().getState();
Rect frame = layerFEState->cursorFrame;
- frame.intersect(outputState.viewport, &frame);
+ frame.intersect(outputState.layerStackSpace.content, &frame);
Rect position = outputState.transform.transform(frame);
if (auto error = hwcLayer->setCursorPosition(position.left, position.top);
diff --git a/services/surfaceflinger/CompositionEngine/tests/DisplayTest.cpp b/services/surfaceflinger/CompositionEngine/tests/DisplayTest.cpp
index 378c050..4519a9d 100644
--- a/services/surfaceflinger/CompositionEngine/tests/DisplayTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/DisplayTest.cpp
@@ -908,7 +908,7 @@
mDisplay->editState().isEnabled = true;
mDisplay->editState().usesClientComposition = false;
- mDisplay->editState().viewport = Rect(0, 0, 1, 1);
+ mDisplay->editState().layerStackSpace.content = Rect(0, 0, 1, 1);
mDisplay->editState().dirtyRegion = Region::INVALID_REGION;
CompositionRefreshArgs refreshArgs;
@@ -929,7 +929,7 @@
nonHwcDisplay->editState().isEnabled = true;
nonHwcDisplay->editState().usesClientComposition = false;
- nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1);
+ nonHwcDisplay->editState().layerStackSpace.content = Rect(0, 0, 1, 1);
nonHwcDisplay->editState().dirtyRegion = Region::INVALID_REGION;
CompositionRefreshArgs refreshArgs;
@@ -950,7 +950,7 @@
nonHwcDisplay->editState().isEnabled = true;
nonHwcDisplay->editState().usesClientComposition = false;
- nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1);
+ nonHwcDisplay->editState().layerStackSpace.content = Rect(0, 0, 1, 1);
nonHwcDisplay->editState().dirtyRegion = Region(Rect(0, 0, 1, 1));
CompositionRefreshArgs refreshArgs;
@@ -971,7 +971,7 @@
nonHwcDisplay->editState().isEnabled = true;
nonHwcDisplay->editState().usesClientComposition = false;
- nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1);
+ nonHwcDisplay->editState().layerStackSpace.content = Rect(0, 0, 1, 1);
nonHwcDisplay->editState().dirtyRegion = Region::INVALID_REGION;
CompositionRefreshArgs refreshArgs;
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
index 020f93a..df3da85 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
@@ -138,7 +138,7 @@
mLayerFEState.geomBufferSize = Rect{0, 0, 1920, 1080};
mLayerFEState.geomBufferTransform = TR_IDENT;
- mOutputState.viewport = Rect{0, 0, 1920, 1080};
+ mOutputState.layerStackSpace.content = Rect{0, 0, 1920, 1080};
}
FloatRect calculateOutputSourceCrop() {
@@ -223,7 +223,7 @@
}
TEST_F(OutputLayerSourceCropTest, viewportAffectsCrop) {
- mOutputState.viewport = Rect{0, 0, 960, 540};
+ mOutputState.layerStackSpace.content = Rect{0, 0, 960, 540};
const FloatRect expected{0.f, 0.f, 960.f, 540.f};
EXPECT_THAT(calculateOutputSourceCrop(), expected);
@@ -245,7 +245,7 @@
mLayerFEState.geomCrop = Rect{0, 0, 1920, 1080};
mLayerFEState.geomLayerBounds = FloatRect{0.f, 0.f, 1920.f, 1080.f};
- mOutputState.viewport = Rect{0, 0, 1920, 1080};
+ mOutputState.layerStackSpace.content = Rect{0, 0, 1920, 1080};
mOutputState.transform = ui::Transform{TR_IDENT};
}
@@ -293,7 +293,7 @@
}
TEST_F(OutputLayerDisplayFrameTest, viewportAffectsFrame) {
- mOutputState.viewport = Rect{0, 0, 960, 540};
+ mOutputState.layerStackSpace.content = Rect{0, 0, 960, 540};
const Rect expected{0, 0, 960, 540};
EXPECT_THAT(calculateOutputDisplayFrame(), expected);
}
@@ -988,7 +988,7 @@
mLayerFEState.cursorFrame = kDefaultCursorFrame;
- mOutputState.viewport = kDefaultDisplayViewport;
+ mOutputState.layerStackSpace.content = kDefaultDisplayViewport;
mOutputState.transform = ui::Transform{kDefaultTransform};
}
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
index fdaf907..3dd26c0 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
@@ -136,7 +136,7 @@
std::unique_ptr<DisplayColorProfile>(mDisplayColorProfile));
mOutput->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(mRenderSurface));
- mOutput->editState().bounds = kDefaultDisplaySize;
+ mOutput->editState().displaySpace.bounds = kDefaultDisplaySize;
}
void injectOutputLayer(InjectedLayer& layer) {
@@ -248,14 +248,14 @@
EXPECT_THAT(mOutput->getState().transform, transform);
EXPECT_EQ(orientation, mOutput->getState().orientation);
- EXPECT_EQ(frame, mOutput->getState().frame);
- EXPECT_EQ(viewport, mOutput->getState().viewport);
- EXPECT_EQ(destinationClip, mOutput->getState().destinationClip);
+ EXPECT_EQ(frame, mOutput->getState().orientedDisplaySpace.content);
+ EXPECT_EQ(viewport, mOutput->getState().layerStackSpace.content);
+ EXPECT_EQ(destinationClip, mOutput->getState().displaySpace.content);
EXPECT_EQ(needsFiltering, mOutput->getState().needsFiltering);
}
/*
- * Output::setBounds()
+ * Output::setDisplaySpaceSize()
*/
TEST_F(OutputTest, setBoundsSetsSizeAndDirtiesEntireOutput) {
@@ -264,9 +264,9 @@
EXPECT_CALL(*mRenderSurface, setDisplaySize(displaySize)).Times(1);
EXPECT_CALL(*mRenderSurface, getSize()).WillOnce(ReturnRef(displaySize));
- mOutput->setBounds(displaySize);
+ mOutput->setDisplaySpaceSize(displaySize);
- EXPECT_EQ(Rect(displaySize), mOutput->getState().bounds);
+ EXPECT_EQ(Rect(displaySize), mOutput->getState().displaySpace.bounds);
EXPECT_THAT(mOutput->getState().dirtyRegion, RegionEq(Region(Rect(displaySize))));
}
@@ -429,7 +429,7 @@
mOutput->setRenderSurface(std::unique_ptr<RenderSurface>(renderSurface));
- EXPECT_EQ(Rect(newDisplaySize), mOutput->getState().bounds);
+ EXPECT_EQ(Rect(newDisplaySize), mOutput->getState().displaySpace.bounds);
}
/*
@@ -438,7 +438,7 @@
TEST_F(OutputTest, getDirtyRegionWithRepaintEverythingTrue) {
const Rect viewport{100, 200};
- mOutput->editState().viewport = viewport;
+ mOutput->editState().layerStackSpace.content = viewport;
mOutput->editState().dirtyRegion.set(50, 300);
{
@@ -450,7 +450,7 @@
TEST_F(OutputTest, getDirtyRegionWithRepaintEverythingFalse) {
const Rect viewport{100, 200};
- mOutput->editState().viewport = viewport;
+ mOutput->editState().layerStackSpace.content = viewport;
mOutput->editState().dirtyRegion.set(50, 300);
{
@@ -858,7 +858,7 @@
OutputRebuildLayerStacksTest() {
mOutput.mState.isEnabled = true;
mOutput.mState.transform = kIdentityTransform;
- mOutput.mState.bounds = kOutputBounds;
+ mOutput.mState.displaySpace.bounds = kOutputBounds;
mRefreshArgs.updatingOutputGeometryThisFrame = true;
@@ -1065,8 +1065,8 @@
EXPECT_CALL(mOutput, getOutputLayerOrderedByZByIndex(0u))
.WillRepeatedly(Return(&mLayer.outputLayer));
- mOutput.mState.bounds = Rect(0, 0, 200, 300);
- mOutput.mState.viewport = Rect(0, 0, 200, 300);
+ mOutput.mState.displaySpace.bounds = Rect(0, 0, 200, 300);
+ mOutput.mState.layerStackSpace.content = Rect(0, 0, 200, 300);
mOutput.mState.transform = ui::Transform(TR_IDENT, 200, 300);
mLayer.layerFEState.isVisible = true;
@@ -1146,7 +1146,7 @@
}
TEST_F(OutputEnsureOutputLayerIfVisibleTest, takesNotSoEarlyOutifDrawRegionEmpty) {
- mOutput.mState.bounds = Rect(0, 0, 0, 0);
+ mOutput.mState.displaySpace.bounds = Rect(0, 0, 0, 0);
ensureOutputLayerIfVisible();
}
@@ -1343,7 +1343,7 @@
mLayer.layerFEState.contentDirty = true;
mLayer.layerFEState.geomLayerTransform = ui::Transform(TR_IDENT, 100, 200);
- mOutput.mState.viewport = Rect(0, 0, 300, 200);
+ mOutput.mState.layerStackSpace.content = Rect(0, 0, 300, 200);
mOutput.mState.transform = ui::Transform(TR_ROT_90, 200, 300);
EXPECT_CALL(mOutput, getOutputLayerCount()).WillOnce(Return(0u));
@@ -1369,7 +1369,7 @@
mLayer.layerFEState.contentDirty = true;
mLayer.layerFEState.geomLayerTransform = ui::Transform(TR_IDENT, 100, 200);
- mOutput.mState.viewport = Rect(0, 0, 300, 200);
+ mOutput.mState.layerStackSpace.content = Rect(0, 0, 300, 200);
mOutput.mState.transform = ui::Transform(TR_ROT_90, 200, 300);
EXPECT_CALL(mOutput, ensureOutputLayer(Eq(0u), Eq(mLayer.layerFE)))
@@ -2783,9 +2783,9 @@
mOutput.setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(mRenderSurface));
mOutput.cacheClientCompositionRequests(MAX_CLIENT_COMPOSITION_CACHE_SIZE);
- mOutput.mState.frame = kDefaultOutputFrame;
- mOutput.mState.viewport = kDefaultOutputViewport;
- mOutput.mState.destinationClip = kDefaultOutputDestinationClip;
+ mOutput.mState.orientedDisplaySpace.content = kDefaultOutputFrame;
+ mOutput.mState.layerStackSpace.content = kDefaultOutputViewport;
+ mOutput.mState.displaySpace.content = kDefaultOutputDestinationClip;
mOutput.mState.transform = ui::Transform{kDefaultOutputOrientation};
mOutput.mState.orientation = kDefaultOutputOrientation;
mOutput.mState.dataspace = kDefaultOutputDataspace;
@@ -3409,9 +3409,9 @@
struct GenerateClientCompositionRequestsTest_ThreeLayers
: public GenerateClientCompositionRequestsTest {
GenerateClientCompositionRequestsTest_ThreeLayers() {
- mOutput.mState.frame = kDisplayFrame;
- mOutput.mState.viewport = kDisplayViewport;
- mOutput.mState.destinationClip = kDisplayDestinationClip;
+ mOutput.mState.orientedDisplaySpace.content = kDisplayFrame;
+ mOutput.mState.layerStackSpace.content = kDisplayViewport;
+ mOutput.mState.displaySpace.content = kDisplayDestinationClip;
mOutput.mState.transform = ui::Transform{kDisplayOrientation};
mOutput.mState.orientation = kDisplayOrientation;
mOutput.mState.needsFiltering = false;
@@ -3924,9 +3924,9 @@
const uint32_t kPortraitOrientation = TR_ROT_90;
constexpr ui::Dataspace kOutputDataspace = ui::Dataspace::DISPLAY_P3;
- mOutput.mState.frame = kPortraitFrame;
- mOutput.mState.viewport = kPortraitViewport;
- mOutput.mState.destinationClip = kPortraitDestinationClip;
+ mOutput.mState.orientedDisplaySpace.content = kPortraitFrame;
+ mOutput.mState.layerStackSpace.content = kPortraitViewport;
+ mOutput.mState.displaySpace.content = kPortraitDestinationClip;
mOutput.mState.transform = ui::Transform{kPortraitOrientation};
mOutput.mState.orientation = kPortraitOrientation;
mOutput.mState.needsFiltering = false;
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index a4fc833..016b6ca 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -29,6 +29,7 @@
#include <compositionengine/DisplayColorProfileCreationArgs.h>
#include <compositionengine/DisplayCreationArgs.h>
#include <compositionengine/DisplaySurface.h>
+#include <compositionengine/ProjectionSpace.h>
#include <compositionengine/RenderSurface.h>
#include <compositionengine/RenderSurfaceCreationArgs.h>
#include <compositionengine/impl/OutputCompositionState.h>
@@ -101,11 +102,11 @@
}
int DisplayDevice::getWidth() const {
- return mCompositionDisplay->getState().bounds.getWidth();
+ return mCompositionDisplay->getState().displaySpace.bounds.getWidth();
}
int DisplayDevice::getHeight() const {
- return mCompositionDisplay->getState().bounds.getHeight();
+ return mCompositionDisplay->getState().displaySpace.bounds.getHeight();
}
void DisplayDevice::setDisplayName(const std::string& displayName) {
@@ -155,13 +156,14 @@
}
void DisplayDevice::setDisplaySize(int width, int height) {
- mCompositionDisplay->setBounds(ui::Size(width, height));
+ mCompositionDisplay->setDisplaySpaceSize(ui::Size(width, height));
}
-void DisplayDevice::setProjection(ui::Rotation orientation, Rect viewport, Rect frame) {
+void DisplayDevice::setProjection(ui::Rotation orientation, Rect layerStackSpaceRect,
+ Rect orientedDisplaySpaceRect) {
mOrientation = orientation;
- const Rect& displayBounds = getCompositionDisplay()->getState().bounds;
+ const Rect& displayBounds = getCompositionDisplay()->getState().displaySpace.bounds;
const int displayWidth = displayBounds.width();
const int displayHeight = displayBounds.height();
@@ -171,40 +173,38 @@
rotation.set(flags, displayWidth, displayHeight);
}
- if (!frame.isValid()) {
+ if (!orientedDisplaySpaceRect.isValid()) {
// the destination frame can be invalid if it has never been set,
// in that case we assume the whole display frame.
- frame = Rect(displayWidth, displayHeight);
+ orientedDisplaySpaceRect = Rect(displayWidth, displayHeight);
}
- if (viewport.isEmpty()) {
- // viewport can be invalid if it has never been set, in that case
+ if (layerStackSpaceRect.isEmpty()) {
+ // layerStackSpaceRect can be invalid if it has never been set, in that case
// we assume the whole display size.
- // it's also invalid to have an empty viewport, so we handle that
+ // It's also invalid to have an empty layerStackSpaceRect, so we handle that
// case in the same way.
- viewport = Rect(displayWidth, displayHeight);
+ layerStackSpaceRect = Rect(displayWidth, displayHeight);
if (rotation.getOrientation() & ui::Transform::ROT_90) {
- // viewport is always specified in the logical orientation
- // of the display (ie: post-rotation).
- std::swap(viewport.right, viewport.bottom);
+ std::swap(layerStackSpaceRect.right, layerStackSpaceRect.bottom);
}
}
ui::Transform logicalTranslation, physicalTranslation, scale;
- const float sourceWidth = viewport.width();
- const float sourceHeight = viewport.height();
- const float destWidth = frame.width();
- const float destHeight = frame.height();
+ const float sourceWidth = layerStackSpaceRect.width();
+ const float sourceHeight = layerStackSpaceRect.height();
+ const float destWidth = orientedDisplaySpaceRect.width();
+ const float destHeight = orientedDisplaySpaceRect.height();
if (sourceWidth != destWidth || sourceHeight != destHeight) {
const float scaleX = destWidth / sourceWidth;
const float scaleY = destHeight / sourceHeight;
scale.set(scaleX, 0, 0, scaleY);
}
- const float sourceX = viewport.left;
- const float sourceY = viewport.top;
- const float destX = frame.left;
- const float destY = frame.top;
+ const float sourceX = layerStackSpaceRect.left;
+ const float sourceY = layerStackSpaceRect.top;
+ const float destX = orientedDisplaySpaceRect.left;
+ const float destY = orientedDisplaySpaceRect.top;
logicalTranslation.set(-sourceX, -sourceY);
physicalTranslation.set(destX, destY);
@@ -217,7 +217,7 @@
}
}
- // The viewport and frame are both in the logical orientation.
+ // The layerStackSpaceRect and orientedDisplaySpaceRect are both in the logical orientation.
// Apply the logical translation, scale to physical size, apply the
// physical translation and finally rotate to the physical orientation.
ui::Transform globalTransform = rotation * physicalTranslation * scale * logicalTranslation;
@@ -226,12 +226,12 @@
const bool needsFiltering =
(!globalTransform.preserveRects() || (type >= ui::Transform::SCALE));
- Rect destinationClip = globalTransform.transform(viewport);
- if (destinationClip.isEmpty()) {
- destinationClip = displayBounds;
+ Rect displaySpaceRect = globalTransform.transform(layerStackSpaceRect);
+ if (displaySpaceRect.isEmpty()) {
+ displaySpaceRect = displayBounds;
}
- // Make sure the destination clip is contained in the display bounds
- destinationClip.intersect(displayBounds, &destinationClip);
+ // Make sure the displaySpaceRect is contained in the display bounds
+ displaySpaceRect.intersect(displayBounds, &displaySpaceRect);
uint32_t transformOrientation;
@@ -242,8 +242,9 @@
transformOrientation = ui::Transform::toRotationFlags(orientation);
}
- getCompositionDisplay()->setProjection(globalTransform, transformOrientation, frame, viewport,
- destinationClip, needsFiltering);
+ getCompositionDisplay()->setProjection(globalTransform, transformOrientation,
+ orientedDisplaySpaceRect, layerStackSpaceRect,
+ displaySpaceRect, needsFiltering);
}
ui::Transform::RotationFlags DisplayDevice::getPrimaryDisplayRotationFlags() {
@@ -296,7 +297,7 @@
}
const Rect& DisplayDevice::getBounds() const {
- return mCompositionDisplay->getState().bounds;
+ return mCompositionDisplay->getState().displaySpace.bounds;
}
const Region& DisplayDevice::getUndefinedRegion() const {
@@ -315,12 +316,12 @@
return mCompositionDisplay->getState().transform;
}
-const Rect& DisplayDevice::getViewport() const {
- return mCompositionDisplay->getState().viewport;
+const Rect& DisplayDevice::getLayerStackSpaceRect() const {
+ return mCompositionDisplay->getState().layerStackSpace.content;
}
-const Rect& DisplayDevice::getFrame() const {
- return mCompositionDisplay->getState().frame;
+const Rect& DisplayDevice::getOrientedDisplaySpaceRect() const {
+ return mCompositionDisplay->getState().orientedDisplaySpace.content;
}
bool DisplayDevice::hasWideColorGamut() const {
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 1319679..35a8b62 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -99,8 +99,8 @@
}
const ui::Transform& getTransform() const;
- const Rect& getViewport() const;
- const Rect& getFrame() const;
+ const Rect& getLayerStackSpaceRect() const;
+ const Rect& getOrientedDisplaySpaceRect() const;
bool needsFiltering() const;
ui::LayerStack getLayerStack() const;
@@ -208,8 +208,8 @@
std::optional<Physical> physical;
sp<IGraphicBufferProducer> surface;
ui::LayerStack layerStack = ui::NO_LAYER_STACK;
- Rect viewport;
- Rect frame;
+ Rect layerStackSpaceRect;
+ Rect orientedDisplaySpaceRect;
ui::Rotation orientation = ui::ROTATION_0;
uint32_t width = 0;
uint32_t height = 0;
diff --git a/services/surfaceflinger/DisplayRenderArea.cpp b/services/surfaceflinger/DisplayRenderArea.cpp
index d7157b1..9a6b328 100644
--- a/services/surfaceflinger/DisplayRenderArea.cpp
+++ b/services/surfaceflinger/DisplayRenderArea.cpp
@@ -49,7 +49,7 @@
DisplayRenderArea::DisplayRenderArea(sp<const DisplayDevice> display, const Rect& sourceCrop,
ui::Size reqSize, ui::Dataspace reqDataSpace,
bool useIdentityTransform, bool allowSecureLayers)
- : RenderArea(reqSize, CaptureFill::OPAQUE, reqDataSpace, display->getViewport(),
+ : RenderArea(reqSize, CaptureFill::OPAQUE, reqDataSpace, display->getLayerStackSpaceRect(),
allowSecureLayers, applyDeviceOrientation(useIdentityTransform, *display)),
mDisplay(std::move(display)),
mSourceCrop(sourceCrop) {}
@@ -93,7 +93,7 @@
Rect DisplayRenderArea::getSourceCrop() const {
// use the projected display viewport by default.
if (mSourceCrop.isEmpty()) {
- return mDisplay->getViewport();
+ return mDisplay->getLayerStackSpaceRect();
}
// Correct for the orientation when the screen capture request contained
@@ -101,8 +101,8 @@
// it needs to rotate based on the screen orientation to allow the screenshot
// to be taken in the ROT_0 orientation
const auto flags = getRotationFlags();
- int width = mDisplay->getViewport().getWidth();
- int height = mDisplay->getViewport().getHeight();
+ int width = mDisplay->getLayerStackSpaceRect().getWidth();
+ int height = mDisplay->getLayerStackSpaceRect().getHeight();
ui::Transform rotation;
rotation.set(flags, width, height);
return rotation.transform(mSourceCrop);
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index eb33175..138d08c 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -647,9 +647,9 @@
}
std::optional<compositionengine::LayerFE::LayerSettings> Layer::prepareShadowClientComposition(
- const LayerFE::LayerSettings& casterLayerSettings, const Rect& displayViewport,
+ const LayerFE::LayerSettings& casterLayerSettings, const Rect& layerStackRect,
ui::Dataspace outputDataspace) {
- renderengine::ShadowSettings shadow = getShadowSettings(displayViewport);
+ renderengine::ShadowSettings shadow = getShadowSettings(layerStackRect);
if (shadow.length <= 0.f) {
return {};
}
@@ -2158,12 +2158,12 @@
: RoundedCornerState();
}
-renderengine::ShadowSettings Layer::getShadowSettings(const Rect& viewport) const {
+renderengine::ShadowSettings Layer::getShadowSettings(const Rect& layerStackRect) const {
renderengine::ShadowSettings state = mFlinger->mDrawingState.globalShadowSettings;
// Shift the spot light x-position to the middle of the display and then
// offset it by casting layer's screen pos.
- state.lightPos.x = (viewport.width() / 2.f) - mScreenBounds.left;
+ state.lightPos.x = (layerStackRect.width() / 2.f) - mScreenBounds.left;
state.lightPos.y -= mScreenBounds.top;
state.length = mEffectiveShadowRadius;
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 8d8ab6d..521659d 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -366,7 +366,7 @@
virtual bool setMetadata(const LayerMetadata& data);
bool reparentChildren(const sp<IBinder>& newParentHandle);
void reparentChildren(const sp<Layer>& newParent);
- virtual void setChildrenDrawingParent(const sp<Layer>& layer);
+ virtual void setChildrenDrawingParent(const sp<Layer>&);
virtual bool reparent(const sp<IBinder>& newParentHandle);
virtual bool detachChildren();
bool attachChildren();
@@ -535,7 +535,7 @@
// Write drawing or current state. If writing current state, the caller should hold the
// external mStateLock. If writing drawing state, this function should be called on the
// main or tracing thread.
- void writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet stateSet,
+ void writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet,
uint32_t traceFlags = SurfaceTracing::TRACE_ALL);
virtual Geometry getActiveGeometry(const Layer::State& s) const { return s.active_legacy; }
@@ -585,16 +585,16 @@
void updateClonedChildren(const sp<Layer>& mirrorRoot,
std::map<sp<Layer>, sp<Layer>>& clonedLayersMap);
void updateClonedRelatives(const std::map<sp<Layer>, sp<Layer>>& clonedLayersMap);
- void addChildToDrawing(const sp<Layer>& layer);
+ void addChildToDrawing(const sp<Layer>&);
void updateClonedInputInfo(const std::map<sp<Layer>, sp<Layer>>& clonedLayersMap);
virtual std::optional<compositionengine::LayerFE::LayerSettings> prepareClientComposition(
compositionengine::LayerFE::ClientCompositionTargetSettings&);
virtual std::optional<compositionengine::LayerFE::LayerSettings> prepareShadowClientComposition(
- const LayerFE::LayerSettings& layerSettings, const Rect& displayViewport,
+ const LayerFE::LayerSettings&, const Rect& layerStackRect,
ui::Dataspace outputDataspace);
// Modifies the passed in layer settings to clear the contents. If the blackout flag is set,
// the settings clears the content with a solid black fill.
- void prepareClearClientComposition(LayerFE::LayerSettings& layerSettings, bool blackout) const;
+ void prepareClearClientComposition(LayerFE::LayerSettings&, bool blackout) const;
public:
/*
@@ -756,7 +756,7 @@
// ignored.
virtual RoundedCornerState getRoundedCornerState() const;
- renderengine::ShadowSettings getShadowSettings(const Rect& viewport) const;
+ renderengine::ShadowSettings getShadowSettings(const Rect& layerStackRect) const;
/**
* Traverse this layer and it's hierarchy of children directly. Unlike traverseInZOrder
@@ -766,17 +766,15 @@
* the scene state, but it's also more efficient than traverseInZOrder and so useful for
* book-keeping.
*/
- void traverse(LayerVector::StateSet stateSet, const LayerVector::Visitor& visitor);
- void traverseInReverseZOrder(LayerVector::StateSet stateSet,
- const LayerVector::Visitor& visitor);
- void traverseInZOrder(LayerVector::StateSet stateSet, const LayerVector::Visitor& visitor);
+ void traverse(LayerVector::StateSet, const LayerVector::Visitor&);
+ void traverseInReverseZOrder(LayerVector::StateSet, const LayerVector::Visitor&);
+ void traverseInZOrder(LayerVector::StateSet, const LayerVector::Visitor&);
/**
* Traverse only children in z order, ignoring relative layers that are not children of the
* parent.
*/
- void traverseChildrenInZOrder(LayerVector::StateSet stateSet,
- const LayerVector::Visitor& visitor);
+ void traverseChildrenInZOrder(LayerVector::StateSet, const LayerVector::Visitor&);
size_t getChildrenCount() const;
@@ -788,7 +786,7 @@
// the current state, but should not be called anywhere else!
LayerVector& getCurrentChildren() { return mCurrentChildren; }
- void addChild(const sp<Layer>& layer);
+ void addChild(const sp<Layer>&);
// Returns index if removed, or negative value otherwise
// for symmetry with Vector::remove
ssize_t removeChild(const sp<Layer>& layer);
@@ -802,7 +800,7 @@
// Copy the current list of children to the drawing state. Called by
// SurfaceFlinger to complete a transaction.
void commitChildList();
- int32_t getZ(LayerVector::StateSet stateSet) const;
+ int32_t getZ(LayerVector::StateSet) const;
virtual void pushPendingState();
/**
@@ -828,7 +826,7 @@
*/
Rect getCroppedBufferSize(const Layer::State& s) const;
- bool setFrameRate(FrameRate frameRate);
+ bool setFrameRate(FrameRate);
virtual FrameRate getFrameRateForLayerTree() const;
static std::string frameRateCompatibilityString(FrameRateCompatibility compatibility);
@@ -870,8 +868,8 @@
* crop coordinates, transforming them into layer space.
*/
void setupRoundedCornersCropCoordinates(Rect win, const FloatRect& roundedCornersCrop) const;
- void setParent(const sp<Layer>& layer);
- LayerVector makeTraversalList(LayerVector::StateSet stateSet, bool* outSkipRelativeZUsers);
+ void setParent(const sp<Layer>&);
+ LayerVector makeTraversalList(LayerVector::StateSet, bool* outSkipRelativeZUsers);
void addZOrderRelative(const wp<Layer>& relative);
void removeZOrderRelative(const wp<Layer>& relative);
@@ -970,7 +968,7 @@
protected:
compositionengine::OutputLayer* findOutputLayerForDisplay(const DisplayDevice*) const;
- bool usingRelativeZ(LayerVector::StateSet stateSet) const;
+ bool usingRelativeZ(LayerVector::StateSet) const;
bool mPremultipliedAlpha{true};
const std::string mName;
@@ -1050,15 +1048,14 @@
* Returns an unsorted vector of all layers that are part of this tree.
* That includes the current layer and all its descendants.
*/
- std::vector<Layer*> getLayersInTree(LayerVector::StateSet stateSet);
+ std::vector<Layer*> getLayersInTree(LayerVector::StateSet);
/**
* Traverses layers that are part of this tree in the correct z order.
* layersInTree must be sorted before calling this method.
*/
void traverseChildrenInZOrderInner(const std::vector<Layer*>& layersInTree,
- LayerVector::StateSet stateSet,
- const LayerVector::Visitor& visitor);
- LayerVector makeChildrenTraversalList(LayerVector::StateSet stateSet,
+ LayerVector::StateSet, const LayerVector::Visitor&);
+ LayerVector makeChildrenTraversalList(LayerVector::StateSet,
const std::vector<Layer*>& layersInTree);
void updateTreeHasFrameRateVote();
diff --git a/services/surfaceflinger/LayerRenderArea.cpp b/services/surfaceflinger/LayerRenderArea.cpp
index 555e61d..e84508f 100644
--- a/services/surfaceflinger/LayerRenderArea.cpp
+++ b/services/surfaceflinger/LayerRenderArea.cpp
@@ -44,8 +44,8 @@
LayerRenderArea::LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop,
ui::Size reqSize, ui::Dataspace reqDataSpace, bool childrenOnly,
- const Rect& displayViewport, bool allowSecureLayers)
- : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, displayViewport, allowSecureLayers),
+ const Rect& layerStackRect, bool allowSecureLayers)
+ : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, layerStackRect, allowSecureLayers),
mLayer(std::move(layer)),
mCrop(crop),
mFlinger(flinger),
diff --git a/services/surfaceflinger/LayerRenderArea.h b/services/surfaceflinger/LayerRenderArea.h
index 71ff1ce..6a90694 100644
--- a/services/surfaceflinger/LayerRenderArea.h
+++ b/services/surfaceflinger/LayerRenderArea.h
@@ -33,7 +33,7 @@
class LayerRenderArea : public RenderArea {
public:
LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop, ui::Size reqSize,
- ui::Dataspace reqDataSpace, bool childrenOnly, const Rect& displayViewport,
+ ui::Dataspace reqDataSpace, bool childrenOnly, const Rect& layerStackRect,
bool allowSecureLayers);
const ui::Transform& getTransform() const override;
diff --git a/services/surfaceflinger/RenderArea.h b/services/surfaceflinger/RenderArea.h
index b4bddac..c9f7f46 100644
--- a/services/surfaceflinger/RenderArea.h
+++ b/services/surfaceflinger/RenderArea.h
@@ -24,14 +24,14 @@
static float getCaptureFillValue(CaptureFill captureFill);
RenderArea(ui::Size reqSize, CaptureFill captureFill, ui::Dataspace reqDataSpace,
- const Rect& displayViewport, bool allowSecureLayers = false,
+ const Rect& layerStackRect, bool allowSecureLayers = false,
RotationFlags rotation = ui::Transform::ROT_0)
: mAllowSecureLayers(allowSecureLayers),
mReqSize(reqSize),
mReqDataSpace(reqDataSpace),
mCaptureFill(captureFill),
mRotationFlags(rotation),
- mDisplayViewport(displayViewport) {}
+ mLayerStackSpaceRect(layerStackRect) {}
virtual ~RenderArea() = default;
@@ -83,7 +83,7 @@
virtual sp<const DisplayDevice> getDisplayDevice() const = 0;
// Returns the source display viewport.
- const Rect& getDisplayViewport() const { return mDisplayViewport; }
+ const Rect& getLayerStackSpaceRect() const { return mLayerStackSpaceRect; }
protected:
const bool mAllowSecureLayers;
@@ -93,7 +93,7 @@
const ui::Dataspace mReqDataSpace;
const CaptureFill mCaptureFill;
const RotationFlags mRotationFlags;
- const Rect mDisplayViewport;
+ const Rect mLayerStackSpaceRect;
};
} // namespace android
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index ca9f629..d9d8bd2 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -862,8 +862,9 @@
state->layerStack = display->getLayerStack();
state->orientation = display->getOrientation();
- const Rect viewport = display->getViewport();
- state->viewport = viewport.isValid() ? viewport.getSize() : display->getSize();
+ const Rect layerStackRect = display->getLayerStackSpaceRect();
+ state->layerStackSpaceRect =
+ layerStackRect.isValid() ? layerStackRect.getSize() : display->getSize();
return NO_ERROR;
}
@@ -2368,7 +2369,7 @@
}
FloatRect SurfaceFlinger::getLayerClipBoundsForDisplay(const DisplayDevice& displayDevice) const {
- return displayDevice.getViewport().toFloatRect();
+ return displayDevice.getLayerStackSpaceRect().toFloatRect();
}
void SurfaceFlinger::computeLayerBounds() {
@@ -2569,7 +2570,8 @@
}
display->setLayerStack(state.layerStack);
- display->setProjection(state.orientation, state.viewport, state.frame);
+ display->setProjection(state.orientation, state.layerStackSpaceRect,
+ state.orientedDisplaySpaceRect);
display->setDisplayName(state.displayName);
return display;
@@ -2698,10 +2700,10 @@
display->setLayerStack(currentState.layerStack);
}
if ((currentState.orientation != drawingState.orientation) ||
- (currentState.viewport != drawingState.viewport) ||
- (currentState.frame != drawingState.frame)) {
- display->setProjection(currentState.orientation, currentState.viewport,
- currentState.frame);
+ (currentState.layerStackSpaceRect != drawingState.layerStackSpaceRect) ||
+ (currentState.orientedDisplaySpaceRect != drawingState.orientedDisplaySpaceRect)) {
+ display->setProjection(currentState.orientation, currentState.layerStackSpaceRect,
+ currentState.orientedDisplaySpaceRect);
}
if (currentState.width != drawingState.width ||
currentState.height != drawingState.height) {
@@ -3568,12 +3570,12 @@
state.orientation = s.orientation;
flags |= eDisplayTransactionNeeded;
}
- if (state.frame != s.frame) {
- state.frame = s.frame;
+ if (state.orientedDisplaySpaceRect != s.orientedDisplaySpaceRect) {
+ state.orientedDisplaySpaceRect = s.orientedDisplaySpaceRect;
flags |= eDisplayTransactionNeeded;
}
- if (state.viewport != s.viewport) {
- state.viewport = s.viewport;
+ if (state.layerStackSpaceRect != s.layerStackSpaceRect) {
+ state.layerStackSpaceRect = s.layerStackSpaceRect;
flags |= eDisplayTransactionNeeded;
}
}
@@ -3808,7 +3810,7 @@
if (layer->setCrop(s.crop)) flags |= eTraversalNeeded;
}
if (what & layer_state_t::eFrameChanged) {
- if (layer->setFrame(s.frame)) flags |= eTraversalNeeded;
+ if (layer->setFrame(s.orientedDisplaySpaceRect)) flags |= eTraversalNeeded;
}
if (what & layer_state_t::eAcquireFenceChanged) {
if (layer->setAcquireFence(s.acquireFence)) flags |= eTraversalNeeded;
@@ -4191,8 +4193,8 @@
d.token = token;
d.layerStack = 0;
d.orientation = ui::ROTATION_0;
- d.frame.makeInvalid();
- d.viewport.makeInvalid();
+ d.orientedDisplaySpaceRect.makeInvalid();
+ d.layerStackSpaceRect.makeInvalid();
d.width = 0;
d.height = 0;
displays.add(d);
@@ -5476,10 +5478,9 @@
displayWeak = display;
layerStack = display->getLayerStack();
- // set the requested width/height to the logical display viewport size
- // by default
+ // set the requested width/height to the logical display layer stack rect size by default
if (args.width == 0 || args.height == 0) {
- reqSize = display->getViewport().getSize();
+ reqSize = display->getLayerStackSpaceRect().getSize();
}
const ui::ColorMode colorMode = display->getCompositionDisplay()->getState().colorMode;
@@ -5552,7 +5553,7 @@
layerStack = display->getLayerStack();
displayWeak = display;
- size = display->getViewport().getSize();
+ size = display->getLayerStackSpaceRect().getSize();
dataspace =
pickDataspaceFromColorMode(display->getCompositionDisplay()->getState().colorMode);
@@ -5586,7 +5587,7 @@
sp<Layer> parent;
Rect crop(args.sourceCrop);
std::unordered_set<sp<Layer>, ISurfaceComposer::SpHash<Layer>> excludeLayers;
- Rect displayViewport;
+ Rect layerStackSpaceRect;
ui::Dataspace dataspace;
bool captureSecureLayers;
{
@@ -5638,7 +5639,7 @@
return NAME_NOT_FOUND;
}
- displayViewport = display->getViewport();
+ layerStackSpaceRect = display->getLayerStackSpaceRect();
const ui::ColorMode colorMode = display->getCompositionDisplay()->getState().colorMode;
dataspace = pickDataspaceFromColorMode(colorMode);
@@ -5657,7 +5658,7 @@
bool childrenOnly = args.childrenOnly;
RenderAreaFuture renderAreaFuture = promise::defer([=]() -> std::unique_ptr<RenderArea> {
return std::make_unique<LayerRenderArea>(*this, parent, crop, reqSize, dataspace,
- childrenOnly, displayViewport,
+ childrenOnly, layerStackSpaceRect,
captureSecureLayers);
});
@@ -5778,7 +5779,7 @@
const auto sourceCrop = renderArea.getSourceCrop();
const auto transform = renderArea.getTransform();
const auto rotation = renderArea.getRotationFlags();
- const auto& displayViewport = renderArea.getDisplayViewport();
+ const auto& layerStackSpaceRect = renderArea.getLayerStackSpaceRect();
renderengine::DisplaySettings clientCompositionDisplay;
std::vector<compositionengine::LayerFE::LayerSettings> clientCompositionLayers;
@@ -5815,7 +5816,7 @@
renderArea.isSecure(),
supportProtectedContent,
clearRegion,
- displayViewport,
+ layerStackSpaceRect,
clientCompositionDisplay.outputDataspace,
true, /* realContentIsVisible */
false, /* clearContent */
diff --git a/services/surfaceflinger/SurfaceInterceptor.cpp b/services/surfaceflinger/SurfaceInterceptor.cpp
index 80102bd..8ec5274 100644
--- a/services/surfaceflinger/SurfaceInterceptor.cpp
+++ b/services/surfaceflinger/SurfaceInterceptor.cpp
@@ -143,7 +143,7 @@
addDisplayLayerStackLocked(transaction, display.sequenceId, display.layerStack);
addDisplaySizeLocked(transaction, display.sequenceId, display.width, display.height);
addDisplayProjectionLocked(transaction, display.sequenceId, toRotationInt(display.orientation),
- display.viewport, display.frame);
+ display.layerStackSpaceRect, display.orientedDisplaySpaceRect);
}
status_t SurfaceInterceptor::writeProtoFileLocked() {
@@ -483,7 +483,7 @@
}
if (state.what & DisplayState::eDisplayProjectionChanged) {
addDisplayProjectionLocked(transaction, sequenceId, toRotationInt(state.orientation),
- state.viewport, state.frame);
+ state.layerStackSpaceRect, state.orientedDisplaySpaceRect);
}
}
diff --git a/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp b/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp
index 06e8761..db0c56f 100644
--- a/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp
+++ b/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp
@@ -90,7 +90,7 @@
};
TEST_F(MultiDisplayLayerBoundsTest, RenderLayerInVirtualDisplay) {
- createDisplay(mMainDisplayState.viewport, 1 /* layerStack */);
+ createDisplay(mMainDisplayState.layerStackSpaceRect, 1 /* layerStack */);
createColorLayer(1 /* layerStack */);
asTransaction([&](Transaction& t) { t.setPosition(mColorLayer, 10, 10); });
@@ -111,9 +111,9 @@
// Create a display and set its layer stack to the main display's layer stack so
// the contents of the main display are mirrored on to the virtual display.
- // Assumption here is that the new mirrored display has the same viewport as the
+ // Assumption here is that the new mirrored display has the same layer stack rect as the
// primary display that it is mirroring.
- createDisplay(mMainDisplayState.viewport, 0 /* layerStack */);
+ createDisplay(mMainDisplayState.layerStackSpaceRect, 0 /* layerStack */);
createColorLayer(0 /* layerStack */);
asTransaction([&](Transaction& t) { t.setPosition(mColorLayer, 10, 10); });
diff --git a/services/surfaceflinger/tests/TransactionTestHarnesses.h b/services/surfaceflinger/tests/TransactionTestHarnesses.h
index f0af363..01badf4 100644
--- a/services/surfaceflinger/tests/TransactionTestHarnesses.h
+++ b/services/surfaceflinger/tests/TransactionTestHarnesses.h
@@ -65,7 +65,7 @@
t.setDisplaySurface(vDisplay, producer);
t.setDisplayLayerStack(vDisplay, 0);
t.setDisplayProjection(vDisplay, displayState.orientation,
- Rect(displayState.viewport), Rect(resolution));
+ Rect(displayState.layerStackSpaceRect), Rect(resolution));
t.apply();
SurfaceComposerClient::Transaction().apply(true);
BufferItem item;
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
index 6086a05..7fade0d 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
@@ -1523,9 +1523,9 @@
mHardwareDisplaySize.height),
compositionState.transform);
EXPECT_EQ(TRANSFORM_FLAGS_ROT_0, compositionState.orientation);
- EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.destinationClip);
- EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.frame);
- EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.viewport);
+ EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.displaySpace.content);
+ EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.orientedDisplaySpace.content);
+ EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.layerStackSpace.content);
EXPECT_EQ(false, compositionState.needsFiltering);
}
@@ -1535,10 +1535,12 @@
mHardwareDisplaySize.height),
compositionState.transform);
EXPECT_EQ(TRANSFORM_FLAGS_ROT_90, compositionState.orientation);
- EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.destinationClip);
- // For 90, the frame and viewport have the hardware display size width and height swapped
- EXPECT_EQ(Rect(SwapWH(mHardwareDisplaySize)), compositionState.frame);
- EXPECT_EQ(Rect(SwapWH(mHardwareDisplaySize)), compositionState.viewport);
+ EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.displaySpace.content);
+ // For 90, the orientedDisplaySpaceRect and layerStackSpaceRect have the hardware display
+ // size width and height swapped
+ EXPECT_EQ(Rect(SwapWH(mHardwareDisplaySize)),
+ compositionState.orientedDisplaySpace.content);
+ EXPECT_EQ(Rect(SwapWH(mHardwareDisplaySize)), compositionState.layerStackSpace.content);
EXPECT_EQ(false, compositionState.needsFiltering);
}
@@ -1548,8 +1550,8 @@
mHardwareDisplaySize.height),
compositionState.transform);
EXPECT_EQ(TRANSFORM_FLAGS_ROT_180, compositionState.orientation);
- EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.frame);
- EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.viewport);
+ EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.orientedDisplaySpace.content);
+ EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.layerStackSpace.content);
EXPECT_EQ(false, compositionState.needsFiltering);
}
@@ -1559,10 +1561,12 @@
mHardwareDisplaySize.height),
compositionState.transform);
EXPECT_EQ(TRANSFORM_FLAGS_ROT_270, compositionState.orientation);
- EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.destinationClip);
- // For 270, the frame and viewport have the hardware display size width and height swapped
- EXPECT_EQ(Rect(SwapWH(mHardwareDisplaySize)), compositionState.frame);
- EXPECT_EQ(Rect(SwapWH(mHardwareDisplaySize)), compositionState.viewport);
+ EXPECT_EQ(Rect(mHardwareDisplaySize), compositionState.displaySpace.content);
+ // For 270, the orientedDisplaySpaceRect and layerStackSpaceRect have the hardware display
+ // size width and height swapped
+ EXPECT_EQ(Rect(SwapWH(mHardwareDisplaySize)),
+ compositionState.orientedDisplaySpace.content);
+ EXPECT_EQ(Rect(SwapWH(mHardwareDisplaySize)), compositionState.layerStackSpace.content);
EXPECT_EQ(false, compositionState.needsFiltering);
}
@@ -2484,11 +2488,11 @@
EXPECT_EQ(newTransform, display.mutableDisplayDevice()->getOrientation());
}
-TEST_F(HandleTransactionLockedTest, processesDisplayViewportChanges) {
+TEST_F(HandleTransactionLockedTest, processesDisplayLayerStackRectChanges) {
using Case = NonHwcVirtualDisplayCase;
- const Rect oldViewport(0, 0, 0, 0);
- const Rect newViewport(0, 0, 123, 456);
+ const Rect oldLayerStackRect(0, 0, 0, 0);
+ const Rect newLayerStackRect(0, 0, 123, 456);
// --------------------------------------------------------------------
// Preconditions
@@ -2497,9 +2501,9 @@
auto display = Case::Display::makeFakeExistingDisplayInjector(this);
display.inject();
- // There is a change to the viewport state
- display.mutableDrawingDisplayState().viewport = oldViewport;
- display.mutableCurrentDisplayState().viewport = newViewport;
+ // There is a change to the layerStackSpaceRect state
+ display.mutableDrawingDisplayState().layerStackSpaceRect = oldLayerStackRect;
+ display.mutableCurrentDisplayState().layerStackSpaceRect = newLayerStackRect;
// --------------------------------------------------------------------
// Invocation
@@ -2509,7 +2513,7 @@
// --------------------------------------------------------------------
// Postconditions
- EXPECT_EQ(newViewport, display.mutableDisplayDevice()->getViewport());
+ EXPECT_EQ(newLayerStackRect, display.mutableDisplayDevice()->getLayerStackSpaceRect());
}
TEST_F(HandleTransactionLockedTest, processesDisplayFrameChanges) {
@@ -2525,9 +2529,9 @@
auto display = Case::Display::makeFakeExistingDisplayInjector(this);
display.inject();
- // There is a change to the viewport state
- display.mutableDrawingDisplayState().frame = oldFrame;
- display.mutableCurrentDisplayState().frame = newFrame;
+ // There is a change to the layerStackSpaceRect state
+ display.mutableDrawingDisplayState().orientedDisplaySpaceRect = oldFrame;
+ display.mutableCurrentDisplayState().orientedDisplaySpaceRect = newFrame;
// --------------------------------------------------------------------
// Invocation
@@ -2537,7 +2541,7 @@
// --------------------------------------------------------------------
// Postconditions
- EXPECT_EQ(newFrame, display.mutableDisplayDevice()->getFrame());
+ EXPECT_EQ(newFrame, display.mutableDisplayDevice()->getOrientedDisplaySpaceRect());
}
TEST_F(HandleTransactionLockedTest, processesDisplayWidthChanges) {
@@ -2568,7 +2572,7 @@
EXPECT_CALL(*nativeWindow, perform(NATIVE_WINDOW_API_DISCONNECT)).Times(1);
display.inject();
- // There is a change to the viewport state
+ // There is a change to the layerStackSpaceRect state
display.mutableDrawingDisplayState().width = oldWidth;
display.mutableDrawingDisplayState().height = oldHeight;
display.mutableCurrentDisplayState().width = newWidth;
@@ -2613,7 +2617,7 @@
EXPECT_CALL(*nativeWindow, perform(NATIVE_WINDOW_API_DISCONNECT)).Times(1);
display.inject();
- // There is a change to the viewport state
+ // There is a change to the layerStackSpaceRect state
display.mutableDrawingDisplayState().width = oldWidth;
display.mutableDrawingDisplayState().height = oldHeight;
display.mutableCurrentDisplayState().width = oldWidth;
@@ -2834,8 +2838,8 @@
TEST_F(DisplayTransactionTest, setDisplayStateLockedDoesNothingIfProjectionDidNotChange) {
using Case = SimplePrimaryDisplayCase;
constexpr ui::Rotation initialOrientation = ui::ROTATION_180;
- const Rect initialFrame = {1, 2, 3, 4};
- const Rect initialViewport = {5, 6, 7, 8};
+ const Rect initialOrientedDisplayRect = {1, 2, 3, 4};
+ const Rect initialLayerStackRect = {5, 6, 7, 8};
// --------------------------------------------------------------------
// Preconditions
@@ -2846,16 +2850,16 @@
// The current display state projection state is all set
display.mutableCurrentDisplayState().orientation = initialOrientation;
- display.mutableCurrentDisplayState().frame = initialFrame;
- display.mutableCurrentDisplayState().viewport = initialViewport;
+ display.mutableCurrentDisplayState().orientedDisplaySpaceRect = initialOrientedDisplayRect;
+ display.mutableCurrentDisplayState().layerStackSpaceRect = initialLayerStackRect;
// The incoming request sets the same projection state
DisplayState state;
state.what = DisplayState::eDisplayProjectionChanged;
state.token = display.token();
state.orientation = initialOrientation;
- state.frame = initialFrame;
- state.viewport = initialViewport;
+ state.orientedDisplaySpaceRect = initialOrientedDisplayRect;
+ state.layerStackSpaceRect = initialLayerStackRect;
// --------------------------------------------------------------------
// Invocation
@@ -2871,8 +2875,9 @@
// The current display state is unchanged
EXPECT_EQ(initialOrientation, display.getCurrentDisplayState().orientation);
- EXPECT_EQ(initialFrame, display.getCurrentDisplayState().frame);
- EXPECT_EQ(initialViewport, display.getCurrentDisplayState().viewport);
+ EXPECT_EQ(initialOrientedDisplayRect,
+ display.getCurrentDisplayState().orientedDisplaySpaceRect);
+ EXPECT_EQ(initialLayerStackRect, display.getCurrentDisplayState().layerStackSpaceRect);
}
TEST_F(DisplayTransactionTest, setDisplayStateLockedRequestsUpdateIfOrientationChanged) {
@@ -2913,8 +2918,8 @@
TEST_F(DisplayTransactionTest, setDisplayStateLockedRequestsUpdateIfFrameChanged) {
using Case = SimplePrimaryDisplayCase;
- const Rect initialFrame = {0, 0, 0, 0};
- const Rect desiredFrame = {5, 6, 7, 8};
+ const Rect initialOrientedDisplayRect = {0, 0, 0, 0};
+ const Rect desiredOrientedDisplayRect = {5, 6, 7, 8};
// --------------------------------------------------------------------
// Preconditions
@@ -2923,14 +2928,14 @@
auto display = Case::Display::makeFakeExistingDisplayInjector(this);
display.inject();
- // The current display state does not have a frame
- display.mutableCurrentDisplayState().frame = initialFrame;
+ // The current display state does not have a orientedDisplaySpaceRect
+ display.mutableCurrentDisplayState().orientedDisplaySpaceRect = initialOrientedDisplayRect;
- // The incoming request sets a frame
+ // The incoming request sets a orientedDisplaySpaceRect
DisplayState state;
state.what = DisplayState::eDisplayProjectionChanged;
state.token = display.token();
- state.frame = desiredFrame;
+ state.orientedDisplaySpaceRect = desiredOrientedDisplayRect;
// --------------------------------------------------------------------
// Invocation
@@ -2944,13 +2949,14 @@
EXPECT_EQ(eDisplayTransactionNeeded, flags);
// The current display state has the new value.
- EXPECT_EQ(desiredFrame, display.getCurrentDisplayState().frame);
+ EXPECT_EQ(desiredOrientedDisplayRect,
+ display.getCurrentDisplayState().orientedDisplaySpaceRect);
}
-TEST_F(DisplayTransactionTest, setDisplayStateLockedRequestsUpdateIfViewportChanged) {
+TEST_F(DisplayTransactionTest, setDisplayStateLockedRequestsUpdateIfLayerStackRectChanged) {
using Case = SimplePrimaryDisplayCase;
- const Rect initialViewport = {0, 0, 0, 0};
- const Rect desiredViewport = {5, 6, 7, 8};
+ const Rect initialLayerStackRect = {0, 0, 0, 0};
+ const Rect desiredLayerStackRect = {5, 6, 7, 8};
// --------------------------------------------------------------------
// Preconditions
@@ -2959,14 +2965,14 @@
auto display = Case::Display::makeFakeExistingDisplayInjector(this);
display.inject();
- // The current display state does not have a viewport
- display.mutableCurrentDisplayState().viewport = initialViewport;
+ // The current display state does not have a layerStackSpaceRect
+ display.mutableCurrentDisplayState().layerStackSpaceRect = initialLayerStackRect;
- // The incoming request sets a viewport
+ // The incoming request sets a layerStackSpaceRect
DisplayState state;
state.what = DisplayState::eDisplayProjectionChanged;
state.token = display.token();
- state.viewport = desiredViewport;
+ state.layerStackSpaceRect = desiredLayerStackRect;
// --------------------------------------------------------------------
// Invocation
@@ -2980,7 +2986,7 @@
EXPECT_EQ(eDisplayTransactionNeeded, flags);
// The current display state has the new value.
- EXPECT_EQ(desiredViewport, display.getCurrentDisplayState().viewport);
+ EXPECT_EQ(desiredLayerStackRect, display.getCurrentDisplayState().layerStackSpaceRect);
}
TEST_F(DisplayTransactionTest, setDisplayStateLockedDoesNothingIfSizeDidNotChange) {
@@ -3142,11 +3148,11 @@
// The orientation state should be set to zero
EXPECT_EQ(ui::ROTATION_0, primaryDisplayState.orientation);
- // The frame state should be set to INVALID
- EXPECT_EQ(Rect::INVALID_RECT, primaryDisplayState.frame);
+ // The orientedDisplaySpaceRect state should be set to INVALID
+ EXPECT_EQ(Rect::INVALID_RECT, primaryDisplayState.orientedDisplaySpaceRect);
- // The viewport state should be set to INVALID
- EXPECT_EQ(Rect::INVALID_RECT, primaryDisplayState.viewport);
+ // The layerStackSpaceRect state should be set to INVALID
+ EXPECT_EQ(Rect::INVALID_RECT, primaryDisplayState.layerStackSpaceRect);
// The width and height should both be zero
EXPECT_EQ(0u, primaryDisplayState.width);
@@ -3157,7 +3163,7 @@
auto displayDevice = primaryDisplay.mutableDisplayDevice();
EXPECT_EQ(PowerMode::ON, displayDevice->getPowerMode());
- // The display refresh period should be set in the frame tracker.
+ // The display refresh period should be set in the orientedDisplaySpaceRect tracker.
FrameStats stats;
mFlinger.getAnimFrameTracker().getStats(&stats);
EXPECT_EQ(DEFAULT_REFRESH_RATE, stats.refreshPeriodNano);