From patchwork Mon May 27 17:33:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 17233 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 78C61238E8 for ; Mon, 27 May 2013 17:34:25 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id b13sf1919464wgh.9 for ; Mon, 27 May 2013 10:33:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to :mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state:x-original-sender :x-original-authentication-results:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=AzvZdHsL77ZgecufvptimVEM4aZfvLfDERDw+vapGXk=; b=f/MW6EftnbH6x0aoWx9xEJT88Q7LGPYndwXGD4WLMNawtmWE0h7gOC29K/duJBzDee Qk9bvKWGacc5kFVM8KcT12Mgweb7fVELuPyHbBJ6fLf8sSSonBO69dygNLngbLQtHXjt vg71ci/5hcul2HUmg5NpEg+f/PCe5sQCNsv2Zxq5M4xy3IXPSXgQA3jlq/y19bwzyXMC x3TuZ3BXAHVceAAuFzm2iabQfzAhs8OjOL6u2MmJn4OJXy0aWR7WpLR9P9FDr7Xfb/Up cNiXqtLxPZAc62bY/xHtr+p4E9G897bARt8Ll2w8qj0st7N81pwQLybeFoT9KAT0l+c9 Gr6Q== X-Received: by 10.180.76.174 with SMTP id l14mr3901063wiw.5.1369675999968; Mon, 27 May 2013 10:33:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.98.227 with SMTP id el3ls835382wib.10.canary; Mon, 27 May 2013 10:33:19 -0700 (PDT) X-Received: by 10.194.220.97 with SMTP id pv1mr9635997wjc.25.1369675999894; Mon, 27 May 2013 10:33:19 -0700 (PDT) Received: from mail-ve0-x22e.google.com (mail-ve0-x22e.google.com [2607:f8b0:400c:c01::22e]) by mx.google.com with ESMTPS id et4si4564840wic.25.2013.05.27.10.33.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 10:33:19 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22e; Received: by mail-ve0-f174.google.com with SMTP id oz10so1643163veb.5 for ; Mon, 27 May 2013 10:33:18 -0700 (PDT) X-Received: by 10.52.34.114 with SMTP id y18mr13433629vdi.56.1369675998647; Mon, 27 May 2013 10:33:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.229.199 with SMTP id jj7csp7171vcb; Mon, 27 May 2013 10:33:18 -0700 (PDT) X-Received: by 10.180.81.169 with SMTP id b9mr9339496wiy.12.1369675996000; Mon, 27 May 2013 10:33:16 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id t11si4537104wij.81.2013.05.27.10.33.15 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 27 May 2013 10:33:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Uh1IJ-0006te-Iz for ; Mon, 27 May 2013 17:33:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 7E54CE00BF for ; Mon, 27 May 2013 17:33:15 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 274 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 274: SceneCollection: Consolidate the scene vector population into an object to Message-Id: <20130527173315.24015.94803.launchpad@ackee.canonical.com> Date: Mon, 27 May 2013 17:33:15 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: list X-Generated-By: Launchpad (canonical.com); Revision="16640"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 1a25798b89c3e667ef6b3f59fefa35b7c5935190 X-Gm-Message-State: ALoCoQkQ49HtfXuMiyJsdug4B0+SLnd/h84Ak4eCtcdhzuA4xEcdeCzvWPBsLJtxqMtQt4b9w+c5 X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Merge authors: Jesse Barker (jesse-barker) Related merge proposals: https://code.launchpad.net/~glmark2-dev/glmark2/scene-collection/+merge/164459 proposed by: Jesse Barker (jesse-barker) review: Approve - Alexandros Frantzis (afrantzis) ------------------------------------------------------------ revno: 274 [merge] author: Jesse Barker committer: Alexandros Frantzis branch nick: trunk timestamp: Mon 2013-05-27 20:31:35 +0300 message: SceneCollection: Consolidate the scene vector population into an object to simplify adding scenes across platforms (rather than having to add for Android separately from others). added: src/scene-collection.h modified: src/android.cpp src/main.cpp --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'src/android.cpp' --- src/android.cpp 2013-05-17 14:54:18 +0000 +++ src/android.cpp 2013-05-17 16:39:23 +0000 @@ -33,10 +33,12 @@ #include "util.h" #include "main-loop.h" #include "benchmark-collection.h" +#include "scene-collection.h" static Canvas *g_canvas; static MainLoop *g_loop; static BenchmarkCollection *g_benchmark_collection; +static SceneCollection *g_scene_collection; static std::ostream *g_log_extra; class MainLoopAndroid : public MainLoop @@ -251,36 +253,6 @@ DummyCanvas() : Canvas(0, 0) {} }; -/** - * Creates all the available scenes and adds them to the supplied vector. - * - * @param scenes the vector to add the scenes to - * @param canvas the canvas to create the scenes with - */ -static void -create_and_add_scenes(std::vector& scenes, Canvas& canvas) -{ - scenes.push_back(new SceneDefaultOptions(canvas)); - scenes.push_back(new SceneBuild(canvas)); - scenes.push_back(new SceneTexture(canvas)); - scenes.push_back(new SceneShading(canvas)); - scenes.push_back(new SceneConditionals(canvas)); - scenes.push_back(new SceneFunction(canvas)); - scenes.push_back(new SceneLoop(canvas)); - scenes.push_back(new SceneBump(canvas)); - scenes.push_back(new SceneEffect2D(canvas)); - scenes.push_back(new ScenePulsar(canvas)); - scenes.push_back(new SceneDesktop(canvas)); - scenes.push_back(new SceneBuffer(canvas)); - scenes.push_back(new SceneIdeas(canvas)); - scenes.push_back(new SceneTerrain(canvas)); - scenes.push_back(new SceneJellyfish(canvas)); - scenes.push_back(new SceneShadow(canvas)); - scenes.push_back(new SceneRefract(canvas)); - scenes.push_back(new SceneClear(canvas)); -} - - void Java_org_linaro_glmark2_native_init(JNIEnv* env, jclass clazz, jobject asset_manager, @@ -328,17 +300,9 @@ Log::info("glmark2 %s\n", GLMARK_VERSION); g_canvas->print_info(); - std::vector scenes; - /* Add and register scenes */ - create_and_add_scenes(scenes, *g_canvas); - - for (std::vector::const_iterator iter = scenes.begin(); - iter != scenes.end(); - iter++) - { - Benchmark::register_scene(**iter); - } + g_scene_collection = new SceneCollection(*g_canvas); + g_scene_collection->register_scenes(); g_benchmark_collection = new BenchmarkCollection(); g_benchmark_collection->populate_from_options(); @@ -373,6 +337,7 @@ delete g_loop; delete g_benchmark_collection; + delete g_scene_collection; delete g_canvas; delete g_log_extra; } @@ -413,12 +378,11 @@ Util::android_set_asset_manager(AAssetManager_fromJava(env, asset_manager)); - std::vector scenes; DummyCanvas canvas; + SceneCollection sc(canvas); + const std::vector& scenes = sc.get(); std::vector si_vector; - create_and_add_scenes(scenes, canvas); - /* Create SceneInfo instances for all the scenes */ for (std::vector::const_iterator iter = scenes.begin(); iter != scenes.end(); @@ -436,8 +400,6 @@ for (size_t i = 0; i < si_vector.size(); i++) env->SetObjectArrayElement(si_array, i, si_vector[i]); - Util::dispose_pointer_vector(scenes); - return si_array; } === modified file 'src/main.cpp' --- src/main.cpp 2013-05-16 18:38:54 +0000 +++ src/main.cpp 2013-05-17 16:39:23 +0000 @@ -31,6 +31,7 @@ #include "text-renderer.h" #include "main-loop.h" #include "benchmark-collection.h" +#include "scene-collection.h" #include #include @@ -215,10 +216,9 @@ canvas.visual_config(Options::visual_config); - vector scenes; - // Register the scenes, so they can be looked up by name - add_and_register_scenes(scenes, canvas); + SceneCollection scenes(canvas); + scenes.register_scenes(); if (Options::list_scenes) { list_scenes(); @@ -243,7 +243,5 @@ else do_benchmark(canvas); - Util::dispose_pointer_vector(scenes); - return 0; } === added file 'src/scene-collection.h' --- src/scene-collection.h 1970-01-01 00:00:00 +0000 +++ src/scene-collection.h 2013-05-17 16:39:23 +0000 @@ -0,0 +1,81 @@ +// +// Copyright Š 2013 Linaro Limited +// +// This file is part of the glmark2 OpenGL (ES) 2.0 benchmark. +// +// glmark2 is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 3 of the License, or (at your option) any later +// version. +// +// glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// glmark2. If not, see . +// +// Authors: +// Jesse Barker +// Alexandros Frantzis +// +#ifndef GLMARK2_SCENE_COLLECTION_H_ +#define GLMARK2_SCENE_COLLECTION_H_ + +#include +#include "scene.h" + + +class SceneCollection +{ +public: + SceneCollection(Canvas& canvas) + { + add_scenes(canvas); + } + ~SceneCollection() { Util::dispose_pointer_vector(scenes_); } + void register_scenes() + { + for (std::vector::const_iterator iter = scenes_.begin(); + iter != scenes_.end(); + iter++) + { + Benchmark::register_scene(**iter); + } + } + const std::vector& get() { return scenes_; } + +private: + std::vector scenes_; + + // + // Creates all the available scenes and adds them to the supplied vector. + // + // @param scenes the vector to add the scenes to + // @param canvas the canvas to create the scenes with + // + void add_scenes(Canvas& canvas) + { + scenes_.push_back(new SceneDefaultOptions(canvas)); + scenes_.push_back(new SceneBuild(canvas)); + scenes_.push_back(new SceneTexture(canvas)); + scenes_.push_back(new SceneShading(canvas)); + scenes_.push_back(new SceneConditionals(canvas)); + scenes_.push_back(new SceneFunction(canvas)); + scenes_.push_back(new SceneLoop(canvas)); + scenes_.push_back(new SceneBump(canvas)); + scenes_.push_back(new SceneEffect2D(canvas)); + scenes_.push_back(new ScenePulsar(canvas)); + scenes_.push_back(new SceneDesktop(canvas)); + scenes_.push_back(new SceneBuffer(canvas)); + scenes_.push_back(new SceneIdeas(canvas)); + scenes_.push_back(new SceneTerrain(canvas)); + scenes_.push_back(new SceneJellyfish(canvas)); + scenes_.push_back(new SceneShadow(canvas)); + scenes_.push_back(new SceneRefract(canvas)); + scenes_.push_back(new SceneClear(canvas)); + + } +}; +#endif // GLMARK2_SCENE_COLLECTION_H_