diff options
Diffstat (limited to 'libs/hwui/tests/main.cpp')
-rw-r--r-- | libs/hwui/tests/main.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/libs/hwui/tests/main.cpp b/libs/hwui/tests/main.cpp index d847d13..a12dac7 100644 --- a/libs/hwui/tests/main.cpp +++ b/libs/hwui/tests/main.cpp @@ -24,16 +24,18 @@ #include <DisplayListRenderer.h> #include <RenderNode.h> #include <renderthread/RenderProxy.h> +#include <renderthread/RenderTask.h> #include "TestContext.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) { + virtual AnimationContext* createAnimationContext(renderthread::TimeLord& clock) override { return new AnimationContext(clock); } }; @@ -41,7 +43,7 @@ public: static DisplayListRenderer* startRecording(RenderNode* node) { DisplayListRenderer* renderer = new DisplayListRenderer(); renderer->setViewport(node->getWidth(), node->getHeight()); - renderer->prepare(false); + renderer->prepare(); return renderer; } @@ -66,24 +68,23 @@ sp<RenderNode> createCard(int x, int y, int width, int height) { return node; } -int main() { - createTestEnvironment(); +int main(int argc, char* argv[]) { + TestContext testContext; // create the native surface const int width = gDisplay.w; const int height = gDisplay.h; - sp<SurfaceControl> control = createWindow(width, height); - sp<Surface> surface = control->getSurface(); + sp<Surface> surface = testContext.surface(); RenderNode* rootNode = new RenderNode(); - rootNode->incStrong(0); + rootNode->incStrong(nullptr); rootNode->mutateStagingProperties().setLeftTopRightBottom(0, 0, width, height); rootNode->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y); rootNode->mutateStagingProperties().setClipToBounds(false); rootNode->setPropertyFieldsDirty(RenderNode::GENERIC); ContextFactory factory; - RenderProxy* proxy = new RenderProxy(false, rootNode, &factory); + std::unique_ptr<RenderProxy> proxy(new RenderProxy(false, rootNode, &factory)); proxy->loadSystemProperties(); proxy->initialize(surface); float lightX = width / 2.0; @@ -110,6 +111,8 @@ int main() { endRecording(renderer, rootNode); for (int i = 0; i < 150; i++) { + testContext.waitForVsync(); + ATRACE_NAME("UI-Draw Frame"); for (size_t ci = 0; ci < cards.size(); ci++) { cards[ci]->mutateStagingProperties().setTranslationX(i); @@ -118,13 +121,11 @@ int main() { } nsecs_t frameTimeNs = systemTime(CLOCK_MONOTONIC); proxy->syncAndDrawFrame(frameTimeNs, 0, gDisplay.density); - usleep(12000); } sleep(5); - delete proxy; - rootNode->decStrong(0); + rootNode->decStrong(nullptr); printf("Success!\n"); return 0; |