Loading libs/hwui/Android.mk +3 −3 Original line number Original line Diff line number Diff line Loading @@ -90,6 +90,9 @@ hwui_src_files := \ protos/hwui.proto protos/hwui.proto hwui_test_common_src_files := \ hwui_test_common_src_files := \ $(call all-cpp-files-under, tests/common/scenes) \ tests/common/TestContext.cpp \ tests/common/TestScene.cpp \ tests/common/TestUtils.cpp tests/common/TestUtils.cpp hwui_cflags := \ hwui_cflags := \ Loading Loading @@ -259,12 +262,9 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \ $(hwui_test_common_src_files) \ $(hwui_test_common_src_files) \ tests/macrobench/TestContext.cpp \ tests/macrobench/TestSceneRunner.cpp \ tests/macrobench/TestSceneRunner.cpp \ tests/macrobench/main.cpp tests/macrobench/main.cpp LOCAL_SRC_FILES += $(call all-cpp-files-under, tests/common/scenes) include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE) # ------------------------ # ------------------------ Loading libs/hwui/tests/macrobench/TestContext.cpp→libs/hwui/tests/common/TestContext.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. * limitations under the License. */ */ #include "TestContext.h" #include "tests/common/TestContext.h" namespace android { namespace android { namespace uirenderer { namespace uirenderer { Loading libs/hwui/tests/macrobench/TestContext.h→libs/hwui/tests/common/TestContext.h +0 −0 File moved. View file libs/hwui/tests/macrobench/Benchmark.h→libs/hwui/tests/common/TestScene.cpp +10 −35 Original line number Original line Diff line number Diff line Loading @@ -13,49 +13,24 @@ * See the License for the specific language governing permissions and * See the License for the specific language governing permissions and * limitations under the License. * limitations under the License. */ */ #ifndef TESTS_BENCHMARK_H #define TESTS_BENCHMARK_H #include "tests/common/TestScene.h" #include "tests/common/TestScene.h" #include <string> #include <vector> namespace android { namespace android { namespace uirenderer { namespace uirenderer { namespace test { struct BenchmarkOptions { // Not a static global because we need to force the map to be constructed int count; // before we try to add things to it. }; std::unordered_map<std::string, TestScene::Info>& TestScene::testMap() { static std::unordered_map<std::string, TestScene::Info> testMap; typedef test::TestScene* (*CreateScene)(const BenchmarkOptions&); return testMap; template <class T> test::TestScene* simpleCreateScene(const BenchmarkOptions&) { return new T(); } } struct BenchmarkInfo { void TestScene::registerScene(const TestScene::Info& info) { std::string name; testMap()[info.name] = info; std::string description; CreateScene createScene; }; class Benchmark { public: Benchmark(const BenchmarkInfo& info) { registerBenchmark(info); } } private: } /* namespace test */ Benchmark() = delete; Benchmark(const Benchmark&) = delete; Benchmark& operator=(const Benchmark&) = delete; static void registerBenchmark(const BenchmarkInfo& info); }; } /* namespace uirenderer */ } /* namespace uirenderer */ } /* namespace android */ } /* namespace android */ #endif /* TESTS_BENCHMARK_H */ libs/hwui/tests/common/TestScene.h +34 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,9 @@ #ifndef TESTS_TESTSCENE_H #ifndef TESTS_TESTSCENE_H #define TESTS_TESTSCENE_H #define TESTS_TESTSCENE_H #include <string> #include <unordered_map> namespace android { namespace android { namespace uirenderer { namespace uirenderer { class RenderNode; class RenderNode; Loading @@ -32,9 +35,40 @@ namespace test { class TestScene { class TestScene { public: public: struct Options { int count = 0; }; template <class T> static test::TestScene* simpleCreateScene(const TestScene::Options&) { return new T(); } typedef test::TestScene* (*CreateScene)(const TestScene::Options&); struct Info { std::string name; std::string description; CreateScene createScene; }; class Registrar { public: Registrar(const TestScene::Info& info) { TestScene::registerScene(info); } private: Registrar() = delete; Registrar(const Registrar&) = delete; Registrar& operator=(const Registrar&) = delete; }; virtual ~TestScene() {} virtual ~TestScene() {} virtual void createContent(int width, int height, TestCanvas& renderer) = 0; virtual void createContent(int width, int height, TestCanvas& renderer) = 0; virtual void doFrame(int frameNr) = 0; virtual void doFrame(int frameNr) = 0; static std::unordered_map<std::string, Info>& testMap(); static void registerScene(const Info& info); }; }; } // namespace test } // namespace test Loading Loading
libs/hwui/Android.mk +3 −3 Original line number Original line Diff line number Diff line Loading @@ -90,6 +90,9 @@ hwui_src_files := \ protos/hwui.proto protos/hwui.proto hwui_test_common_src_files := \ hwui_test_common_src_files := \ $(call all-cpp-files-under, tests/common/scenes) \ tests/common/TestContext.cpp \ tests/common/TestScene.cpp \ tests/common/TestUtils.cpp tests/common/TestUtils.cpp hwui_cflags := \ hwui_cflags := \ Loading Loading @@ -259,12 +262,9 @@ LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \ $(hwui_test_common_src_files) \ $(hwui_test_common_src_files) \ tests/macrobench/TestContext.cpp \ tests/macrobench/TestSceneRunner.cpp \ tests/macrobench/TestSceneRunner.cpp \ tests/macrobench/main.cpp tests/macrobench/main.cpp LOCAL_SRC_FILES += $(call all-cpp-files-under, tests/common/scenes) include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE) # ------------------------ # ------------------------ Loading
libs/hwui/tests/macrobench/TestContext.cpp→libs/hwui/tests/common/TestContext.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. * limitations under the License. */ */ #include "TestContext.h" #include "tests/common/TestContext.h" namespace android { namespace android { namespace uirenderer { namespace uirenderer { Loading
libs/hwui/tests/macrobench/TestContext.h→libs/hwui/tests/common/TestContext.h +0 −0 File moved. View file
libs/hwui/tests/macrobench/Benchmark.h→libs/hwui/tests/common/TestScene.cpp +10 −35 Original line number Original line Diff line number Diff line Loading @@ -13,49 +13,24 @@ * See the License for the specific language governing permissions and * See the License for the specific language governing permissions and * limitations under the License. * limitations under the License. */ */ #ifndef TESTS_BENCHMARK_H #define TESTS_BENCHMARK_H #include "tests/common/TestScene.h" #include "tests/common/TestScene.h" #include <string> #include <vector> namespace android { namespace android { namespace uirenderer { namespace uirenderer { namespace test { struct BenchmarkOptions { // Not a static global because we need to force the map to be constructed int count; // before we try to add things to it. }; std::unordered_map<std::string, TestScene::Info>& TestScene::testMap() { static std::unordered_map<std::string, TestScene::Info> testMap; typedef test::TestScene* (*CreateScene)(const BenchmarkOptions&); return testMap; template <class T> test::TestScene* simpleCreateScene(const BenchmarkOptions&) { return new T(); } } struct BenchmarkInfo { void TestScene::registerScene(const TestScene::Info& info) { std::string name; testMap()[info.name] = info; std::string description; CreateScene createScene; }; class Benchmark { public: Benchmark(const BenchmarkInfo& info) { registerBenchmark(info); } } private: } /* namespace test */ Benchmark() = delete; Benchmark(const Benchmark&) = delete; Benchmark& operator=(const Benchmark&) = delete; static void registerBenchmark(const BenchmarkInfo& info); }; } /* namespace uirenderer */ } /* namespace uirenderer */ } /* namespace android */ } /* namespace android */ #endif /* TESTS_BENCHMARK_H */
libs/hwui/tests/common/TestScene.h +34 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,9 @@ #ifndef TESTS_TESTSCENE_H #ifndef TESTS_TESTSCENE_H #define TESTS_TESTSCENE_H #define TESTS_TESTSCENE_H #include <string> #include <unordered_map> namespace android { namespace android { namespace uirenderer { namespace uirenderer { class RenderNode; class RenderNode; Loading @@ -32,9 +35,40 @@ namespace test { class TestScene { class TestScene { public: public: struct Options { int count = 0; }; template <class T> static test::TestScene* simpleCreateScene(const TestScene::Options&) { return new T(); } typedef test::TestScene* (*CreateScene)(const TestScene::Options&); struct Info { std::string name; std::string description; CreateScene createScene; }; class Registrar { public: Registrar(const TestScene::Info& info) { TestScene::registerScene(info); } private: Registrar() = delete; Registrar(const Registrar&) = delete; Registrar& operator=(const Registrar&) = delete; }; virtual ~TestScene() {} virtual ~TestScene() {} virtual void createContent(int width, int height, TestCanvas& renderer) = 0; virtual void createContent(int width, int height, TestCanvas& renderer) = 0; virtual void doFrame(int frameNr) = 0; virtual void doFrame(int frameNr) = 0; static std::unordered_map<std::string, Info>& testMap(); static void registerScene(const Info& info); }; }; } // namespace test } // namespace test Loading