Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3209)

Unified Diff: gpu/demos/framework/pepper.cc

Issue 5944001: Make Graphics3D::SwapBuffers take a completion callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update to Alok's Context3D/Surface3D changes Created 9 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc ('k') | ppapi/cpp/dev/surface_3d_dev.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/demos/framework/pepper.cc
diff --git a/gpu/demos/framework/pepper.cc b/gpu/demos/framework/pepper.cc
index ce698d525d582453b33d540af36947dbe6adc54b..c6f6e1f231218ab05b84255c2cb8226f0575cf29 100644
--- a/gpu/demos/framework/pepper.cc
+++ b/gpu/demos/framework/pepper.cc
@@ -24,7 +24,9 @@ class PluginInstance : public pp::Instance {
PluginInstance(PP_Instance instance, pp::Module* module)
: pp::Instance(instance),
module_(module),
- demo_(CreateDemo()) {
+ demo_(CreateDemo()),
+ swap_pending_(false),
+ paint_needed_(false) {
// Set the callback object outside of the initializer list to avoid a
// compiler warning about using "this" in an initializer list.
callback_factory_.Initialize(this);
@@ -63,24 +65,30 @@ class PluginInstance : public pp::Instance {
context_.BindSurfaces(surface_, surface_);
pp::Instance::BindGraphics(surface_);
- if (demo_->IsAnimated())
- Animate(0);
- else
- Paint();
+ Paint();
}
void Paint() {
+ if (swap_pending_) {
+ // A swap is pending. Delay paint until swap finishes.
+ paint_needed_ = true;
+ return;
+ }
glSetCurrentContextPPAPI(context_.pp_resource());
demo_->Draw();
- surface_.SwapBuffers();
+ swap_pending_ = true;
+ surface_.SwapBuffers(
+ callback_factory_.NewCallback(&PluginInstance::OnSwap));
glSetCurrentContextPPAPI(0);
}
private:
- void Animate(int delay) {
- Paint();
- module_->core()->CallOnMainThread(delay,
- callback_factory_.NewCallback(&PluginInstance::Animate), delay);
+ void OnSwap(int32_t) {
+ swap_pending_ = false;
+ if (paint_needed_ || demo_->IsAnimated()) {
+ paint_needed_ = false;
+ Paint();
+ }
}
pp::Module* module_;
@@ -88,6 +96,8 @@ class PluginInstance : public pp::Instance {
pp::Context3D_Dev context_;
pp::Surface3D_Dev surface_;
pp::Size size_;
+ bool swap_pending_;
+ bool paint_needed_;
pp::CompletionCallbackFactory<PluginInstance> callback_factory_;
};
« no previous file with comments | « chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc ('k') | ppapi/cpp/dev/surface_3d_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698