summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mojo/apps/js/main.cc3
-rw-r--r--mojo/apps/js/main.js58
-rw-r--r--mojo/mojo_apps.gypi8
3 files changed, 53 insertions, 16 deletions
diff --git a/mojo/apps/js/main.cc b/mojo/apps/js/main.cc
index 12ec34e..3ecca28 100644
--- a/mojo/apps/js/main.cc
+++ b/mojo/apps/js/main.cc
@@ -6,6 +6,7 @@
#include "gin/public/isolate_holder.h"
#include "mojo/apps/js/mojo_runner_delegate.h"
#include "mojo/common/bindings_support_impl.h"
+#include "mojo/public/gles2/gles2.h"
#include "mojo/public/system/core_cpp.h"
#include "mojo/public/system/macros.h"
@@ -39,9 +40,11 @@ void Start(MojoHandle pipe, const std::string& module) {
extern "C" MOJO_APPS_JS_EXPORT MojoResult CDECL MojoMain(MojoHandle pipe) {
mojo::common::BindingsSupportImpl bindings_support;
mojo::BindingsSupport::Set(&bindings_support);
+ MojoGLES2Initialize();
mojo::apps::Start(pipe, "mojo/apps/js/main");
+ MojoGLES2Terminate();
mojo::BindingsSupport::Set(NULL);
return MOJO_RESULT_OK;
}
diff --git a/mojo/apps/js/main.js b/mojo/apps/js/main.js
index 5f596c3..1dd5ff8 100644
--- a/mojo/apps/js/main.js
+++ b/mojo/apps/js/main.js
@@ -5,29 +5,59 @@
define([
"console",
"mojo/apps/js/bindings/connector",
+ "mojo/apps/js/bindings/core",
"mojo/apps/js/bindings/threading",
- "mojom/hello_world_service",
-], function(console, connector, threading, hello) {
+ "mojom/native_viewport",
+ "mojom/gles2",
+], function(console,
+ connector,
+ core,
+ threading,
+ nativeViewport,
+ gles2) {
- function HelloWorldClientImpl() {
+ function NativeViewportClientImpl() {
}
- HelloWorldClientImpl.prototype =
- Object.create(hello.HelloWorldClientStub.prototype);
+ NativeViewportClientImpl.prototype =
+ Object.create(nativeViewport.NativeViewportClientStub.prototype);
- HelloWorldClientImpl.prototype.didReceiveGreeting = function(result) {
- console.log("DidReceiveGreeting from pipe: " + result);
- connection.close();
- threading.quit();
+ NativeViewportClientImpl.prototype.didOpen = function() {
+ console.log("NativeViewportClientImpl.prototype.DidOpen");
};
- var connection = null;
+ function GLES2ClientImpl() {
+ }
+
+ GLES2ClientImpl.prototype =
+ Object.create(gles2.GLES2ClientStub.prototype);
+
+ GLES2ClientImpl.prototype.didCreateContext = function(encoded,
+ width,
+ height) {
+ console.log("GLES2ClientImpl.prototype.didCreateContext");
+ // Need to call MojoGLES2MakeCurrent(encoded) in C++.
+ // TODO(abarth): Should we handle some of this GL setup in C++?
+ };
+
+ GLES2ClientImpl.prototype.contextLost = function() {
+ console.log("GLES2ClientImpl.prototype.contextLost");
+ };
+
+ var nativeViewportConnection = null;
+ var gles2Connection = null;
return function(handle) {
- connection = new connector.Connection(handle,
- HelloWorldClientImpl,
- hello.HelloWorldServiceProxy);
+ nativeViewportConnection = new connector.Connection(
+ handle,
+ NativeViewportClientImpl,
+ nativeViewport.NativeViewportProxy);
+
+ var gles2Handles = core.createMessagePipe();
+ gles2Connection = new connector.Connection(
+ gles2Handles.handle0, GLES2ClientImpl, gles2.GLES2Proxy);
- connection.remote.greeting("hello, world!");
+ nativeViewportConnection.remote.open();
+ nativeViewportConnection.remote.createGLES2Context(gles2Handles.handle1);
};
});
diff --git a/mojo/mojo_apps.gypi b/mojo/mojo_apps.gypi
index 5d5605f..dddf66f 100644
--- a/mojo/mojo_apps.gypi
+++ b/mojo/mojo_apps.gypi
@@ -6,15 +6,19 @@
'dependencies': [
'../base/base.gyp:base',
'../gin/gin.gyp:gin',
- 'hello_world_service',
'mojo_common_lib',
+ 'mojo_gles2',
+ 'mojo_gles2_bindings',
+ 'mojo_native_viewport_bindings',
'mojo_system',
],
'export_dependent_settings': [
'../base/base.gyp:base',
'../gin/gin.gyp:gin',
- 'hello_world_service',
'mojo_common_lib',
+ 'mojo_gles2',
+ 'mojo_gles2_bindings',
+ 'mojo_native_viewport_bindings',
'mojo_system',
],
'sources': [