Skip to content

Commit

Permalink
Update mojo.js to use native_viewport
Browse files Browse the repository at this point in the history
This CL moves mojo.js from using hello_world_service to using native_viewport.
Now mojo.js creates a viewport, but we're still not able to draw GL becaues we
don't have WebGL bindings.

R=aa@chromium.org
BUG=324643

Review URL: https://codereview.chromium.org/98423005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238834 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
abarth@chromium.org committed Dec 5, 2013
1 parent a9fcce3 commit e1d0d62
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
3 changes: 3 additions & 0 deletions mojo/apps/js/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
}
58 changes: 44 additions & 14 deletions mojo/apps/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
});
8 changes: 6 additions & 2 deletions mojo/mojo_apps.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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': [
Expand Down

0 comments on commit e1d0d62

Please sign in to comment.