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

Unified Diff: examples/surfaces_app/child_gl_impl.cc

Issue 807733002: Split surface id and simplify connecting to surfaces service (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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: 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 cc4d9d1d437447087e0fc12632d8e6a3378330e3..35a27152500dcbc388aa003cba82860cf9128fc5 100644
--- a/examples/surfaces_app/child_gl_impl.cc
+++ b/examples/surfaces_app/child_gl_impl.cc
@@ -49,9 +49,9 @@ ChildGLImpl::ChildGLImpl(ApplicationConnection* surfaces_service_connection,
: start_time_(base::TimeTicks::Now()),
next_resource_id_(1),
weak_factory_(this) {
- surfaces_service_connection->ConnectToService(&surfaces_service_);
- surfaces_service_->CreateSurfaceConnection(base::Bind(
- &ChildGLImpl::SurfaceConnectionCreated, weak_factory_.GetWeakPtr()));
+ 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,
@@ -75,16 +75,14 @@ void ChildGLImpl::ProduceFrame(
cube_.Init(size_.width(), size_.height());
cube_.set_color(
SkColorGetR(color_), SkColorGetG(color_), SkColorGetB(color_));
- produce_callback_ = callback;
- AllocateSurface();
+ id_ = allocator_->GenerateId();
+ surface_->CreateSurface(mojo::SurfaceId::From(id_));
+ callback.Run(SurfaceId::From(id_));
+ Draw();
}
-void ChildGLImpl::SurfaceConnectionCreated(SurfacePtr surface,
- uint32_t id_namespace) {
- surface_ = surface.Pass();
- surface_.set_client(this);
+void ChildGLImpl::SetIdNamespace(uint32_t id_namespace) {
allocator_.reset(new cc::SurfaceIdAllocator(id_namespace));
- AllocateSurface();
}
void ChildGLImpl::ReturnResources(Array<ReturnedResourcePtr> resources) {
@@ -95,16 +93,6 @@ void ChildGLImpl::ReturnResources(Array<ReturnedResourcePtr> resources) {
}
}
-void ChildGLImpl::AllocateSurface() {
- if (produce_callback_.is_null() || !allocator_)
- return;
-
- id_ = allocator_->GenerateId();
- surface_->CreateSurface(mojo::SurfaceId::From(id_), mojo::Size::From(size_));
- produce_callback_.Run(SurfaceId::From(id_));
- Draw();
-}
-
void ChildGLImpl::Draw() {
// First, generate a GL texture and draw the cube into it.
GLuint texture = 0u;

Powered by Google App Engine
This is Rietveld 408576698