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

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

Issue 1595773002: Added ImagePipe (Closed) Base URL: https://github.com/domokit/mojo.git@submit-2
Patch Set: minor changes to make it build with GCC on fnl Created 4 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: mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.cc
diff --git a/mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.cc b/mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b299c6f0a85729138e4490d4e2b0ccc941c4b9ad
--- /dev/null
+++ b/mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.cc
@@ -0,0 +1,77 @@
+// Copyright 2015 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_producer_endpoint.h"
+
+namespace image_pipe {
+
+void ImagePipeProducerEndpoint::CloseEndpoint() {
+ image_pipe_ptr_.reset();
+ endpoint_closed_callback_();
+}
+
+ImagePipeProducerEndpoint::ImagePipeProducerEndpoint(
+ mojo::gfx::ImagePipePtr image_pipe,
+ std::function<void()> endpoint_closed_callback,
+ bool is_checked)
+ : ImagePipeEndpoint(true, is_checked), image_pipe_ptr_(image_pipe.Pass()) {
+ endpoint_closed_callback_ = endpoint_closed_callback;
+ image_pipe_ptr_.set_connection_error_handler([this] { CloseEndpoint(); });
+}
+
+ImagePipeProducerEndpoint::~ImagePipeProducerEndpoint() {}
+
+bool ImagePipeProducerEndpoint::AcquireImage(uint32_t& id, bool blocking) {
+ bool have_image = false;
+ do {
+ have_image = ImagePipeEndpoint::AcquireNextImage(id);
+ if (blocking && !have_image) {
+ if (image_pipe_ptr_.encountered_error())
+ break;
+ image_pipe_ptr_.WaitForIncomingResponse();
+ if (image_pipe_ptr_.encountered_error())
+ break;
+ }
+ } while (blocking && !have_image);
+
+ return have_image;
+}
+
+void ImagePipeProducerEndpoint::AddImage(mojo::gfx::ImagePtr image,
+ uint32_t id) {
+ ImagePipeEndpoint::ProducerAdd(id);
+ image_pipe_ptr_->AddImage(image.Pass(), id);
+}
+
+void ImagePipeProducerEndpoint::RemoveImage(uint32_t id) {
+ ImagePipeEndpoint::ProducerRemove(id);
+ image_pipe_ptr_->RemoveImage(id);
+}
+
+void ImagePipeProducerEndpoint::ConsumerReleaseInternal(
+ uint32_t id,
+ mojo::gfx::PresentationStatus status) {
+ ImagePipeEndpoint::ConsumerRelease(id, status);
+}
+
+void ImagePipeProducerEndpoint::PresentImage(
+ uint32_t id,
+ const PresentImageCallback& callback) {
+ ImagePipeEndpoint::ProducerPresent(id, callback);
+ image_pipe_ptr_->PresentImage(
+ id, [this](uint32_t id, mojo::gfx::PresentationStatus status) {
+ ConsumerReleaseInternal(id, status);
+ });
+}
+
+void ImagePipeProducerEndpoint::FlushImages() {
+ ImagePipeEndpoint::ProducerFlush();
+ image_pipe_ptr_->FlushImages();
+}
+
+void ImagePipeProducerEndpoint::GetSupportedImageProperties(
+ const GetSupportedImagePropertiesCallback& callback) {
+ image_pipe_ptr_->GetSupportedImageProperties(callback);
+}
+}

Powered by Google App Engine
This is Rietveld 408576698