From patchwork Mon May 27 17:28:33 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: 17232 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 056C7238E8 for ; Mon, 27 May 2013 17:29:41 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id n10sf8900695qcx.7 for ; Mon, 27 May 2013 10:28:36 -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=CictVhZLKCBEmgpe6BwOnQFsU8gVCdzNM5vgSmcFe+g=; b=Ib/V1nVUcaGiVqbaIcdm6rp3nM3w8YOHHW1vvjLaXZeSx5lGoiIwgb4Q4xjt/DVWyJ SlXIXZN+HYv2yGwLtYpthCE38/GNTwbm3gTyF6+0HRBKGR9PB8HErqAl0mBrydtIMuGb +gwdqah/HRg04K4/vzB1Gpl+gavLuSX2e1lb50X3OsQrJSAamW6E//1yrsHksYN2hRzZ moPykGzq+qVQuKsctrmOFzhlpimgv9nhZ0Q4R0q7HWlWfMp3nA9b8AWzdw+6KGMCNoJ6 iQiOzTqzY31ySWSLG4Z2boTk0OfatrMFk2EUa2vWock7GN9FoCJHD8nqtxonHzR45DP/ AzGw== X-Received: by 10.236.192.131 with SMTP id i3mr14153314yhn.29.1369675716084; Mon, 27 May 2013 10:28:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.120.193 with SMTP id le1ls2811921qeb.66.gmail; Mon, 27 May 2013 10:28:35 -0700 (PDT) X-Received: by 10.220.200.200 with SMTP id ex8mr15804512vcb.43.1369675715751; Mon, 27 May 2013 10:28:35 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id un20si17197392veb.11.2013.05.27.10.28.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 10:28:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf11so4781817vcb.26 for ; Mon, 27 May 2013 10:28:35 -0700 (PDT) X-Received: by 10.220.246.8 with SMTP id lw8mr15667538vcb.8.1369675715212; Mon, 27 May 2013 10:28:35 -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 jj7csp7051vcb; Mon, 27 May 2013 10:28:34 -0700 (PDT) X-Received: by 10.180.184.83 with SMTP id es19mr9083060wic.54.1369675713642; Mon, 27 May 2013 10:28:33 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id gf8si4703933wjb.162.2013.05.27.10.28.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 27 May 2013 10:28:33 -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 1Uh1Dl-0005vz-5d for ; Mon, 27 May 2013 17:28:33 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 1A4A3E086A for ; Mon, 27 May 2013 17:28:33 +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: <20130527172833.22665.94797.launchpad@ackee.canonical.com> Date: Mon, 27 May 2013 17:28:33 -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: 6859273477f92f3dc10769a98396c2988a3a9fd1 X-Gm-Message-State: ALoCoQntf0TD/GKg9QMR3dt5kcaqrXpGIx3aXAd+iiCRq5RRNy8ugXCqQ3rOJeLtREPGo+SbHeG/ X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 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:22:08 +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). ------------- This line and the following will be ignored -------------- added: src/scene-collection.h modified: src/android.cpp src/main.cpp unknown: android/bin/ android/gen/ android/libs/ android/local.properties android/obj/ android/proguard-project.txt pending merges: Jesse Barker 2013-05-17 SceneCollection: Consolidate the scene vector population into an object to 2 shelves exist. See "bzr shelve --list" for details. 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_