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

Unified Diff: mojo/apps/js/main.js

Issue 131153007: Send size to NativeViewportClient::OnCreated instead of GLES2Client::DidCreateContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix TODO 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
Index: mojo/apps/js/main.js
diff --git a/mojo/apps/js/main.js b/mojo/apps/js/main.js
index 9ca9e9d4c7f3bd076aae146d56126920bb781364..348bd01f3a1b9821e4685fefe706480fd188d88d 100644
--- a/mojo/apps/js/main.js
+++ b/mojo/apps/js/main.js
@@ -295,7 +295,7 @@ define([
this.remote_ = remote;
var pipe = core.createMessagePipe();
- new GLES2ClientImpl(pipe.handle0);
+ this.gles2_ = new GLES2ClientImpl(pipe.handle0);
this.remote_.open();
this.remote_.createGLES2Context(pipe.handle1);
@@ -303,7 +303,8 @@ define([
NativeViewportClientImpl.prototype =
Object.create(nativeViewport.NativeViewportClientStub.prototype);
- NativeViewportClientImpl.prototype.onCreated = function() {
+ NativeViewportClientImpl.prototype.onCreated = function(width, height) {
+ this.gles2_.setDimensions(width, height);
console.log('NativeViewportClientImpl.prototype.OnCreated');
};
NativeViewportClientImpl.prototype.didOpen = function() {
@@ -317,9 +318,7 @@ define([
this.angle_ = 45;
}
- GLES2ClientImpl.prototype.didCreateContext = function(width, height) {
- this.width_ = width;
- this.height_ = height;
+ GLES2ClientImpl.prototype.didCreateContext = function() {
this.program_ = loadProgram(this.gl_);
this.positionLocation_ =
this.gl_.getAttribLocation(this.program_, 'a_position');
@@ -333,7 +332,14 @@ define([
this.timer_ = timer.createRepeating(16, this.handleTimer.bind(this));
};
+ GLES2ClientImpl.prototype.setDimensions = function(width, height) {
+ this.width_ = width;
+ this.height_ = height;
+ }
+
GLES2ClientImpl.prototype.drawCube = function() {
+ if (!this.width_ || !this.height_)
+ return;
this.gl_.viewport(0, 0, this.width_, this.height_);
this.gl_.clear(this.gl_.COLOR_BUFFER_BIT);
this.gl_.useProgram(this.program_);

Powered by Google App Engine
This is Rietveld 408576698