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

Unified Diff: mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.cc

Issue 1595773002: Added ImagePipe (Closed) Base URL: https://github.com/domokit/mojo.git@submit-2
Patch Set: rebased Created 4 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
Index: mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.cc
diff --git a/mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.cc b/mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0516ea4afa5181a5f77fadba64318227730086e8
--- /dev/null
+++ b/mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.cc
@@ -0,0 +1,65 @@
+// Copyright 2016 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 "image_pipe_consumer_endpoint.h"
+
+namespace image_pipe {
+
+void ImagePipeConsumerEndpoint::CloseEndpoint() {
+ image_pipe_binding_.Close();
+ delegate_->HandleEndpointClosed();
+}
+
+ImagePipeConsumerEndpoint::ImagePipeConsumerEndpoint(
+ mojo::InterfaceRequest<mojo::gfx::ImagePipe> request,
+ ImagePipeConsumerDelegate* delegate)
+ : state_tracker_(false, [this]() { CloseEndpoint(); }),
+ delegate_(delegate),
+ image_pipe_binding_(this, request.Pass()) {
+ image_pipe_binding_.set_connection_error_handler([this]() {
+ MOJO_LOG(ERROR) << "Image Pipe Connection Error for Consumer!";
+ CloseEndpoint();
+ });
+}
+
+ImagePipeConsumerEndpoint::~ImagePipeConsumerEndpoint() {}
+
+void ImagePipeConsumerEndpoint::ReleaseImage(
+ uint32_t id,
+ mojo::gfx::PresentationStatus status) {
+ state_tracker_.ConsumerRelease(id, status);
+}
+
+// mojo::gfx::ImagePipe implementation
+void ImagePipeConsumerEndpoint::AddImage(mojo::gfx::ImagePtr image,
+ uint32_t id) {
+ state_tracker_.ProducerAdd(id);
+ delegate_->AddImage(image.Pass(), id);
+}
+
+void ImagePipeConsumerEndpoint::RemoveImage(uint32_t id) {
+ state_tracker_.ProducerRemove(id);
+ delegate_->RemoveImage(id);
+}
+
+void ImagePipeConsumerEndpoint::PresentImage(
+ uint32_t id,
+ const PresentImageCallback& callback) {
+ state_tracker_.ProducerPresent(id, callback);
+ delegate_->PresentImage(id);
+}
+
+void ImagePipeConsumerEndpoint::FlushImages() {
+ state_tracker_.ProducerFlush();
+}
+
+bool ImagePipeConsumerEndpoint::AcquireNextImage(uint32_t* out_id) {
+ return state_tracker_.AcquireNextImage(out_id);
+}
+
+void ImagePipeConsumerEndpoint::DisableFatalErrorsForTesting() {
+ state_tracker_.DisableFatalErrorsForTesting();
+}
+
+} // namespace image_pipe
« no previous file with comments | « mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.h ('k') | mojo/services/gfx/images/cpp/image_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698