added animation library.

This commit is contained in:
rachytski 2012-08-16 11:18:01 +03:00 committed by Alex Zolotarev
parent 6815bad255
commit 96c0658a68
10 changed files with 267 additions and 4 deletions

View file

@ -45,7 +45,7 @@ LOCAL_SRC_FILES := \
nv_time/nv_time.cpp
LOCAL_LDLIBS := -llog -lGLESv2 \
-lmap -lgui -lversion -lsearch -lstorage -lindexer -lyg -lplatform \
-lmap -lgui -lversion -lsearch -lstorage -lindexer -lyg -lplatform -lanim \
-lgeometry -lcoding -lbase -lexpat -lfreetype -lfribidi -lzlib -lbzip2 \
-ljansson -ltomcrypt -lprotobuf ./obj/local/$(TARGET_ARCH_ABI)/libgnustl_static.a

19
anim/anim.pro Normal file
View file

@ -0,0 +1,19 @@
# Animation library
TARGET = anim
TEMPLATE = lib
CONFIG += staticlib
ROOT_DIR = ..
DEPENDENCIES = geometry coding base expat
include($$ROOT_DIR/common.pri)
HEADERS += \
controller.hpp \
task.hpp
SOURCES += \
controller.cpp \

83
anim/controller.cpp Normal file
View file

@ -0,0 +1,83 @@
#include "controller.hpp"
#include "task.hpp"
#include "../base/timer.hpp"
#include "../std/bind.hpp"
namespace anim
{
Controller::Controller()
{
m_animStep = 10;
m_thread.Create(this);
}
Controller::~Controller()
{
m_tasks.Cancel();
m_newTasks.Cancel();
m_thread.Cancel();
}
void Controller::AddTask(shared_ptr<Task> const & task)
{
m_newTasks.PushBack(task);
}
void Controller::CopyTasks(TTasks & from, TTasks & to)
{
to.clear();
swap(from, to);
}
void Controller::Do()
{
while (true)
{
// making synchronized copy of tasks to process
// them without intervention from other threads.
m_newTasks.ProcessList(bind(&Controller::CopyTasks, this, _1, ref(m_newTasksList)));
m_tasks.ProcessList(bind(&Controller::CopyTasks, this, _1, ref(m_tasksList)));
// checking for thread cancellation
if (m_newTasks.IsCancelled()
|| m_tasks.IsCancelled()
|| IsCancelled())
break;
// current animation step timestamp
double timeStamp = my::Timer::LocalTime();
// starting new tasks and adding them to the pool.
// they we'll be processed in the next animation step
for (TTasks::const_iterator it = m_newTasksList.begin();
it != m_newTasksList.end();
++it)
{
shared_ptr<Task> task = *it;
task->OnStart(timeStamp);
m_tasks.PushBack(task);
}
m_newTasksList.clear();
// processing current tasks
for (TTasks::const_iterator it = m_tasksList.begin();
it != m_tasksList.end();
++it)
{
shared_ptr<Task> task = *it;
task->OnStep(timeStamp);
if (!task->IsFinished())
m_tasks.PushBack(task);
else
task->OnEnd(timeStamp);
}
m_tasksList.clear();
// sleeping till the next animation step.
threads::Sleep(m_animStep);
}
}
}

50
anim/controller.hpp Normal file
View file

@ -0,0 +1,50 @@
#pragma once
#include "../std/shared_ptr.hpp"
#include "../base/thread.hpp"
#include "../base/threaded_list.hpp"
namespace anim
{
class Task;
// Animation controller class.
// - Creates and manages the separate thread.
// - Using ThreadedList to manage the list of active commands.
// - CPU efficient, which means that when there are no commands
// the thread is sleeping and doesn't consume CPU
class Controller : public threads::IRoutine
{
private:
// Container for tasks
typedef list<shared_ptr<Task> > TTasks;
ThreadedList<shared_ptr<Task> > m_tasks;
// Task for the current step.
TTasks m_tasksList;
ThreadedList<shared_ptr<Task> > m_newTasks;
// Added, but not started tasks.
// They'll be started in the next animation step.
TTasks m_newTasksList;
// Animation thread.
threads::Thread m_thread;
// Animation step in miliseconds.
unsigned m_animStep;
// MainLoop method
void Do();
void CopyTasks(list<shared_ptr<Task> > & from, list<shared_ptr<Task> > & to);
public:
// Constructor
Controller();
// Destructor
~Controller();
// Adding animation task to the controller
void AddTask(shared_ptr<Task> const & task);
};
}

