Move FloatRect from libgfx to libui
Moves FloatRect from libgfx (which is being disintegrated) to libui
Test: Builds and sailfish boots
Change-Id: I68c1b7d86a363066fe4d6f0c038ca9d92d7ab9c7
diff --git a/include/gfx/FloatRect.h b/include/ui/FloatRect.h
similarity index 96%
rename from include/gfx/FloatRect.h
rename to include/ui/FloatRect.h
index 6be5e22..270675c 100644
--- a/include/gfx/FloatRect.h
+++ b/include/ui/FloatRect.h
@@ -17,10 +17,9 @@
#pragma once
namespace android {
-namespace gfx {
class FloatRect {
- public:
+public:
FloatRect() = default;
constexpr FloatRect(float _left, float _top, float _right, float _bottom)
: left(_left), top(_top), right(_right), bottom(_bottom) {}
@@ -38,5 +37,4 @@
return a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom;
}
-} // namespace gfx
} // namespace android
diff --git a/include/ui/Rect.h b/include/ui/Rect.h
index ce33d4e..3d600be 100644
--- a/include/ui/Rect.h
+++ b/include/ui/Rect.h
@@ -17,12 +17,12 @@
#ifndef ANDROID_UI_RECT
#define ANDROID_UI_RECT
-#include <gfx/FloatRect.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>
#include <android/rect.h>
@@ -185,7 +185,7 @@
inline int32_t height() const { return getHeight(); }
inline void set(const Rect& rhs) { operator = (rhs); }
- gfx::FloatRect toFloatRect() const {
+ FloatRect toFloatRect() const {
return {static_cast<float>(left), static_cast<float>(top),
static_cast<float>(right), static_cast<float>(bottom)};
}
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp
index a25e8a1..e49e734 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp
@@ -23,9 +23,8 @@
#include "HWC2.h"
#include "ComposerHal.h"
-#include <gfx/FloatRect.h>
-
#include <ui/Fence.h>
+#include <ui/FloatRect.h>
#include <ui/GraphicBuffer.h>
#include <ui/Region.h>
@@ -74,12 +73,12 @@
}
using android::Fence;
+using android::FloatRect;
using android::GraphicBuffer;
using android::HdrCapabilities;
using android::Rect;
using android::Region;
using android::sp;
-using android::gfx::FloatRect;
using android::hardware::Return;
using android::hardware::Void;
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index 93eb999..e129a3a 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -38,12 +38,10 @@
namespace android {
class Fence;
+ class FloatRect;
class GraphicBuffer;
class Rect;
class Region;
- namespace gfx {
- class FloatRect;
- }
namespace Hwc2 {
class Composer;
}
@@ -410,7 +408,7 @@
[[clang::warn_unused_result]] Error setSidebandStream(
const native_handle_t* stream);
[[clang::warn_unused_result]] Error setSourceCrop(
- const android::gfx::FloatRect& crop);
+ const android::FloatRect& crop);
[[clang::warn_unused_result]] Error setTransform(Transform transform);
[[clang::warn_unused_result]] Error setVisibleRegion(
const android::Region& region);
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
index 0bfc56e..2fff266 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
@@ -1031,7 +1031,7 @@
virtual void setFrame(const Rect& frame) {
getLayer()->displayFrame = reinterpret_cast<hwc_rect_t const&>(frame);
}
- virtual void setCrop(const gfx::FloatRect& crop) {
+ virtual void setCrop(const FloatRect& crop) {
if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) {
getLayer()->sourceCropf = reinterpret_cast<hwc_frect_t const&>(crop);
} else {
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h
index a94bc1e..f64d69a 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h
@@ -48,14 +48,12 @@
// ---------------------------------------------------------------------------
class Fence;
+class FloatRect;
class GraphicBuffer;
class NativeHandle;
class Region;
class String8;
class SurfaceFlinger;
-namespace gfx {
- class FloatRect;
-}
class HWComposer
{
@@ -172,7 +170,7 @@
virtual void setBlending(uint32_t blending) = 0;
virtual void setTransform(uint32_t transform) = 0;
virtual void setFrame(const Rect& frame) = 0;
- virtual void setCrop(const gfx::FloatRect& crop) = 0;
+ virtual void setCrop(const FloatRect& crop) = 0;
virtual void setVisibleRegionScreen(const Region& reg) = 0;
virtual void setSurfaceDamage(const Region& reg) = 0;
virtual void setSidebandStream(const sp<NativeHandle>& stream) = 0;
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index a854aec..d045586 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -477,10 +477,10 @@
return activeCrop;
}
-gfx::FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
+FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
// the content crop is the area of the content that gets scaled to the
// layer's size. This is in buffer space.
- gfx::FloatRect crop = getContentCrop().toFloatRect();
+ FloatRect crop = getContentCrop().toFloatRect();
// In addition there is a WM-specified crop we pull from our drawing state.
const State& s(getDrawingState());
@@ -674,7 +674,7 @@
hwcInfo.displayFrame = transformedFrame;
}
- gfx::FloatRect sourceCrop = computeCrop(displayDevice);
+ FloatRect sourceCrop = computeCrop(displayDevice);
error = hwcLayer->setSourceCrop(sourceCrop);
if (error != HWC2::Error::None) {
ALOGE("[%s] Failed to set source crop [%.3f, %.3f, %.3f, %.3f]: "
@@ -2338,7 +2338,7 @@
const Rect& frame = hwcInfo.displayFrame;
result.appendFormat("%4d %4d %4d %4d | ", frame.left, frame.top,
frame.right, frame.bottom);
- const gfx::FloatRect& crop = hwcInfo.sourceCrop;
+ const FloatRect& crop = hwcInfo.sourceCrop;
result.appendFormat("%6.1f %6.1f %6.1f %6.1f\n", crop.left, crop.top,
crop.right, crop.bottom);
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 8227dae..c578e07 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -27,8 +27,6 @@
#include <utils/String8.h>
#include <utils/Timers.h>
-#include <gfx/FloatRect.h>
-
#include <ui/FrameStats.h>
#include <ui/GraphicBuffer.h>
#include <ui/PixelFormat.h>
@@ -513,7 +511,7 @@
uint32_t getEffectiveUsage(uint32_t usage) const;
- gfx::FloatRect computeCrop(const sp<const DisplayDevice>& hw) const;
+ FloatRect computeCrop(const sp<const DisplayDevice>& hw) const;
// Compute the initial crop as specified by parent layers and the SurfaceControl
// for this layer. Does not include buffer crop from the IGraphicBufferProducer
// client, as that should not affect child clipping. Returns in screen space.
@@ -694,7 +692,7 @@
HWC2::Composition compositionType;
bool clearClientTarget;
Rect displayFrame;
- gfx::FloatRect sourceCrop;
+ FloatRect sourceCrop;
};
std::unordered_map<int32_t, HWCInfo> mHwcLayers;