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

Unified Diff: mojo/services/surfaces/surfaces_impl.cc

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 9 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 | « mojo/services/surfaces/surfaces_impl.h ('k') | mojo/services/surfaces/surfaces_output_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/surfaces/surfaces_impl.cc
diff --git a/mojo/services/surfaces/surfaces_impl.cc b/mojo/services/surfaces/surfaces_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..577b6c1c4126b3362ae189c82d1b267d445d5065
--- /dev/null
+++ b/mojo/services/surfaces/surfaces_impl.cc
@@ -0,0 +1,81 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/services/surfaces/surfaces_impl.h"
+
+#include "base/trace_event/trace_event.h"
+#include "cc/output/compositor_frame.h"
+#include "cc/resources/returned_resource.h"
+#include "cc/surfaces/surface_id_allocator.h"
+#include "mojo/converters/geometry/geometry_type_converters.h"
+#include "mojo/converters/surfaces/surfaces_type_converters.h"
+#include "mojo/services/surfaces/surfaces_scheduler.h"
+
+using mojo::SurfaceIdPtr;
+
+namespace surfaces {
+
+namespace {
+void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) {
+ callback.Run();
+}
+}
+
+SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager,
+ uint32_t id_namespace,
+ SurfacesScheduler* scheduler,
+ mojo::InterfaceRequest<mojo::Surface> request)
+ : manager_(manager),
+ factory_(manager, this),
+ id_namespace_(id_namespace),
+ scheduler_(scheduler),
+ binding_(this, request.Pass()) {
+}
+
+SurfacesImpl::~SurfacesImpl() {
+ factory_.DestroyAll();
+}
+
+void SurfacesImpl::GetIdNamespace(
+ const Surface::GetIdNamespaceCallback& callback) {
+ callback.Run(id_namespace_);
+}
+
+void SurfacesImpl::SetResourceReturner(mojo::ResourceReturnerPtr returner) {
+ returner_ = returner.Pass();
+}
+
+void SurfacesImpl::CreateSurface(uint32_t local_id) {
+ factory_.Create(QualifyIdentifier(local_id));
+}
+
+void SurfacesImpl::SubmitFrame(uint32_t local_id,
+ mojo::FramePtr frame,
+ const mojo::Closure& callback) {
+ TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame");
+ factory_.SubmitFrame(QualifyIdentifier(local_id),
+ frame.To<scoped_ptr<cc::CompositorFrame>>(),
+ base::Bind(&CallCallback, callback));
+ scheduler_->SetNeedsDraw();
+}
+
+void SurfacesImpl::DestroySurface(uint32_t local_id) {
+ factory_.Destroy(QualifyIdentifier(local_id));
+}
+
+void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) {
+ if (resources.empty() || !returner_)
+ return;
+ mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size());
+ for (size_t i = 0; i < resources.size(); ++i) {
+ ret[i] = mojo::ReturnedResource::From(resources[i]);
+ }
+ returner_->ReturnResources(ret.Pass());
+}
+
+cc::SurfaceId SurfacesImpl::QualifyIdentifier(uint32_t local_id) {
+ return cc::SurfaceId(static_cast<uint64_t>(id_namespace_) << 32 | local_id);
+}
+
+} // namespace mojo
« no previous file with comments | « mojo/services/surfaces/surfaces_impl.h ('k') | mojo/services/surfaces/surfaces_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698