17
anim/task.hpp Normal file
View file

@ -0,0 +1,17 @@
#pragma once
namespace anim
{
// Interface for single animation task
class Task
{
public:
virtual void OnStart(double ts) = 0;
virtual void OnStep(double ts) = 0;
virtual void OnEnd(double ts) = 0;
virtual bool IsFinished() = 0;
virtual void Finish() = 0;
virtual ~Task() {};
};
}

View file

@ -52,6 +52,8 @@
EEFC0BBF12B5656A002914FF /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE12020311CD464100ABDD5D /* libfreetype.a */; };
EEFE7C1412F8C9E1006AF8C3 /* fonts_blacklist.txt in Resources */ = {isa = PBXBuildFile; fileRef = EEFE7C1212F8C9E1006AF8C3 /* fonts_blacklist.txt */; };
EEFE7C1512F8C9E1006AF8C3 /* fonts_whitelist.txt in Resources */ = {isa = PBXBuildFile; fileRef = EEFE7C1312F8C9E1006AF8C3 /* fonts_whitelist.txt */; };
EEFFB4E815DCDD8A00BACE1C /* libanim.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EEFFB4E715DCDD8A00BACE1C /* libanim.a */; };
EEFFB4E915DCDD8A00BACE1C /* libanim.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EEFFB4E715DCDD8A00BACE1C /* libanim.a */; };
F7B90CD31521E6D200C054EE /* CustomNavigationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F7B90CD21521E6D100C054EE /* CustomNavigationView.mm */; };
F7B90CD41521E6D200C054EE /* CustomNavigationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F7B90CD21521E6D100C054EE /* CustomNavigationView.mm */; };
F7FDD823147F30CC005900FA /* drules_proto.bin in Resources */ = {isa = PBXBuildFile; fileRef = F7FDD822147F30CC005900FA /* drules_proto.bin */; };
@ -1364,6 +1366,7 @@
EEF5745412DE1AD50082F472 /* libfribidi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfribidi.a; sourceTree = SOURCE_ROOT; };
EEFE7C1212F8C9E1006AF8C3 /* fonts_blacklist.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = fonts_blacklist.txt; path = ../../data/fonts_blacklist.txt; sourceTree = "<group>"; };
EEFE7C1312F8C9E1006AF8C3 /* fonts_whitelist.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = fonts_whitelist.txt; path = ../../data/fonts_whitelist.txt; sourceTree = "<group>"; };
EEFFB4E715DCDD8A00BACE1C /* libanim.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libanim.a; path = "libanim.a"; sourceTree = "SOURCE_ROOT"; };
F7B90CD11521E6D100C054EE /* CustomNavigationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomNavigationView.h; sourceTree = "<group>"; };
F7B90CD21521E6D100C054EE /* CustomNavigationView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomNavigationView.mm; sourceTree = "<group>"; };
F7DD848414FE77F8005695E1 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -2044,6 +2047,7 @@
FAEA8B2A1437CA80002A6737 /* libjansson.a in Frameworks */,
FAF29847146EEF4A00FF0057 /* libprotobuf.a in Frameworks */,
EE5A34E6156FCB9500E34FFE /* libgui.a in Frameworks */,
EEFFB4E815DCDD8A00BACE1C /* libanim.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2075,6 +2079,7 @@
FAFB0910151215EE0041901D /* libjansson.a in Frameworks */,
FAFB0911151215EE0041901D /* libprotobuf.a in Frameworks */,
EE5A34E7156FCBD800E34FFE /* libgui.a in Frameworks */,
EEFFB4E915DCDD8A00BACE1C /* libanim.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2277,6 +2282,7 @@
EE12020511CD464100ABDD5D /* libindexer.a */,
EE12020611CD464100ABDD5D /* libmap.a */,
EE12020811CD464100ABDD5D /* libyg.a */,
EEFFB4E715DCDD8A00BACE1C /* libanim.a */,
);
name = "Static Libraries";
sourceTree = "<group>";
@ -4347,6 +4353,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Simulator Lite";
};
@ -4444,6 +4454,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Production Lite";
};
@ -4498,6 +4512,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Debug Lite";
};
@ -4555,6 +4573,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "AdHoc Lite";
};
@ -4602,6 +4624,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Simulator Full";
};
@ -4656,6 +4682,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Debug Full";
};
@ -4713,6 +4743,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "AdHoc Full";
};
@ -4770,6 +4804,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Production Full";
};
@ -4826,6 +4864,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Release Lite";
};
@ -4882,6 +4924,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Pro.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Release Full";
};
@ -4889,6 +4935,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Simulator Lite";
};
@ -4896,6 +4946,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Simulator Full";
};
@ -4903,6 +4957,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Debug Lite";
};
@ -4910,6 +4968,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Debug Full";
};
@ -4917,6 +4979,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "AdHoc Lite";
};
@ -4924,6 +4990,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Release Lite";
};
@ -4931,6 +5001,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "AdHoc Full";
};
@ -4938,6 +5012,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Release Full";
};
@ -4945,6 +5023,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Production Lite";
};
@ -4952,6 +5034,10 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = "MapsWithMe-Lite.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../omim-iphone-release/out/release\"",
);
};
name = "Production Full";
};

