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

Unified Diff: mojo/apps/js/bindings/codec.js

Issue 131153007: Send size to NativeViewportClient::OnCreated instead of GLES2Client::DidCreateContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix various issues Created 6 years, 11 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 | « no previous file | mojo/apps/js/bindings/gl/context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/apps/js/bindings/codec.js
diff --git a/mojo/apps/js/bindings/codec.js b/mojo/apps/js/bindings/codec.js
index edaa005eafed9a9cdacc6c8aa855bc9d48f7d650..5df5803b2bee13f9479489c73b6b90a484797acb 100644
--- a/mojo/apps/js/bindings/codec.js
+++ b/mojo/apps/js/bindings/codec.js
@@ -95,6 +95,9 @@ define(function() {
this.viewU32 = new Uint32Array(
this.memory.buffer, 0,
Math.floor(this.memory.length / Uint32Array.BYTES_PER_ELEMENT));
+ this.viewFloat = new Float32Array(
+ this.memory.buffer, 0,
+ Math.floor(this.memory.length / Float32Array.BYTES_PER_ELEMENT));
}
Decoder.prototype.skip = function(offset) {
@@ -119,6 +122,12 @@ define(function() {
return low + high * 0x100000000;
};
+ Decoder.prototype.decodeFloat = function() {
+ var result = this.viewFloat[this.next / this.viewFloat.BYTES_PER_ELEMENT];
+ this.next += this.viewFloat.BYTES_PER_ELEMENT;
+ return result;
+ };
+
Decoder.prototype.decodePointer = function() {
// TODO(abarth): To correctly decode a pointer, we need to know the real
// base address of the array buffer.
@@ -203,6 +212,14 @@ define(function() {
this.next += 8;
};
+ Encoder.prototype.encodeFloat = function(val) {
+ var floatBuffer = new Float32Array(1);
+ floatBuffer[0] = val;
+ var buffer = new Uint8Array(floatBuffer.buffer, 0);
+ for (var i = 0; i < buffer.length; ++i)
+ this.buffer.memory[this.next++] = buffer[i];
+ };
+
Encoder.prototype.encodePointer = function(pointer) {
if (!pointer)
return this.write64(0);
« no previous file with comments | « no previous file | mojo/apps/js/bindings/gl/context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698