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

Commit b8d1f365 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Merge "Revert "Add a benchmark for drawing a gainmap"" into main

parents a0a17434 71f1bf56
Loading
Loading
Loading
Loading
+3 −47
Original line number Diff line number Diff line
@@ -16,8 +16,9 @@

#include "TestUtils.h"

#include <hwui/Bitmap.h>
#include <hwui/ImageDecoder.h>
#include "DeferredLayerUpdater.h"
#include "hwui/Paint.h"

#include <hwui/MinikinSkia.h>
#include <hwui/Typeface.h>
#include <minikin/Layout.h>
@@ -27,9 +28,7 @@
#include <renderthread/VulkanManager.h>
#include <utils/Unicode.h>

#include "DeferredLayerUpdater.h"
#include "SkCanvas.h"
#include "SkCodec.h"
#include "SkColorData.h"
#include "SkMatrix.h"
#include "SkPath.h"
@@ -37,7 +36,6 @@
#include "SkRect.h"
#include "SkSurface.h"
#include "SkUnPreMultiply.h"
#include "hwui/Paint.h"

namespace android {
namespace uirenderer {
@@ -195,47 +193,5 @@ SkFont TestUtils::defaultFont() {
    return SkFont(sk_ref_sp(skTypeface));
}

static const uint8_t sRedCarGainmap[]{
#embed "data/gainmap.jpg"
};

sk_sp<SkData> dataForImage(SampleImage image) {
    switch (image) {
        case SampleImage::RedCarGainmap:
            return SkData::MakeWithoutCopy(sRedCarGainmap, sizeof(sRedCarGainmap));
    }
    return SkData::MakeEmpty();
}

sk_sp<Bitmap> TestUtils::getSampleImage(SampleImage image) {
    static std::unordered_map<SampleImage, sk_sp<Bitmap>> sCache;

    auto& entry = sCache[image];

    if (!entry) {
        auto data = dataForImage(image);
        auto codec = SkCodec::MakeFromData(data);
        auto androidCodec = SkAndroidCodec::MakeFromCodec(std::move(codec));
        ImageDecoder decoder{std::move(androidCodec)};
        int imageWidth = decoder.width();
        int imageHeight = decoder.height();
        decoder.setTargetSize(imageWidth, imageHeight);
        SkImageInfo bitmapInfo = decoder.getOutputInfo();

        SkBitmap bm;
        if (!bm.setInfo(bitmapInfo)) {
            LOG_ALWAYS_FATAL("Failed to setInfo properly");
        }

        sk_sp<Bitmap> nativeBitmap = Bitmap::allocateHeapBitmap(&bm);
        SkCodec::Result result = decoder.decode(bm.getPixels(), bm.rowBytes());
        bm.setImmutable();

        entry = std::move(nativeBitmap);
    }

    return entry;
}

} /* namespace uirenderer */
} /* namespace android */
+0 −6
Original line number Diff line number Diff line
@@ -101,10 +101,6 @@ private:
    T mOldValue;
};

enum class SampleImage {
    RedCarGainmap,
};

class TestUtils {
public:
    class SignalingDtor {
@@ -136,8 +132,6 @@ public:
        return true;
    }

    static sk_sp<Bitmap> getSampleImage(SampleImage image);

    static sk_sp<Bitmap> createBitmap(int width, int height,
                                      SkColorType colorType = kN32_SkColorType) {
        SkImageInfo info = SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType);
−2.71 MiB
Loading image diff...
+0 −46
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.
 */

#include "TestSceneBase.h"

class GainmapFillrate;

static TestScene::Registrar _GainmapFillrate(TestScene::Info{
        "gainmap", "A scene that draws a gainmap", TestScene::simpleCreateScene<GainmapFillrate>});

class GainmapFillrate : public TestScene {
public:
    void createContent(int width, int height, Canvas& canvas) override {
        auto bitmap = TestUtils::getSampleImage(SampleImage::RedCarGainmap);
        int imageWidth = bitmap->info().width();
        int imageHeight = bitmap->info().height();
        mContent = TestUtils::createNode(0, 0, imageWidth, imageHeight,
                                         [&](RenderProperties& props, Canvas& canvas) {
                                             canvas.drawBitmap(*bitmap, 0.f, 0.f, nullptr);
                                         });
        canvas.drawColor(Color::White, SkBlendMode::kSrc);
        canvas.drawRenderNode(mContent.get());
    }

    void doFrame(int frameNr) override {
        mContent->mutateStagingProperties().setTranslationX(frameNr % 200);
        mContent->mutateStagingProperties().setTranslationY(frameNr % 200);
        mContent->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y);
    }

private:
    sp<RenderNode> mContent;
};
+3 −3

File changed.

Contains only whitespace changes.