summaryrefslogtreecommitdiff
path: root/libs/hwui/tests/macrobench/TestSceneRunner.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2015-12-02 14:50:25 -0800
committerChris Craik <ccraik@google.com>2015-12-02 15:25:10 -0800
commit8160f20b0aca8c6595d4b385d673f59b6bcd16a4 (patch)
tree581bd7ae88d7ad352fc03e00d5175ccbfdd140bc /libs/hwui/tests/macrobench/TestSceneRunner.cpp
parent54fa17f667c285a5c9225e238c8132dfe830ef36 (diff)
Reorganize hwui test directories
Now test-only common files reside in tests/common, and each test executable type (macrobench, microbench, and unit) has a subdir there. This change means the shared lib no longer has test code in it, and sets up a means for scenes to be shared between tests. Change-Id: I37b081f6977300e03fdd961b8e6439fde730605e
Diffstat (limited to 'libs/hwui/tests/macrobench/TestSceneRunner.cpp')
-rw-r--r--libs/hwui/tests/macrobench/TestSceneRunner.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/libs/hwui/tests/macrobench/TestSceneRunner.cpp b/libs/hwui/tests/macrobench/TestSceneRunner.cpp
new file mode 100644
index 000000000000..1e1c6a1e318a
--- /dev/null
+++ b/libs/hwui/tests/macrobench/TestSceneRunner.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2015 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 "AnimationContext.h"
+#include "Benchmark.h"
+#include "RenderNode.h"
+#include "TestContext.h"
+#include "tests/common/scenes/TestSceneBase.h"
+#include "renderthread/RenderProxy.h"
+#include "renderthread/RenderTask.h"
+
+#include <cutils/log.h>
+#include <gui/Surface.h>
+#include <ui/PixelFormat.h>
+
+using namespace android;
+using namespace android::uirenderer;
+using namespace android::uirenderer::renderthread;
+using namespace android::uirenderer::test;
+
+class ContextFactory : public IContextFactory {
+public:
+ virtual AnimationContext* createAnimationContext(renderthread::TimeLord& clock) override {
+ return new AnimationContext(clock);
+ }
+};
+
+void run(const BenchmarkInfo& info, const BenchmarkOptions& opts) {
+ // Switch to the real display
+ gDisplay = getBuiltInDisplay();
+
+ std::unique_ptr<TestScene> scene(info.createScene(opts));
+
+ TestContext testContext;
+
+ // create the native surface
+ const int width = gDisplay.w;
+ const int height = gDisplay.h;
+ sp<Surface> surface = testContext.surface();
+
+ sp<RenderNode> rootNode = TestUtils::createNode(0, 0, width, height,
+ [&scene, width, height](RenderProperties& props, TestCanvas& canvas) {
+ props.setClipToBounds(false);
+ scene->createContent(width, height, canvas);
+ });
+
+ ContextFactory factory;
+ std::unique_ptr<RenderProxy> proxy(new RenderProxy(false,
+ rootNode.get(), &factory));
+ proxy->loadSystemProperties();
+ proxy->initialize(surface);
+ float lightX = width / 2.0;
+ proxy->setup(width, height, dp(800.0f), 255 * 0.075, 255 * 0.15);
+ proxy->setLightCenter((Vector3){lightX, dp(-200.0f), dp(800.0f)});
+
+ // Do a few cold runs then reset the stats so that the caches are all hot
+ for (int i = 0; i < 3; i++) {
+ testContext.waitForVsync();
+ nsecs_t vsync = systemTime(CLOCK_MONOTONIC);
+ UiFrameInfoBuilder(proxy->frameInfo()).setVsync(vsync, vsync);
+ proxy->syncAndDrawFrame();
+ }
+ proxy->resetProfileInfo();
+
+ for (int i = 0; i < opts.count; i++) {
+ testContext.waitForVsync();
+
+ ATRACE_NAME("UI-Draw Frame");
+ nsecs_t vsync = systemTime(CLOCK_MONOTONIC);
+ UiFrameInfoBuilder(proxy->frameInfo()).setVsync(vsync, vsync);
+ scene->doFrame(i);
+ proxy->syncAndDrawFrame();
+ }
+
+ proxy->dumpProfileInfo(STDOUT_FILENO, 0);
+}