Index: examples/surfaces_app/child_gl_impl.cc |
diff --git a/examples/surfaces_app/child_gl_impl.cc b/examples/surfaces_app/child_gl_impl.cc |
index 35a27152500dcbc388aa003cba82860cf9128fc5..3e429b3df516ba0286ba51eea6b4a9c41a77b18e 100644 |
--- a/examples/surfaces_app/child_gl_impl.cc |
+++ b/examples/surfaces_app/child_gl_impl.cc |
@@ -46,12 +46,9 @@ static void ContextLostThunk(void*) { |
ChildGLImpl::ChildGLImpl(ApplicationConnection* surfaces_service_connection, |
CommandBufferPtr command_buffer) |
- : start_time_(base::TimeTicks::Now()), |
- next_resource_id_(1), |
- weak_factory_(this) { |
+ : local_id_(1u), start_time_(base::TimeTicks::Now()), next_resource_id_(1) { |
sky
2015/01/13 18:14:27
Member initialize id_namespace_ too.
jamesr
2015/01/14 01:50:29
Done.
|
surfaces_service_connection->ConnectToService(&surface_); |
surface_.set_client(this); |
- surface_.WaitForIncomingMethodCall(); // Wait for ID namespace to arrive. |
context_ = |
MojoGLES2CreateContext(command_buffer.PassMessagePipe().release().value(), |
&ContextLostThunk, |
@@ -63,26 +60,36 @@ ChildGLImpl::ChildGLImpl(ApplicationConnection* surfaces_service_connection, |
ChildGLImpl::~ChildGLImpl() { |
MojoGLES2DestroyContext(context_); |
- surface_->DestroySurface(mojo::SurfaceId::From(id_)); |
+ surface_->DestroySurface(local_id_); |
} |
-void ChildGLImpl::ProduceFrame( |
- ColorPtr color, |
- SizePtr size, |
- const mojo::Callback<void(SurfaceIdPtr id)>& callback) { |
+void ChildGLImpl::ProduceFrame(ColorPtr color, |
+ SizePtr size, |
+ const ProduceCallback& callback) { |
color_ = color.To<SkColor>(); |
size_ = size.To<gfx::Size>(); |
cube_.Init(size_.width(), size_.height()); |
cube_.set_color( |
SkColorGetR(color_), SkColorGetG(color_), SkColorGetB(color_)); |
- id_ = allocator_->GenerateId(); |
- surface_->CreateSurface(mojo::SurfaceId::From(id_)); |
- callback.Run(SurfaceId::From(id_)); |
+ surface_->CreateSurface(local_id_); |
+ produce_callback_ = callback; |
+ if (id_namespace_ != 0u) |
+ RunProduceCallback(); |
Draw(); |
} |
void ChildGLImpl::SetIdNamespace(uint32_t id_namespace) { |
- allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); |
+ id_namespace_ = id_namespace; |
+ if (!produce_callback_.is_null()) |
+ RunProduceCallback(); |
+ produce_callback_.reset(); |
+} |
+ |
+void ChildGLImpl::RunProduceCallback() { |
+ auto id = SurfaceId::New(); |
+ id->id_namespace = id_namespace_; |
+ id->local = local_id_; |
+ produce_callback_.Run(id.Pass()); |
} |
void ChildGLImpl::ReturnResources(Array<ReturnedResourcePtr> resources) { |
@@ -169,8 +176,7 @@ void ChildGLImpl::Draw() { |
scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
frame->delegated_frame_data = delegated_frame_data.Pass(); |
- surface_->SubmitFrame(mojo::SurfaceId::From(id_), mojo::Frame::From(*frame), |
- mojo::Closure()); |
+ surface_->SubmitFrame(local_id_, mojo::Frame::From(*frame), mojo::Closure()); |
base::MessageLoop::current()->PostDelayedTask( |
FROM_HERE, |