summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authorzhurunz@google.com <zhurunz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 22:36:05 +0000
committerzhurunz@google.com <zhurunz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 22:36:05 +0000
commit04e4ea22d41506d722e43cbc682aa81b0c227ff8 (patch)
tree7cf76a4c8696177b34e061dde58d4fb83a09ccc9 /o3d
parent9c3c3eda705d30320ac66940710a6d7b1e3de801 (diff)
downloadchromium_src-04e4ea22d41506d722e43cbc682aa81b0c227ff8.zip
chromium_src-04e4ea22d41506d722e43cbc682aa81b0c227ff8.tar.gz
chromium_src-04e4ea22d41506d722e43cbc682aa81b0c227ff8.tar.bz2
Allows one mousemove event per N ticks.
Review URL: http://codereview.chromium.org/4592001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/core/cross/client.cc19
-rw-r--r--o3d/core/cross/client.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/o3d/core/cross/client.cc b/o3d/core/cross/client.cc
index c9f9066..a4160df 100644
--- a/o3d/core/cross/client.cc
+++ b/o3d/core/cross/client.cc
@@ -85,6 +85,15 @@ namespace o3d {
static const float kContinuousModeMinDrawPerSecond = 15;
// TODO(zhurunz) Tuning this value.
+// We don't want to handle too much MOUSEMOVE events for perf reasons.
+// This is used for limiting one MOUSEMOVE event per N ticks.
+//
+// Notes:
+// Don't limit MOUSEMOVE event on new texture since that don't always come.
+// Don't limit MOUSEMOVE event on rendering since RENDERMODE_ON_DEMAND might
+// depends on MOUSEMOVE first.
+static const int kTicksPerMouseMoveEvent = 4;
+
// Client constructor. Creates the default root node for the scenegraph
Client::Client(ServiceLocator* service_locator)
: service_locator_(service_locator),
@@ -103,6 +112,7 @@ Client::Client(ServiceLocator* service_locator)
event_manager_(),
is_ticking_(false),
last_tick_time_(0),
+ tick_count_(0),
root_(NULL),
#ifdef OS_WIN
calls_(0),
@@ -238,6 +248,7 @@ bool Client::Tick() {
}
is_ticking_ = false;
+ tick_count_++;
return message_check_ok;
}
@@ -470,6 +481,14 @@ void Client::ClearEventCallback(String type_name) {
}
void Client::AddEventToQueue(const Event& event) {
+ // Limit one MOUSEMOVE event per N ticks.
+ if (event.type() == Event::TYPE_MOUSEMOVE) {
+ if (tick_count_ <= kTicksPerMouseMoveEvent) {
+ return;
+ } else {
+ tick_count_ = 0;
+ }
+ }
event_manager_.AddEventToQueue(event);
}
diff --git a/o3d/core/cross/client.h b/o3d/core/cross/client.h
index 4affeb2..eebc586 100644
--- a/o3d/core/cross/client.h
+++ b/o3d/core/cross/client.h
@@ -520,6 +520,9 @@ class Client {
// Time used for tick and message processing.
float last_tick_time_;
+ // Number of ticks since last reset.
+ int tick_count_;
+
// Reference to global transform graph root for Client.
Transform::Ref root_;