| 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..9c803a801e4758be7d1f8c48003e155a2838530c
|
| --- /dev/null
|
| +++ b/mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.cc
|
| @@ -0,0 +1,93 @@
|
| +// 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,
|
| + mojo::gfx::SupportedImagePropertiesPtr supported_properties,
|
| + ImagePipeConsumerDelegate* delegate)
|
| + : state_tracker_(false, [this]() { CloseEndpoint(); }),
|
| + delegate_(delegate),
|
| + supported_properties_dirty_(true),
|
| + supported_properties_callback_pending_(false),
|
| + image_pipe_binding_(this, request.Pass()) {
|
| + image_pipe_binding_.set_connection_error_handler([this]() {
|
| + MOJO_LOG(ERROR) << "Image Pipe Connection Error for Consumer!";
|
| + CloseEndpoint();
|
| + });
|
| +
|
| + supported_properties_ = supported_properties.Pass();
|
| +}
|
| +
|
| +ImagePipeConsumerEndpoint::~ImagePipeConsumerEndpoint() {}
|
| +
|
| +void ImagePipeConsumerEndpoint::ReleaseImage(
|
| + uint32_t id,
|
| + mojo::gfx::PresentationStatus status) {
|
| + state_tracker_.ConsumerRelease(id, status);
|
| +}
|
| +
|
| +void ImagePipeConsumerEndpoint::SetSupportedImageProperties(
|
| + mojo::gfx::SupportedImagePropertiesPtr supported_properties) {
|
| + supported_properties_ = supported_properties.Pass();
|
| + supported_properties_dirty_ = true;
|
| +
|
| + if (supported_properties_callback_pending_) {
|
| + supported_properties_callback_.Run(supported_properties_.Clone());
|
| + supported_properties_callback_pending_ = false;
|
| + supported_properties_dirty_ = false;
|
| + }
|
| +}
|
| +
|
| +// 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();
|
| +}
|
| +
|
| +void ImagePipeConsumerEndpoint::GetSupportedImageProperties(
|
| + const GetSupportedImagePropertiesCallback& callback) {
|
| + if (supported_properties_dirty_) {
|
| + callback.Run(supported_properties_.Clone());
|
| + supported_properties_dirty_ = false;
|
| + } else {
|
| + supported_properties_callback_ = callback;
|
| + supported_properties_callback_pending_ = true;
|
| + }
|
| +}
|
| +
|
| +bool ImagePipeConsumerEndpoint::AcquireNextImage(uint32_t* id) {
|
| + return state_tracker_.AcquireNextImage(id);
|
| +}
|
| +
|
| +void ImagePipeConsumerEndpoint::DisableFatalErrorsForTesting() {
|
| + state_tracker_.DisableFatalErrorsForTesting();
|
| +}
|
| +
|
| +} // namespace image_pipe
|
|
|