Create libgfx, starting with FloatRect
Creates libgfx, the future home of everything currently in libui and
libgui, which will be rigorously checked with -Weverything (with a few
common-sense exceptions) and clang-tidy and formatted using the included
.clang-format file.
Starts by moving FloatRect out of services/surfaceflinger since it will
be used by other libgfx primitives later.
Test: m
Change-Id: I5045ac089020e6ee380e81e8735117c500264b37
diff --git a/services/surfaceflinger/DisplayHardware/FloatRect.h b/services/surfaceflinger/DisplayHardware/FloatRect.h
deleted file mode 100644
index 151eaaa..0000000
--- a/services/surfaceflinger/DisplayHardware/FloatRect.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2013 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.
- */
-
-#ifndef ANDROID_SF_FLOAT_RECT
-#define ANDROID_SF_FLOAT_RECT
-
-#include <ui/Rect.h>
-#include <utils/TypeHelpers.h>
-
-namespace android {
-
-class FloatRect
-{
-public:
- float left;
- float top;
- float right;
- float bottom;
-
- inline FloatRect()
- : left(0), top(0), right(0), bottom(0) { }
- inline FloatRect(const Rect& other) // NOLINT(implicit)
- : left(other.left), top(other.top), right(other.right), bottom(other.bottom) { }
-
- inline float getWidth() const { return right - left; }
- inline float getHeight() const { return bottom - top; }
-};
-
-}; // namespace android
-
-#endif // ANDROID_SF_FLOAT_RECT
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp
index 85c21b2..1502eeb 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp
@@ -23,7 +23,7 @@
#include "HWC2.h"
#include "ComposerHal.h"
-#include "FloatRect.h"
+#include <gfx/FloatRect.h>
#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
@@ -74,12 +74,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 7e8f94b..5b894ba 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -38,13 +38,15 @@
namespace android {
class Fence;
- class FloatRect;
class GraphicBuffer;
class Rect;
class Region;
+ namespace gfx {
+ class FloatRect;
+ }
namespace Hwc2 {
class Composer;
- };
+ }
}
namespace HWC2 {
@@ -398,7 +400,7 @@
[[clang::warn_unused_result]] Error setSidebandStream(
const native_handle_t* stream);
[[clang::warn_unused_result]] Error setSourceCrop(
- const android::FloatRect& crop);
+ const android::gfx::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 facf8208..af280a4 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 FloatRect& crop) {
+ virtual void setCrop(const gfx::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 170e382..bca25ac 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h
@@ -48,12 +48,14 @@
// ---------------------------------------------------------------------------
class Fence;
-class FloatRect;
class GraphicBuffer;
class NativeHandle;
class Region;
class String8;
class SurfaceFlinger;
+namespace gfx {
+ class FloatRect;
+}
class HWComposer
{
@@ -168,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 FloatRect& crop) = 0;
+ virtual void setCrop(const gfx::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;