X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-actor-utils.cpp;h=bf62bb8b4fd9e4157fe77754e558a632261c4d5f;hb=6a219d0bbcfd016e24b5466d5fb1a666c92feae5;hp=2db4dbcd224d6df68f8fc524fd2b657c5b3d9af8;hpb=893ec494389e7fe476a64e220ae97eedb73e74d7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp index 2db4dbc..bf62bb8 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,4 +91,44 @@ Actor CreateRenderableActor(Texture texture, const std::string& vertexShader, co return actor; } +Actor CreateRenderableActor2(TextureSet textures, const std::string& vertexShader, const std::string& fragmentShader) +{ + // Create the geometry + Geometry geometry = CreateQuadGeometry(); + + // Create Shader + Shader shader = Shader::New(vertexShader, fragmentShader); + + // Create renderer from geometry and material + Renderer renderer = Renderer::New(geometry, shader); + + // Create actor and set renderer + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + + // If we a texture, then create a texture-set and add to renderer + if(textures) + { + renderer.SetTextures(textures); + + auto texture = textures.GetTexture(0); + + // Set actor to the size of the texture if set + actor.SetProperty(Actor::Property::SIZE, Vector2(texture.GetWidth(), texture.GetHeight())); + } + + return actor; +} + +Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height) +{ + Texture texture = Texture::New(type, format, width, height); + + int bufferSize = width * height * 2; + uint8_t* buffer = reinterpret_cast(malloc(bufferSize)); + PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, format, PixelData::FREE); + texture.Upload(pixelData, 0u, 0u, 0u, 0u, width, height); + return texture; +} + } // namespace Dali