summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaf@google.com <maf@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 23:33:21 +0000
committermaf@google.com <maf@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 23:33:21 +0000
commitf44ea0d6f8a6da9b98ecfe3fc30235ef65e28635 (patch)
tree438d764fb3ab89a93ee91d3764c053abf701ade0
parent26cd5c815ddc94fe643cb7acf23731d2a2d80915 (diff)
downloadchromium_src-f44ea0d6f8a6da9b98ecfe3fc30235ef65e28635.zip
chromium_src-f44ea0d6f8a6da9b98ecfe3fc30235ef65e28635.tar.gz
chromium_src-f44ea0d6f8a6da9b98ecfe3fc30235ef65e28635.tar.bz2
Add a boolean parameter to Client::RenderClient() to choose whether to
make the javascript render callback or not. Generally you want to pass true, but if the render is happening in non-windowed mode (eg on a Mac) and is in response to an update event rather than a timer, it can be useful to pass false to prevent the javascript code triggering another update and causing an infinite calback loop. Case in point is the custom camera example, which modifies some HTML form text fields on render callback, which on Firefox causes a plugin invalidation and round and round we would go. Review URL: http://codereview.chromium.org/159181 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21473 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--o3d/core/cross/client.cc5
-rw-r--r--o3d/core/cross/client.h12
-rw-r--r--o3d/plugin/cross/o3d_glue.cc2
-rw-r--r--o3d/plugin/linux/main_linux.cc14
-rw-r--r--o3d/plugin/mac/main_mac.mm10
-rw-r--r--o3d/plugin/mac/plugin_mac.mm2
-rw-r--r--o3d/tests/basic_system_test/basic_system_test.cc4
7 files changed, 31 insertions, 18 deletions
diff --git a/o3d/core/cross/client.cc b/o3d/core/cross/client.cc
index b6b103c..ed5fea3 100644
--- a/o3d/core/cross/client.cc
+++ b/o3d/core/cross/client.cc
@@ -210,7 +210,7 @@ void Client::ClearLostResourcesCallback() {
}
}
-void Client::RenderClient() {
+void Client::RenderClient(bool send_callback) {
ElapsedTimeTimer timer;
rendering_ = true;
render_tree_called_ = false;
@@ -223,7 +223,8 @@ void Client::RenderClient() {
counter_manager_.AdvanceRenderFrameCounters(1.0f);
profiler_->ProfileStart("Render callback");
- render_callback_manager_.Run(render_event_);
+ if (send_callback)
+ render_callback_manager_.Run(render_event_);
profiler_->ProfileStop("Render callback");
if (!render_tree_called_) {
diff --git a/o3d/core/cross/client.h b/o3d/core/cross/client.h
index 0f20172..16ffbf4 100644
--- a/o3d/core/cross/client.h
+++ b/o3d/core/cross/client.h
@@ -248,8 +248,16 @@ class Client {
// This is the function anything hosting the client, like a plugin, should
// call to render.
// Parameters:
- // None
- void RenderClient();
+ // send_callback : whether to make the javascript render callback.
+ // Generally you want to pass true, but if the render is happening
+ // in non-windowed mode (eg on a Mac) and is in response to an update
+ // event rather than a timer, it can be useful to pass false to prevent
+ // the javascript code triggering another update and causing an infinite
+ // calback loop. Case in point is the custom camera example, which
+ // modifies some HTML form text fields on render callback, which on
+ // Firefox causes a plugin invalidation and round and round we would
+ // go.
+ void RenderClient(bool send_callback);
// Sets the texture to use when a Texture or Sampler is missing while
// rendering. If you set it to NULL you'll get an error if you try to render
diff --git a/o3d/plugin/cross/o3d_glue.cc b/o3d/plugin/cross/o3d_glue.cc
index 47331ff..9d6c24e 100644
--- a/o3d/plugin/cross/o3d_glue.cc
+++ b/o3d/plugin/cross/o3d_glue.cc
@@ -863,7 +863,7 @@ void PluginObject::AsyncTick() {
void PluginObject::Tick() {
client_->Tick();
if (renderer_ && renderer_->need_to_render()) {
- client_->RenderClient();
+ client_->RenderClient(true);
}
DCHECK(pending_ticks_ > 0);
diff --git a/o3d/plugin/linux/main_linux.cc b/o3d/plugin/linux/main_linux.cc
index af39342..55096db 100644
--- a/o3d/plugin/linux/main_linux.cc
+++ b/o3d/plugin/linux/main_linux.cc
@@ -59,7 +59,7 @@ bool g_xembed_support = false;
static void DrawPlugin(PluginObject *obj) {
// Limit drawing to no more than once every timer tick.
if (!obj->draw_) return;
- obj->client()->RenderClient();
+ obj->client()->RenderClient(true);
obj->draw_ = false;
}
@@ -71,8 +71,10 @@ void LinuxTimer(XtPointer data, XtIntervalId* id) {
obj->client()->Tick();
obj->draw_ = true;
if (obj->renderer()) {
- if (obj->client()->render_mode() == o3d::Client::RENDERMODE_CONTINUOUS ||
- obj->renderer()->need_to_render()) {
+ if (obj->client()->render_mode() == o3d::Client::RENDERMODE_CONTINUOUS ||
+
+ obj->renderer()->need_to_render()) {
+
// NOTE: this draws no matter what instead of just invalidating the
// region, which means it will execute even if the plug-in window is
// invisible.
@@ -568,8 +570,10 @@ static gboolean GtkTimeoutCallback(gpointer user_data) {
obj->draw_ = true;
obj->client()->Tick();
if (obj->renderer()) {
- if (obj->client()->render_mode() == o3d::Client::RENDERMODE_CONTINUOUS ||
- obj->renderer()->need_to_render()) {
+ if (obj->client()->render_mode() == o3d::Client::RENDERMODE_CONTINUOUS ||
+
+ obj->renderer()->need_to_render()) {
+
gtk_widget_queue_draw(obj->gtk_container_);
}
}
diff --git a/o3d/plugin/mac/main_mac.mm b/o3d/plugin/mac/main_mac.mm
index 1ef1d1c..11355b7 100644
--- a/o3d/plugin/mac/main_mac.mm
+++ b/o3d/plugin/mac/main_mac.mm
@@ -73,8 +73,8 @@ scoped_ptr<base::AtExitManager> g_at_exit_manager;
#define CFTIMER
// #define DEFERRED_DRAW_ON_NULLEVENTS
-void DrawPlugin(PluginObject* obj) {
- obj->client()->RenderClient();
+void DrawPlugin(PluginObject* obj, bool send_callback) {
+ obj->client()->RenderClient(send_callback);
}
unsigned char GetMacEventKeyChar(const EventRecord *the_event) {
@@ -411,7 +411,7 @@ bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event) {
obj->MacEventReceived();
switch (the_event->type) {
case NPCocoaEventDrawRect:
- DrawPlugin(obj);
+ DrawPlugin(obj, false);
handled = true;
break;
case NPCocoaEventMouseDown:
@@ -729,7 +729,7 @@ bool HandleMacEvent(EventRecord* the_event, NPP instance) {
GLUE_PROFILE_STOP(instance, "forceredraw");
#elif defined(CFTIMER)
#else
- DrawPlugin(obj);
+ DrawPlugin(obj, true);
#endif
// Safari tab switching recovery code.
if (obj->mac_surface_hidden_) {
@@ -754,7 +754,7 @@ bool HandleMacEvent(EventRecord* the_event, NPP instance) {
handled = true;
break;
case updateEvt:
- DrawPlugin(obj);
+ DrawPlugin(obj, false);
handled = true;
break;
case osEvt:
diff --git a/o3d/plugin/mac/plugin_mac.mm b/o3d/plugin/mac/plugin_mac.mm
index 0714ad5..0c46fe3 100644
--- a/o3d/plugin/mac/plugin_mac.mm
+++ b/o3d/plugin/mac/plugin_mac.mm
@@ -246,7 +246,7 @@ void RenderTimer::TimerCallback(CFRunLoopTimerRef timer, void* info) {
aglSetInteger(obj->mac_agl_context_, AGL_SWAP_INTERVAL, &sync);
}
- obj->client()->RenderClient();
+ obj->client()->RenderClient(true);
}
}
}
diff --git a/o3d/tests/basic_system_test/basic_system_test.cc b/o3d/tests/basic_system_test/basic_system_test.cc
index b37ac8e8..598eb9f8 100644
--- a/o3d/tests/basic_system_test/basic_system_test.cc
+++ b/o3d/tests/basic_system_test/basic_system_test.cc
@@ -198,7 +198,7 @@ void BasicSystemTest::SetUp() {
void BasicSystemTest::TearDown() {
// Force another render to make the stream capture end.
- client()->RenderClient();
+ client()->RenderClient(true);
pack_->Destroy();
delete client_;
@@ -328,7 +328,7 @@ TEST_F(BasicSystemTest, BasicSystemTestCase) {
// and framebuffer contents.
BEGIN_ASSERT_STREAM_CAPTURE();
for (int frame_count = 0; frame_count < 5; ++frame_count) {
- client()->RenderClient();
+ client()->RenderClient(true);
ASSERT_FRAMEBUFFER();
Matrix4 mat(Matrix4::rotationY(static_cast<float>(frame_count) * 2 *
static_cast<float>(M_PI) / 5.0f));