View file

@ -6,7 +6,7 @@ CONFIG += staticlib
INCLUDEPATH += ../3party/protobuf/src
ROOT_DIR = ..
DEPENDENCIES = search gui yg indexer geometry coding base expat
DEPENDENCIES = search gui yg indexer anim geometry coding base expat
include($$ROOT_DIR/common.pri)
@ -48,6 +48,7 @@ HEADERS += \
tile_set.hpp \
geourl_process.hpp \
country_status_display.hpp \
rotate_screen_task.hpp
SOURCES += \
feature_vec_model.cpp \
@ -87,6 +88,7 @@ SOURCES += \
geourl_process.cpp \
bookmark.cpp \
country_status_display.cpp \
rotate_screen_task.cpp
!iphone*:!bada*:!android* {
HEADERS += qgl_render_context.hpp
@ -99,3 +101,7 @@ SOURCES += \

View file

@ -6,7 +6,7 @@ CONFIG -= app_bundle
TEMPLATE = app
ROOT_DIR = ../..
DEPENDENCIES = map gui search storage yg indexer platform geometry coding base \
DEPENDENCIES = map gui search storage yg indexer platform anim geometry coding base \
freetype fribidi expat protobuf tomcrypt jansson
include($$ROOT_DIR/common.pri)

View file

@ -16,6 +16,7 @@ SUBDIRS = 3party \
platform \
geometry/geometry_tests \
platform/platform_tests \
anim \
yg \
gui \
storage storage/storage_tests \
@ -35,6 +36,7 @@ SUBDIRS = 3party \
geometry \
version \
platform \
anim \
indexer \
storage \
yg \

View file

@ -1,6 +1,6 @@
# Main application in qt.
ROOT_DIR = ..
DEPENDENCIES = map gui search storage indexer yg platform geometry coding base \
DEPENDENCIES = map gui search storage indexer yg platform anim geometry coding base \
bzip2 freetype expat fribidi tomcrypt jansson version protobuf
include($$ROOT_DIR/common.pri)