Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8e4c3d7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Create libgfx, starting with FloatRect"

parents 865a01c8 71bded51
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
BasedOnStyle: Google

AccessModifierOffset: -2
AllowShortFunctionsOnASingleLine: Inline
BinPackParameters: false
ColumnLimit: 100
CommentPragmas: NOLINT:.*
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 8
IndentWidth: 4
+18 −20
Original line number Diff line number Diff line
@@ -14,31 +14,29 @@
 * limitations under the License.
 */

#ifndef ANDROID_SF_FLOAT_RECT
#define ANDROID_SF_FLOAT_RECT

#include <ui/Rect.h>
#include <utils/TypeHelpers.h>
#pragma once

namespace android {
namespace gfx {

class FloatRect
{
class FloatRect {
  public:
    float left;
    float top;
    float right;
    float bottom;
    FloatRect() = default;
    constexpr FloatRect(float _left, float _top, float _right, float _bottom)
      : left(_left), top(_top), right(_right), bottom(_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) { }
    float getWidth() const { return right - left; }
    float getHeight() const { return bottom - top; }

    inline float getWidth() const { return right - left; }
    inline float getHeight() const { return bottom - top; }
    float left = 0.0f;
    float top = 0.0f;
    float right = 0.0f;
    float bottom = 0.0f;
};

}; // namespace android
inline bool operator==(const FloatRect& a, const FloatRect& b) {
    return a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom;
}

#endif // ANDROID_SF_FLOAT_RECT
}  // namespace gfx
}  // namespace android
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef ANDROID_UI_RECT
#define ANDROID_UI_RECT

#include <gfx/FloatRect.h>
#include <utils/Flattenable.h>
#include <utils/Log.h>
#include <utils/TypeHelpers.h>
@@ -177,11 +178,15 @@ public:
    // this calculates (Region(*this) - exclude).bounds() efficiently
    Rect reduce(const Rect& exclude) const;


    // for backward compatibility
    inline int32_t width() const { return getWidth(); }
    inline int32_t height() const { return getHeight(); }
    inline void set(const Rect& rhs) { operator = (rhs); }

    gfx::FloatRect toFloatRect() const {
        return {static_cast<float>(left), static_cast<float>(top),
                static_cast<float>(right), static_cast<float>(bottom)};
    }
};

ANDROID_BASIC_TYPES_TRAITS(Rect)
+3 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ cc_library_shared {
        "-Wno-nested-anon-types",
        "-Wno-gnu-anonymous-struct",

        // We are aware of the risks inherent in comparing floats for equality
        "-Wno-float-equal",

        "-DDEBUG_ONLY_CODE=0",
    ],

+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@ cc_library_shared {
        // We only care about compiling as C++14
        "-Wno-c++98-compat-pedantic",

        // We are aware of the risks inherent in comparing floats for equality
        "-Wno-float-equal",

        // We use four-character constants for the GraphicBuffer header, and don't care
        // that they're non-portable as long as they're consistent within one execution
        "-Wno-four-char-constants",
Loading