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

Commit ec4ba182 authored by Kevin Lubick's avatar Kevin Lubick Committed by Android (Google) Code Review
Browse files

Merge "Avoid default SkFont in tests" into main

parents 417b2d77 09a77097
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include "DeferredLayerUpdater.h"
#include "hwui/Paint.h"

#include <hwui/MinikinSkia.h>
#include <hwui/Typeface.h>
#include <minikin/Layout.h>
#include <pipeline/skia/SkiaOpenGLPipeline.h>
#include <pipeline/skia/SkiaVulkanPipeline.h>
@@ -179,5 +181,13 @@ SkRect TestUtils::getLocalClipBounds(const SkCanvas* canvas) {
    return outlineInLocalCoord;
}

SkFont TestUtils::defaultFont() {
    const std::shared_ptr<minikin::MinikinFont>& minikinFont =
      Typeface::resolveDefault(nullptr)->fFontCollection->getFamilyAt(0)->getFont(0)->baseTypeface();
    SkTypeface* skTypeface = reinterpret_cast<const MinikinFontSkia*>(minikinFont.get())->GetSkTypeface();
    LOG_ALWAYS_FATAL_IF(skTypeface == nullptr);
    return SkFont(sk_ref_sp(skTypeface));
}

} /* namespace uirenderer */
} /* namespace android */
+3 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@

#include <SkBitmap.h>
#include <SkColor.h>
#include <SkFont.h>
#include <SkImageInfo.h>
#include <SkRefCnt.h>

@@ -353,6 +354,8 @@ public:

    static CallCounts& countsForFunctor(int functor) { return sMockFunctorCounts[functor]; }

    static SkFont defaultFont();

private:
    static std::unordered_map<int, CallCounts> sMockFunctorCounts;

+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ class ListViewAnimation : public TestListViewSceneBase {
                128 * 3;
        paint.setColor(bgDark ? Color::White : Color::Grey_700);

        SkFont font;
        SkFont font = TestUtils::defaultFont();
        font.setSize(size / 2);
        char charToShow = 'A' + (rand() % 26);
        const SkPoint pos = {SkIntToScalar(size / 2),
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ private:
                128 * 3;
        paint.setColor(bgDark ? Color::White : Color::Grey_700);

        SkFont font;
        SkFont font = TestUtils::defaultFont();
        font.setSize(size / 2);
        char charToShow = 'A' + (rand() % 26);
        const SkPoint pos = {SkIntToScalar(size / 2),