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

Unified Diff: examples/surfaces_app/child_gl_impl.cc

Issue 826423008: Use local ids for Surfaces APIs that can only apply to local surfaces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 | « examples/surfaces_app/child_gl_impl.h ('k') | examples/surfaces_app/child_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fd27ca6c53831b95d0f165647b175926170cb7e1 100644
--- a/examples/surfaces_app/child_gl_impl.cc
+++ b/examples/surfaces_app/child_gl_impl.cc
@@ -46,12 +46,12 @@ 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) {
+ : id_namespace_(0u),
+ local_id_(1u),
+ start_time_(base::TimeTicks::Now()),
+ next_resource_id_(1) {
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 +63,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 +179,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,
« no previous file with comments | « examples/surfaces_app/child_gl_impl.h ('k') | examples/surfaces_app/child_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698