summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 20:39:34 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 20:39:34 +0000
commitdbccad7fadd2cca98722f1fd99b394c8a20ebf05 (patch)
treede735deef76cefea85c5d30c922173ab2b3fa7ba /mojo
parentb9f812940e5ad63483cbd467aed26bb65296e321 (diff)
downloadchromium_src-dbccad7fadd2cca98722f1fd99b394c8a20ebf05.zip
chromium_src-dbccad7fadd2cca98722f1fd99b394c8a20ebf05.tar.gz
chromium_src-dbccad7fadd2cca98722f1fd99b394c8a20ebf05.tar.bz2
Send size to NativeViewportClient::OnCreated instead of GLES2Client::DidCreateContext
The size is not really a concept that belongs to GL. Note, we can still start creating the context before we get OnCreated. BUG=333157 Review URL: https://codereview.chromium.org/131153007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r--mojo/apps/js/bindings/codec.js17
-rw-r--r--mojo/apps/js/bindings/gl/context.cc15
-rw-r--r--mojo/apps/js/bindings/gl/context.h7
-rw-r--r--mojo/apps/js/main.js30
-rw-r--r--mojo/examples/aura_demo/aura_demo.cc3
-rw-r--r--mojo/examples/aura_demo/root_window_host_mojo.cc18
-rw-r--r--mojo/examples/aura_demo/root_window_host_mojo.h7
-rw-r--r--mojo/examples/compositor_app/compositor_app.cc6
-rw-r--r--mojo/examples/compositor_app/compositor_host.cc5
-rw-r--r--mojo/examples/compositor_app/compositor_host.h3
-rw-r--r--mojo/examples/compositor_app/gles2_client_impl.cc14
-rw-r--r--mojo/examples/compositor_app/gles2_client_impl.h12
-rw-r--r--mojo/examples/launcher/launcher.cc1
-rw-r--r--mojo/examples/sample_app/gles2_client_impl.cc26
-rw-r--r--mojo/examples/sample_app/gles2_client_impl.h13
-rw-r--r--mojo/examples/sample_app/sample_app.cc1
-rw-r--r--mojo/gles2/gles2_client_impl.cc6
-rw-r--r--mojo/gles2/gles2_client_impl.h4
-rw-r--r--mojo/public/gles2/gles2_types.h7
-rw-r--r--mojo/services/gles2/gles2.mojom2
-rw-r--r--mojo/services/gles2/gles2_impl.cc2
-rw-r--r--mojo/services/native_viewport/native_viewport_mac.mm1
-rw-r--r--mojo/services/native_viewport/native_viewport_service.cc3
-rw-r--r--mojo/services/native_viewport/native_viewport_x11.cc1
24 files changed, 121 insertions, 83 deletions
diff --git a/mojo/apps/js/bindings/codec.js b/mojo/apps/js/bindings/codec.js
index edaa005..5df5803 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);
diff --git a/mojo/apps/js/bindings/gl/context.cc b/mojo/apps/js/bindings/gl/context.cc
index 878a873..a4f54fe 100644
--- a/mojo/apps/js/bindings/gl/context.cc
+++ b/mojo/apps/js/bindings/gl/context.cc
@@ -166,7 +166,7 @@ Context::~Context() {
MojoGLES2DestroyContext(context_);
}
-void Context::DidCreateContext(uint32_t width, uint32_t height) {
+void Context::DidCreateContext() {
// TODO(aa): When we want to support multiple contexts, we should add
// Context::MakeCurrent() for developers to switch between them.
MojoGLES2MakeCurrent(context_);
@@ -178,18 +178,11 @@ void Context::DidCreateContext(uint32_t width, uint32_t height) {
v8::Handle<v8::Function> callback = v8::Local<v8::Function>::New(
isolate, did_create_callback_);
- v8::Handle<v8::Value> args[] = {
- gin::ConvertToV8(isolate, width),
- gin::ConvertToV8(isolate, height),
- };
- runner_->Call(callback, runner_->global(), 2, args);
+ runner_->Call(callback, runner_->global(), 0, NULL);
}
-void Context::DidCreateContextThunk(
- void* closure,
- uint32_t width,
- uint32_t height) {
- static_cast<Context*>(closure)->DidCreateContext(width, height);
+void Context::DidCreateContextThunk(void* closure) {
+ static_cast<Context*>(closure)->DidCreateContext();
}
void Context::ContextLost() {
diff --git a/mojo/apps/js/bindings/gl/context.h b/mojo/apps/js/bindings/gl/context.h
index de47f15..94f56b6 100644
--- a/mojo/apps/js/bindings/gl/context.h
+++ b/mojo/apps/js/bindings/gl/context.h
@@ -62,11 +62,8 @@ class Context : public gin::Wrappable<Context> {
v8::Handle<v8::Function> did_create_callback);
virtual ~Context();
- void DidCreateContext(uint32_t width, uint32_t height);
- static void DidCreateContextThunk(
- void* closure,
- uint32_t width,
- uint32_t height);
+ void DidCreateContext();
+ static void DidCreateContextThunk(void* closure);
void ContextLost();
static void ContextLostThunk(void* closure);
diff --git a/mojo/apps/js/main.js b/mojo/apps/js/main.js
index 9ca9e9d..1a159670 100644
--- a/mojo/apps/js/main.js
+++ b/mojo/apps/js/main.js
@@ -295,9 +295,15 @@ define([
this.remote_ = remote;
var pipe = core.createMessagePipe();
- new GLES2ClientImpl(pipe.handle0);
-
- this.remote_.open();
+ this.gles2_ = new GLES2ClientImpl(pipe.handle0);
+
+ var rect = new nativeViewport.Rect;
+ rect.position = new nativeViewport.Point;
+ rect.size = new nativeViewport.Size;
+ rect.size.width = 800;
+ rect.size.height = 600;
+ this.remote_.create(rect);
+ this.remote_.show();
this.remote_.createGLES2Context(pipe.handle1);
}
NativeViewportClientImpl.prototype =
@@ -306,10 +312,11 @@ define([
NativeViewportClientImpl.prototype.onCreated = function() {
console.log('NativeViewportClientImpl.prototype.OnCreated');
};
- NativeViewportClientImpl.prototype.didOpen = function() {
- console.log('NativeViewportClientImpl.prototype.DidOpen');
- };
+ NativeViewportClientImpl.prototype.onBoundsChanged = function(bounds) {
+ console.log('NativeViewportClientImpl.prototype.OnBoundsChanged');
+ this.gles2_.setDimensions(bounds.size);
+ }
function GLES2ClientImpl(remotePipe) {
this.gl_ = new gljs.Context(remotePipe, this.didCreateContext.bind(this));
@@ -317,9 +324,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 +338,14 @@ define([
this.timer_ = timer.createRepeating(16, this.handleTimer.bind(this));
};
+ GLES2ClientImpl.prototype.setDimensions = function(size) {
+ this.width_ = size.width;
+ this.height_ = size.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_);
diff --git a/mojo/examples/aura_demo/aura_demo.cc b/mojo/examples/aura_demo/aura_demo.cc
index 3d9bb16..91fa7cd 100644
--- a/mojo/examples/aura_demo/aura_demo.cc
+++ b/mojo/examples/aura_demo/aura_demo.cc
@@ -140,7 +140,8 @@ class AuraDemo : public ShellClient {
private:
void HostContextCreated() {
- aura::RootWindow::CreateParams params(gfx::Rect(0, 0, 500, 500));
+ aura::RootWindow::CreateParams params(
+ gfx::Rect(root_window_host_->bounds().size()));
params.host = root_window_host_.get();
root_window_.reset(new aura::RootWindow(params));
root_window_host_->set_delegate(root_window_.get());
diff --git a/mojo/examples/aura_demo/root_window_host_mojo.cc b/mojo/examples/aura_demo/root_window_host_mojo.cc
index b448123..86794f2 100644
--- a/mojo/examples/aura_demo/root_window_host_mojo.cc
+++ b/mojo/examples/aura_demo/root_window_host_mojo.cc
@@ -31,7 +31,8 @@ WindowTreeHostMojo::WindowTreeHostMojo(
ScopedMessagePipeHandle viewport_handle,
const gfx::Rect& bounds,
const base::Callback<void()>& compositor_created_callback)
- : native_viewport_(viewport_handle.Pass(), this),
+ : context_created_(false),
+ native_viewport_(viewport_handle.Pass(), this),
compositor_created_callback_(compositor_created_callback) {
AllocationScope scope;
native_viewport_->Create(bounds);
@@ -160,7 +161,9 @@ void WindowTreeHostMojo::OnCreated() {
void WindowTreeHostMojo::OnBoundsChanged(const Rect& bounds) {
bounds_ = gfx::Rect(bounds.position().x(), bounds.position().y(),
bounds.size().width(), bounds.size().height());
- window()->SetBounds(gfx::Rect(bounds_.size()));
+ if (delegate_)
+ window()->SetBounds(gfx::Rect(bounds_.size()));
+ CreateCompositorIfNeeded();
}
void WindowTreeHostMojo::OnDestroyed() {
@@ -200,10 +203,17 @@ void WindowTreeHostMojo::OnEvent(const Event& event) {
////////////////////////////////////////////////////////////////////////////////
// WindowTreeHostMojo, private:
-void WindowTreeHostMojo::DidCreateContext(gfx::Size viewport_size) {
+void WindowTreeHostMojo::DidCreateContext() {
+ context_created_ = true;
+ CreateCompositorIfNeeded();
+}
+
+void WindowTreeHostMojo::CreateCompositorIfNeeded() {
+ if (bounds_.IsEmpty() || !context_created_)
+ return;
CreateCompositor(GetAcceleratedWidget());
compositor_created_callback_.Run();
- NotifyHostResized(viewport_size);
+ NotifyHostResized(bounds_.size());
}
} // namespace examples
diff --git a/mojo/examples/aura_demo/root_window_host_mojo.h b/mojo/examples/aura_demo/root_window_host_mojo.h
index bbc8fc2..d75bfde 100644
--- a/mojo/examples/aura_demo/root_window_host_mojo.h
+++ b/mojo/examples/aura_demo/root_window_host_mojo.h
@@ -28,6 +28,7 @@ class WindowTreeHostMojo : public aura::WindowTreeHost,
const base::Callback<void()>& compositor_created_callback);
virtual ~WindowTreeHostMojo();
+ gfx::Rect bounds() const { return bounds_; }
GLES2ClientImpl* gles2_client() { return gles2_client_.get(); }
private:
@@ -55,16 +56,18 @@ class WindowTreeHostMojo : public aura::WindowTreeHost,
virtual void PrepareForShutdown() OVERRIDE;
// Overridden from NativeViewportClient:
- virtual void OnCreated() OVERRIDE;
+ virtual void OnCreated() MOJO_OVERRIDE;
virtual void OnDestroyed() OVERRIDE;
virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE;
virtual void OnEvent(const Event& event) OVERRIDE;
- void DidCreateContext(gfx::Size size);
+ void DidCreateContext();
+ void CreateCompositorIfNeeded();
static ui::ContextFactory* context_factory_;
scoped_ptr<GLES2ClientImpl> gles2_client_;
+ bool context_created_;
RemotePtr<NativeViewport> native_viewport_;
base::Callback<void()> compositor_created_callback_;
diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc
index de6db6b..f8c7078 100644
--- a/mojo/examples/compositor_app/compositor_app.cc
+++ b/mojo/examples/compositor_app/compositor_app.cc
@@ -52,6 +52,7 @@ class SampleApp : public ShellClient {
public:
explicit NativeViewportClientImpl(ScopedMessagePipeHandle viewport_handle)
: viewport_(viewport_handle.Pass(), this) {
+ AllocationScope allocation;
viewport_->Create(gfx::Rect(10, 10, 800, 600));
viewport_->Show();
ScopedMessagePipeHandle gles2_handle;
@@ -66,8 +67,8 @@ class SampleApp : public ShellClient {
host_.reset(new CompositorHost(gles2_client_.get()));
}
- void DidCreateContext(gfx::Size viewport_size) {
- host_->DidCreateContext(viewport_size);
+ void DidCreateContext() {
+ host_->DidCreateContext();
}
virtual ~NativeViewportClientImpl() {}
@@ -80,6 +81,7 @@ class SampleApp : public ShellClient {
}
virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE {
+ host_->SetSize(bounds.size());
}
virtual void OnEvent(const Event& event) MOJO_OVERRIDE {
diff --git a/mojo/examples/compositor_app/compositor_host.cc b/mojo/examples/compositor_app/compositor_host.cc
index d78b994..cc45c19 100644
--- a/mojo/examples/compositor_app/compositor_host.cc
+++ b/mojo/examples/compositor_app/compositor_host.cc
@@ -67,8 +67,11 @@ CompositorHost::CompositorHost(GLES2ClientImpl* gles2_client_impl)
CompositorHost::~CompositorHost() {}
-void CompositorHost::DidCreateContext(gfx::Size viewport_size) {
+void CompositorHost::SetSize(gfx::Size viewport_size) {
tree_->SetViewportSize(viewport_size);
+}
+
+void CompositorHost::DidCreateContext() {
tree_->SetLayerTreeHostClientReady();
tree_->InitializeOutputSurfaceIfNeeded();
}
diff --git a/mojo/examples/compositor_app/compositor_host.h b/mojo/examples/compositor_app/compositor_host.h
index d033b1c..3b4064f 100644
--- a/mojo/examples/compositor_app/compositor_host.h
+++ b/mojo/examples/compositor_app/compositor_host.h
@@ -25,7 +25,8 @@ class CompositorHost : public cc::LayerTreeHostClient {
explicit CompositorHost(GLES2ClientImpl* gles2_client_impl);
virtual ~CompositorHost();
- void DidCreateContext(gfx::Size viewport_size);
+ void SetSize(gfx::Size viewport_size);
+ void DidCreateContext();
// cc::LayerTreeHostClient implementation.
virtual void WillBeginMainFrame(int frame_id) OVERRIDE;
diff --git a/mojo/examples/compositor_app/gles2_client_impl.cc b/mojo/examples/compositor_app/gles2_client_impl.cc
index 3b59f96..5cc0321 100644
--- a/mojo/examples/compositor_app/gles2_client_impl.cc
+++ b/mojo/examples/compositor_app/gles2_client_impl.cc
@@ -13,7 +13,7 @@ namespace examples {
GLES2ClientImpl::GLES2ClientImpl(
ScopedMessagePipeHandle pipe,
- const base::Callback<void(gfx::Size)>& context_created_callback)
+ const base::Callback<void()>& context_created_callback)
: context_created_callback_(context_created_callback) {
context_ = MojoGLES2CreateContext(
pipe.release().value(),
@@ -42,18 +42,14 @@ gpu::ContextSupport* GLES2ClientImpl::Support() const {
MojoGLES2GetContextSupport(context_));
}
-void GLES2ClientImpl::DidCreateContext(uint32_t width,
- uint32_t height) {
+void GLES2ClientImpl::DidCreateContext() {
TRACE_EVENT0("compositor_app", "DidCreateContext");
if (!context_created_callback_.is_null())
- context_created_callback_.Run(gfx::Size(width, height));
+ context_created_callback_.Run();
}
-void GLES2ClientImpl::DidCreateContextThunk(
- void* closure,
- uint32_t width,
- uint32_t height) {
- static_cast<GLES2ClientImpl*>(closure)->DidCreateContext(width, height);
+void GLES2ClientImpl::DidCreateContextThunk(void* closure) {
+ static_cast<GLES2ClientImpl*>(closure)->DidCreateContext();
}
void GLES2ClientImpl::ContextLost() {
diff --git a/mojo/examples/compositor_app/gles2_client_impl.h b/mojo/examples/compositor_app/gles2_client_impl.h
index e162b1d..657bf79 100644
--- a/mojo/examples/compositor_app/gles2_client_impl.h
+++ b/mojo/examples/compositor_app/gles2_client_impl.h
@@ -10,7 +10,6 @@
#include "mojo/public/bindings/remote_ptr.h"
#include "mojo/public/gles2/gles2.h"
#include "mojom/native_viewport.h"
-#include "ui/gfx/size.h"
namespace gpu {
class ContextSupport;
@@ -26,22 +25,19 @@ class GLES2ClientImpl {
public:
GLES2ClientImpl(
ScopedMessagePipeHandle pipe,
- const base::Callback<void(gfx::Size)>& context_created_callback);
+ const base::Callback<void()>& context_created_callback);
virtual ~GLES2ClientImpl();
gpu::gles2::GLES2Interface* Interface() const;
gpu::ContextSupport* Support() const;
private:
- void DidCreateContext(uint32_t width, uint32_t height);
- static void DidCreateContextThunk(
- void* closure,
- uint32_t width,
- uint32_t height);
+ void DidCreateContext();
+ static void DidCreateContextThunk(void* closure);
void ContextLost();
static void ContextLostThunk(void* closure);
- base::Callback<void(gfx::Size viewport_size)> context_created_callback_;
+ base::Callback<void()> context_created_callback_;
MojoGLES2Context context_;
diff --git a/mojo/examples/launcher/launcher.cc b/mojo/examples/launcher/launcher.cc
index c5d4962..891c7b4 100644
--- a/mojo/examples/launcher/launcher.cc
+++ b/mojo/examples/launcher/launcher.cc
@@ -268,6 +268,5 @@ extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain(
mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass());
loop.Run();
- MojoGLES2Terminate();
return MOJO_RESULT_OK;
}
diff --git a/mojo/examples/sample_app/gles2_client_impl.cc b/mojo/examples/sample_app/gles2_client_impl.cc
index b3f2003..eb7f47b 100644
--- a/mojo/examples/sample_app/gles2_client_impl.cc
+++ b/mojo/examples/sample_app/gles2_client_impl.cc
@@ -22,7 +22,8 @@ float CalculateDragDistance(const gfx::PointF& start, const Point& end) {
}
GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe)
- : getting_animation_frames_(false) {
+ : getting_animation_frames_(false),
+ context_created_(false) {
context_ = MojoGLES2CreateContext(
pipe.release().value(),
&DidCreateContextThunk,
@@ -35,6 +36,11 @@ GLES2ClientImpl::~GLES2ClientImpl() {
MojoGLES2DestroyContext(context_);
}
+void GLES2ClientImpl::SetSize(const Size& size) {
+ size_ = gfx::Size(size.width(), size.height());
+ InitializeCubeIfNeeded();
+}
+
void GLES2ClientImpl::HandleInputEvent(const Event& event) {
switch (event.action()) {
case ui::ET_MOUSE_PRESSED:
@@ -75,19 +81,21 @@ void GLES2ClientImpl::HandleInputEvent(const Event& event) {
}
}
-void GLES2ClientImpl::DidCreateContext(uint32_t width,
- uint32_t height) {
+void GLES2ClientImpl::DidCreateContext() {
MojoGLES2MakeCurrent(context_);
+ context_created_ = true;
+ InitializeCubeIfNeeded();
+}
- cube_.Init(width, height);
+void GLES2ClientImpl::InitializeCubeIfNeeded() {
+ if (size_.IsEmpty() || !context_created_)
+ return;
+ cube_.Init(size_.width(), size_.height());
RequestAnimationFrames();
}
-void GLES2ClientImpl::DidCreateContextThunk(
- void* closure,
- uint32_t width,
- uint32_t height) {
- static_cast<GLES2ClientImpl*>(closure)->DidCreateContext(width, height);
+void GLES2ClientImpl::DidCreateContextThunk(void* closure) {
+ static_cast<GLES2ClientImpl*>(closure)->DidCreateContext();
}
void GLES2ClientImpl::ContextLost() {
diff --git a/mojo/examples/sample_app/gles2_client_impl.h b/mojo/examples/sample_app/gles2_client_impl.h
index dbb5e82..a30b546 100644
--- a/mojo/examples/sample_app/gles2_client_impl.h
+++ b/mojo/examples/sample_app/gles2_client_impl.h
@@ -10,6 +10,7 @@
#include "mojo/public/gles2/gles2.h"
#include "mojom/native_viewport.h"
#include "ui/gfx/point_f.h"
+#include "ui/gfx/size.h"
namespace mojo {
namespace examples {
@@ -19,14 +20,12 @@ class GLES2ClientImpl {
explicit GLES2ClientImpl(ScopedMessagePipeHandle pipe);
virtual ~GLES2ClientImpl();
+ void SetSize(const Size& size);
void HandleInputEvent(const Event& event);
private:
- void DidCreateContext(uint32_t width, uint32_t height);
- static void DidCreateContextThunk(
- void* closure,
- uint32_t width,
- uint32_t height);
+ void DidCreateContext();
+ static void DidCreateContextThunk(void* closure);
void ContextLost();
static void ContextLostThunk(void* closure);
void DrawAnimationFrame();
@@ -35,7 +34,10 @@ class GLES2ClientImpl {
void RequestAnimationFrames();
void CancelAnimationFrames();
+ void InitializeCubeIfNeeded();
+
MojoTimeTicks last_time_;
+ gfx::Size size_;
SpinningCube cube_;
gfx::PointF capture_point_;
gfx::PointF last_drag_point_;
@@ -43,6 +45,7 @@ class GLES2ClientImpl {
bool getting_animation_frames_;
MojoGLES2Context context_;
+ bool context_created_;
MOJO_DISALLOW_COPY_AND_ASSIGN(GLES2ClientImpl);
};
diff --git a/mojo/examples/sample_app/sample_app.cc b/mojo/examples/sample_app/sample_app.cc
index 50d3508..927bc89 100644
--- a/mojo/examples/sample_app/sample_app.cc
+++ b/mojo/examples/sample_app/sample_app.cc
@@ -77,6 +77,7 @@ class SampleApp : public ShellClient {
}
virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE {
+ gles2_client_->SetSize(bounds.size());
}
virtual void OnEvent(const Event& event) MOJO_OVERRIDE {
diff --git a/mojo/gles2/gles2_client_impl.cc b/mojo/gles2/gles2_client_impl.cc
index 6f4e21b..4bca145 100644
--- a/mojo/gles2/gles2_client_impl.cc
+++ b/mojo/gles2/gles2_client_impl.cc
@@ -38,9 +38,7 @@ void GLES2ClientImpl::CancelAnimationFrames() {
service_->CancelAnimationFrames();
}
-void GLES2ClientImpl::DidCreateContext(uint64_t encoded,
- uint32_t width,
- uint32_t height) {
+void GLES2ClientImpl::DidCreateContext(uint64_t encoded) {
// Ack, Hans! It's the giant hack.
// TODO(abarth): Replace this hack with something more disciplined. Most
// likley, we should receive a MojoHandle that we use to wire up the
@@ -48,7 +46,7 @@ void GLES2ClientImpl::DidCreateContext(uint64_t encoded,
// still in-process, we just reinterpret_cast the value into a GL interface.
implementation_ = reinterpret_cast<gpu::gles2::GLES2Implementation*>(
static_cast<uintptr_t>(encoded));
- created_callback_(closure_, width, height);
+ created_callback_(closure_);
}
void GLES2ClientImpl::ContextLost() {
diff --git a/mojo/gles2/gles2_client_impl.h b/mojo/gles2/gles2_client_impl.h
index 7abd0fc..7c5073f7 100644
--- a/mojo/gles2/gles2_client_impl.h
+++ b/mojo/gles2/gles2_client_impl.h
@@ -30,9 +30,7 @@ class GLES2ClientImpl : public GLES2Client, public MojoGLES2ContextPrivate {
void CancelAnimationFrames();
private:
- virtual void DidCreateContext(uint64_t encoded,
- uint32_t width,
- uint32_t height) MOJO_OVERRIDE;
+ virtual void DidCreateContext(uint64_t encoded) MOJO_OVERRIDE;
virtual void ContextLost() MOJO_OVERRIDE;
virtual void DrawAnimationFrame() MOJO_OVERRIDE;
diff --git a/mojo/public/gles2/gles2_types.h b/mojo/public/gles2/gles2_types.h
index 19c579f..b6a9838 100644
--- a/mojo/public/gles2/gles2_types.h
+++ b/mojo/public/gles2/gles2_types.h
@@ -16,11 +16,8 @@ extern "C" {
#endif
typedef struct MojoGLES2ContextPrivate *MojoGLES2Context;
-// TODO(piman):
-// - create context synchronously
-// - pass width/height through native viewport, not here.
-typedef void (*MojoGLES2ContextCreated)(
- void* closure, uint32_t width, uint32_t height);
+// TODO(piman): create context synchronously
+typedef void (*MojoGLES2ContextCreated)(void* closure);
typedef void (*MojoGLES2ContextLost)(void* closure);
typedef void (*MojoGLES2DrawAnimationFrame)(void* closure);
diff --git a/mojo/services/gles2/gles2.mojom b/mojo/services/gles2/gles2.mojom
index 2e78ba3..a27fd53 100644
--- a/mojo/services/gles2/gles2.mojom
+++ b/mojo/services/gles2/gles2.mojom
@@ -13,7 +13,7 @@ interface GLES2 {
[Peer=GLES2]
interface GLES2Client {
- void DidCreateContext(uint64 encoded, uint32 width, uint32 height);
+ void DidCreateContext(uint64 encoded);
void ContextLost();
void DrawAnimationFrame();
};
diff --git a/mojo/services/gles2/gles2_impl.cc b/mojo/services/gles2/gles2_impl.cc
index 6aac1d3..63ed9d7 100644
--- a/mojo/services/gles2/gles2_impl.cc
+++ b/mojo/services/gles2/gles2_impl.cc
@@ -43,7 +43,7 @@ void GLES2Impl::CreateContext(gfx::AcceleratedWidget widget,
gpu::gles2::GLES2Interface* gl = gl_context_->GetImplementation();
uint64_t encoded_gl = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(gl));
- client_->DidCreateContext(encoded_gl, size.width(), size.height());
+ client_->DidCreateContext(encoded_gl);
}
void GLES2Impl::OnGLContextLost() {
diff --git a/mojo/services/native_viewport/native_viewport_mac.mm b/mojo/services/native_viewport/native_viewport_mac.mm
index 651c532..83f1e72 100644
--- a/mojo/services/native_viewport/native_viewport_mac.mm
+++ b/mojo/services/native_viewport/native_viewport_mac.mm
@@ -38,6 +38,7 @@ class NativeViewportMac : public NativeViewport {
backing:NSBackingStoreBuffered
defer:NO];
delegate_->OnAcceleratedWidgetAvailable([window_ contentView]);
+ delegate_->OnBoundsChanged(rect_);
}
virtual void Show() OVERRIDE {
diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc
index ddb46c7..97bc909 100644
--- a/mojo/services/native_viewport/native_viewport_service.cc
+++ b/mojo/services/native_viewport/native_viewport_service.cc
@@ -80,7 +80,7 @@ class NativeViewportService::NativeViewportImpl
if (widget_ == gfx::kNullAcceleratedWidget || !gles2_)
return;
gfx::Size size = native_viewport_->GetSize();
- if (size.width() == 0 || size.height() == 0)
+ if (size.IsEmpty())
return;
gles2_->CreateContext(widget_, size);
created_context_ = true;
@@ -147,6 +147,7 @@ class NativeViewportService::NativeViewportImpl
virtual void OnBoundsChanged(const gfx::Rect& bounds) MOJO_OVERRIDE {
CreateGLES2ContextIfNeeded();
+ AllocationScope allocation;
client_->OnBoundsChanged(bounds);
}
diff --git a/mojo/services/native_viewport/native_viewport_x11.cc b/mojo/services/native_viewport/native_viewport_x11.cc
index 015fcec..7b7e808 100644
--- a/mojo/services/native_viewport/native_viewport_x11.cc
+++ b/mojo/services/native_viewport/native_viewport_x11.cc
@@ -50,6 +50,7 @@ class NativeViewportX11 : public NativeViewport,
base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this);
delegate_->OnAcceleratedWidgetAvailable(window_);
+ delegate_->OnBoundsChanged(bounds_);
}
virtual void Show() OVERRIDE {