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

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

Issue 7529009: Updated demo to use resizable plugin element. This exercises the new PPB_Graphics3D_Dev::Resize()... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | « gpu/demos/framework/demo.cc ('k') | gpu/demos/framework/window.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/demos/framework/pepper.cc
===================================================================
--- gpu/demos/framework/pepper.cc (revision 94518)
+++ gpu/demos/framework/pepper.cc (working copy)
@@ -24,7 +24,8 @@
module_(module),
demo_(CreateDemo()),
swap_pending_(false),
- paint_needed_(false) {
+ paint_needed_(false),
+ resize_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);
@@ -44,19 +45,12 @@
return;
size_ = position.size();
- demo_->InitWindowSize(size_.width(), size_.height());
- if (context_.is_null()) {
- context_ = pp::Graphics3D_Dev(*this, 0, pp::Graphics3D_Dev(), NULL);
- if (context_.is_null())
- return;
+ if (context_.is_null())
+ CreateContext();
+ else
+ resize_needed_ = true;
- pp::Instance::BindGraphics(context_);
- glSetCurrentContextPPAPI(context_.pp_resource());
- demo_->InitGL();
- glSetCurrentContextPPAPI(0);
- }
-
Paint();
}
@@ -66,15 +60,46 @@
paint_needed_ = true;
return;
}
+
+ if (resize_needed_) {
+ context_.ResizeBuffers(size_.width(), size_.height());
+ demo_->Resize(size_.width(), size_.height());
+ resize_needed_ = false;
+ }
+
glSetCurrentContextPPAPI(context_.pp_resource());
demo_->Draw();
+ glSetCurrentContextPPAPI(0);
+
swap_pending_ = true;
context_.SwapBuffers(
callback_factory_.NewCallback(&PluginInstance::OnSwap));
+ }
+
+ private:
+ void CreateContext() {
+ int32_t attribs[] = {
+ PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
+ PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
+ PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8,
+ PP_GRAPHICS3DATTRIB_SAMPLES, 0,
+ PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0,
+ PP_GRAPHICS3DATTRIB_WIDTH, size_.width(),
+ PP_GRAPHICS3DATTRIB_HEIGHT, size_.height(),
+ PP_GRAPHICS3DATTRIB_NONE
+ };
+ context_ = pp::Graphics3D_Dev(*this, 0, pp::Graphics3D_Dev(), attribs);
+ if (context_.is_null())
+ return;
+
+ pp::Instance::BindGraphics(context_);
+
+ glSetCurrentContextPPAPI(context_.pp_resource());
+ demo_->InitGL();
+ demo_->Resize(size_.width(), size_.height());
glSetCurrentContextPPAPI(0);
}
- private:
void OnSwap(int32_t) {
swap_pending_ = false;
if (paint_needed_ || demo_->IsAnimated()) {
@@ -89,6 +114,7 @@
pp::Size size_;
bool swap_pending_;
bool paint_needed_;
+ bool resize_needed_;
pp::CompletionCallbackFactory<PluginInstance> callback_factory_;
};
« no previous file with comments | « gpu/demos/framework/demo.cc ('k') | gpu/demos/framework/window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698