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

Unified Diff: mojo/examples/sample_app/sample_app.cc

Issue 451753003: Mojo multiple command buffer support and sample (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better casts Created 6 years, 4 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 | « mojo/examples/pepper_container_app/pepper_container_app.cc ('k') | mojo/examples/surfaces_app/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/sample_app/sample_app.cc
diff --git a/mojo/examples/sample_app/sample_app.cc b/mojo/examples/sample_app/sample_app.cc
index ceebd61b88b5fa4541066af6cfd167bc03c53e89..f1bcb72a52c4874d2a1944c1c87bc564dd60a459 100644
--- a/mojo/examples/sample_app/sample_app.cc
+++ b/mojo/examples/sample_app/sample_app.cc
@@ -12,6 +12,7 @@
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/macros.h"
#include "mojo/public/cpp/utility/run_loop.h"
+#include "mojo/services/public/interfaces/gpu/gpu.mojom.h"
#include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h"
namespace examples {
@@ -30,6 +31,9 @@ class SampleApp : public mojo::ApplicationDelegate,
app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_);
viewport_.set_client(this);
+ // TODO(jamesr): Should be mojo:mojo_gpu_service
+ app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_);
+
mojo::RectPtr rect(mojo::Rect::New());
rect->x = 10;
rect->y = 10;
@@ -37,27 +41,27 @@ class SampleApp : public mojo::ApplicationDelegate,
rect->height = 600;
viewport_->Create(rect.Pass());
viewport_->Show();
+ }
+ virtual void OnCreated(uint64_t native_viewport_id) MOJO_OVERRIDE {
+ mojo::SizePtr size = mojo::Size::New();
+ size->width = 800;
+ size->height = 600;
mojo::CommandBufferPtr command_buffer;
- viewport_->CreateGLES2Context(Get(&command_buffer));
+ gpu_service_->CreateOnscreenGLES2Context(
+ native_viewport_id, size.Pass(), Get(&command_buffer));
gles2_client_.reset(new GLES2ClientImpl(command_buffer.Pass()));
}
- virtual void OnCreated() MOJO_OVERRIDE {
- }
-
- virtual void OnDestroyed(
- const mojo::Callback<void()>& callback) MOJO_OVERRIDE {
- mojo::RunLoop::current()->Quit();
- callback.Run();
- }
+ virtual void OnDestroyed() MOJO_OVERRIDE { mojo::RunLoop::current()->Quit(); }
virtual void OnBoundsChanged(mojo::RectPtr bounds) MOJO_OVERRIDE {
assert(bounds);
mojo::SizePtr size(mojo::Size::New());
size->width = bounds->width;
size->height = bounds->height;
- gles2_client_->SetSize(*size);
+ if (gles2_client_)
+ gles2_client_->SetSize(*size);
}
virtual void OnEvent(mojo::EventPtr event,
@@ -71,6 +75,7 @@ class SampleApp : public mojo::ApplicationDelegate,
private:
scoped_ptr<GLES2ClientImpl> gles2_client_;
mojo::NativeViewportPtr viewport_;
+ mojo::GpuPtr gpu_service_;
DISALLOW_COPY_AND_ASSIGN(SampleApp);
};
« no previous file with comments | « mojo/examples/pepper_container_app/pepper_container_app.cc ('k') | mojo/examples/surfaces_app/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698