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

Unified Diff: examples/surfaces_app/child_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
Index: examples/surfaces_app/child_impl.cc
diff --git a/examples/surfaces_app/child_impl.cc b/examples/surfaces_app/child_impl.cc
index cd0cf481364ecf1d37397cf99ffffbb4766389f4..de5279eaf77a14c6c11f5b418cd2a906670b3a63 100644
--- a/examples/surfaces_app/child_impl.cc
+++ b/examples/surfaces_app/child_impl.cc
@@ -28,19 +28,22 @@ using cc::SolidColorDrawQuad;
using cc::DelegatedFrameData;
using cc::CompositorFrame;
-ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) {
+static const uint32_t kLocalId = 1u;
+
+ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection)
+ : id_namespace_(0u) {
surfaces_service_connection->ConnectToService(&surface_);
surface_.set_client(this);
surface_.WaitForIncomingMethodCall(); // Wait for ID namespace to arrive.
+ DCHECK_NE(0u, id_namespace_);
}
ChildImpl::~ChildImpl() {
- if (surface_)
- surface_->DestroySurface(mojo::SurfaceId::From(id_));
+ surface_->DestroySurface(kLocalId);
}
void ChildImpl::SetIdNamespace(uint32_t id_namespace) {
- allocator_.reset(new cc::SurfaceIdAllocator(id_namespace));
+ id_namespace_ = id_namespace;
}
void ChildImpl::ReturnResources(
@@ -48,12 +51,9 @@ void ChildImpl::ReturnResources(
DCHECK(!resources.size());
}
-void ChildImpl::ProduceFrame(
- ColorPtr color,
- SizePtr size_ptr,
- const mojo::Callback<void(SurfaceIdPtr id)>& callback) {
- id_ = allocator_->GenerateId();
- surface_->CreateSurface(mojo::SurfaceId::From(id_));
+void ChildImpl::ProduceFrame(ColorPtr color,
+ SizePtr size_ptr,
+ const ProduceCallback& callback) {
gfx::Size size = size_ptr.To<gfx::Size>();
gfx::Rect rect(size);
RenderPassId id(1, 1);
@@ -65,11 +65,8 @@ void ChildImpl::ProduceFrame(
SolidColorDrawQuad* color_quad =
pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
bool force_anti_aliasing_off = false;
- color_quad->SetNew(pass->shared_quad_state_list.back(),
- rect,
- rect,
- color.To<SkColor>(),
- force_anti_aliasing_off);
+ color_quad->SetNew(pass->shared_quad_state_list.back(), rect, rect,
+ color.To<SkColor>(), force_anti_aliasing_off);
scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData);
delegated_frame_data->render_pass_list.push_back(pass.Pass());
@@ -77,9 +74,12 @@ void ChildImpl::ProduceFrame(
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());
- callback.Run(SurfaceId::From(id_));
+ surface_->CreateSurface(kLocalId);
sky 2015/01/13 18:14:27 I'm not familiar with this class. Is ProduceFrame
jamesr 2015/01/14 01:50:29 That's right - this app produces exactly one frame
+ surface_->SubmitFrame(kLocalId, mojo::Frame::From(*frame), mojo::Closure());
+ auto qualified_id = mojo::SurfaceId::New();
+ qualified_id->id_namespace = id_namespace_;
+ qualified_id->local = kLocalId;
+ callback.Run(qualified_id.Pass());
}
} // namespace examples

Powered by Google App Engine
This is Rietveld 408576698