OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 define([ | 5 define([ |
6 'console', | 6 'console', |
7 'monotonic_clock', | 7 'monotonic_clock', |
8 'timer', | 8 'timer', |
9 'mojo/public/js/bindings/connection', | 9 'mojo/public/js/bindings/connection', |
10 'mojo/public/js/bindings/core', | 10 'mojo/public/js/bindings/core', |
11 'mojo/apps/js/bindings/gl', | 11 'mojo/apps/js/bindings/gl', |
12 'mojo/apps/js/bindings/threading', | 12 'mojo/apps/js/bindings/threading', |
13 'mojo/services/native_viewport/native_viewport.mojom', | 13 'mojo/services/native_viewport/native_viewport.mojom', |
14 'mojo/public/interfaces/shell/shell.mojom', | 14 'mojo/public/interfaces/service_provider/service_provider.mojom', |
15 ], function(console, | 15 ], function(console, |
16 monotonicClock, | 16 monotonicClock, |
17 timer, | 17 timer, |
18 connection, | 18 connection, |
19 core, | 19 core, |
20 gljs, | 20 gljs, |
21 threading, | 21 threading, |
22 nativeViewport, | 22 nativeViewport, |
23 shell) { | 23 service_provider) { |
24 | 24 |
25 const VERTEX_SHADER_SOURCE = [ | 25 const VERTEX_SHADER_SOURCE = [ |
26 'uniform mat4 u_mvpMatrix;', | 26 'uniform mat4 u_mvpMatrix;', |
27 'attribute vec4 a_position;', | 27 'attribute vec4 a_position;', |
28 'void main()', | 28 'void main()', |
29 '{', | 29 '{', |
30 ' gl_Position = u_mvpMatrix * a_position;', | 30 ' gl_Position = u_mvpMatrix * a_position;', |
31 '}' | 31 '}' |
32 ].join('\n'); | 32 ].join('\n'); |
33 | 33 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 gl.bindBuffer(gl.ARRAY_BUFFER, 0); | 269 gl.bindBuffer(gl.ARRAY_BUFFER, 0); |
270 | 270 |
271 vboIndices = gl.createBuffer(); | 271 vboIndices = gl.createBuffer(); |
272 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vboIndices); | 272 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vboIndices); |
273 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, cubeIndices, gl.STATIC_DRAW); | 273 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, cubeIndices, gl.STATIC_DRAW); |
274 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0); | 274 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0); |
275 | 275 |
276 return cubeIndices.length; | 276 return cubeIndices.length; |
277 } | 277 } |
278 | 278 |
279 function SampleApp(shell) { | 279 function SampleApp(service_provider) { |
280 this.shell_ = shell; | 280 this.service_provider_ = service_provider; |
281 | 281 |
282 var pipe = new core.createMessagePipe(); | 282 var pipe = new core.createMessagePipe(); |
283 this.shell_.connect('mojo:mojo_native_viewport_service', pipe.handle1); | 283 this.service_provider_.connect('mojo:mojo_native_viewport_service', |
| 284 pipe.handle1); |
284 new connection.Connection(pipe.handle0, NativeViewportClientImpl, | 285 new connection.Connection(pipe.handle0, NativeViewportClientImpl, |
285 nativeViewport.NativeViewportProxy); | 286 nativeViewport.NativeViewportProxy); |
286 } | 287 } |
287 // TODO(aa): It is a bummer to need this stub object in JavaScript. We should | 288 // TODO(aa): It is a bummer to need this stub object in JavaScript. We should |
288 // have a 'client' object that contains both the sending and receiving bits of | 289 // have a 'client' object that contains both the sending and receiving bits of |
289 // the client side of the interface. Since JS is loosely typed, we do not need | 290 // the client side of the interface. Since JS is loosely typed, we do not need |
290 // a separate base class to inherit from to receive callbacks. | 291 // a separate base class to inherit from to receive callbacks. |
291 SampleApp.prototype = Object.create(shell.ShellClientStub.prototype); | 292 SampleApp.prototype = |
| 293 Object.create(service_provider.ServiceProviderStub.prototype); |
292 | 294 |
293 | 295 |
294 function NativeViewportClientImpl(remote) { | 296 function NativeViewportClientImpl(remote) { |
295 this.remote_ = remote; | 297 this.remote_ = remote; |
296 | 298 |
297 var pipe = core.createMessagePipe(); | 299 var pipe = core.createMessagePipe(); |
298 | 300 |
299 var rect = new nativeViewport.Rect; | 301 var rect = new nativeViewport.Rect; |
300 rect.position = new nativeViewport.Point; | 302 rect.position = new nativeViewport.Point; |
301 rect.size = new nativeViewport.Size; | 303 rect.size = new nativeViewport.Size; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 GLES2ClientImpl.prototype.getRotationForTimeDelta = function(secondsDelta) { | 385 GLES2ClientImpl.prototype.getRotationForTimeDelta = function(secondsDelta) { |
384 return secondsDelta * 40; | 386 return secondsDelta * 40; |
385 }; | 387 }; |
386 | 388 |
387 GLES2ClientImpl.prototype.contextLost = function() { | 389 GLES2ClientImpl.prototype.contextLost = function() { |
388 console.log('GLES2ClientImpl.prototype.contextLost'); | 390 console.log('GLES2ClientImpl.prototype.contextLost'); |
389 }; | 391 }; |
390 | 392 |
391 | 393 |
392 return function(handle) { | 394 return function(handle) { |
393 new connection.Connection(handle, SampleApp, shell.ShellProxy); | 395 new connection.Connection( |
| 396 handle, SampleApp, service_provider.ServiceProviderProxy); |
394 }; | 397 }; |
395 }); | 398 }); |
OLD | NEW |