| 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..69c5decef6bd6ffae793c655749acfa45a40d5b9
|
| --- /dev/null
|
| +++ b/mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.cc
|
| @@ -0,0 +1,91 @@
|
| +// 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_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,
|
| + bool is_checked)
|
| + : ImagePipeEndpoint(false, is_checked),
|
| + 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) {
|
| + ImagePipeEndpoint::ConsumerRelease(id, status);
|
| +}
|
| +
|
| +void ImagePipeConsumerEndpoint::SetSupportedImageProperties(
|
| + mojo::gfx::SupportedImagePropertiesPtr supported_properties) {
|
| + supported_properties_ = supported_properties.Pass();
|
| + supported_properties_dirty_ = true;
|
| +
|
| + // this should be conditional on whether
|
| + 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) {
|
| + ImagePipeEndpoint::ProducerAdd(id);
|
| + delegate_->AddImage(image.Pass(), id);
|
| +}
|
| +
|
| +void ImagePipeConsumerEndpoint::RemoveImage(uint32_t id) {
|
| + ImagePipeEndpoint::ProducerRemove(id);
|
| + delegate_->RemoveImage(id);
|
| +}
|
| +
|
| +void ImagePipeConsumerEndpoint::PresentImage(
|
| + uint32_t id,
|
| + const PresentImageCallback& callback) {
|
| + ImagePipeEndpoint::ProducerPresent(id, callback);
|
| + delegate_->PresentImage(id);
|
| +}
|
| +
|
| +void ImagePipeConsumerEndpoint::FlushImages() {
|
| + ImagePipeEndpoint::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 ImagePipeEndpoint::AcquireNextImage(id);
|
| +}
|
| +
|
| +} // namespace image_pipe
|
|
|