OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "image_pipe_consumer_endpoint.h" |
| 6 |
| 7 namespace image_pipe { |
| 8 |
| 9 void ImagePipeConsumerEndpoint::CloseEndpoint() { |
| 10 image_pipe_binding_.Close(); |
| 11 delegate_->HandleEndpointClosed(); |
| 12 } |
| 13 |
| 14 ImagePipeConsumerEndpoint::ImagePipeConsumerEndpoint( |
| 15 mojo::InterfaceRequest<mojo::gfx::ImagePipe> request, |
| 16 mojo::gfx::SupportedImagePropertiesPtr supported_properties, |
| 17 ImagePipeConsumerDelegate* delegate, |
| 18 bool is_checked) |
| 19 : ImagePipeEndpoint(false, is_checked), |
| 20 delegate_(delegate), |
| 21 supported_properties_dirty_(true), |
| 22 supported_properties_callback_pending_(false), |
| 23 image_pipe_binding_(this, request.Pass()) { |
| 24 image_pipe_binding_.set_connection_error_handler([this]() { |
| 25 MOJO_LOG(ERROR) << "Image Pipe Connection Error for Consumer!"; |
| 26 CloseEndpoint(); |
| 27 }); |
| 28 |
| 29 supported_properties_ = supported_properties.Pass(); |
| 30 } |
| 31 |
| 32 ImagePipeConsumerEndpoint::~ImagePipeConsumerEndpoint() {} |
| 33 |
| 34 void ImagePipeConsumerEndpoint::ReleaseImage( |
| 35 uint32_t id, |
| 36 mojo::gfx::PresentationStatus status) { |
| 37 ImagePipeEndpoint::ConsumerRelease(id, status); |
| 38 } |
| 39 |
| 40 void ImagePipeConsumerEndpoint::SetSupportedImageProperties( |
| 41 mojo::gfx::SupportedImagePropertiesPtr supported_properties) { |
| 42 supported_properties_ = supported_properties.Pass(); |
| 43 supported_properties_dirty_ = true; |
| 44 |
| 45 // this should be conditional on whether |
| 46 if (supported_properties_callback_pending_) { |
| 47 supported_properties_callback_.Run(supported_properties_.Clone()); |
| 48 supported_properties_callback_pending_ = false; |
| 49 supported_properties_dirty_ = false; |
| 50 } |
| 51 } |
| 52 |
| 53 /* mojo::gfx::ImagePipe implementation */ |
| 54 void ImagePipeConsumerEndpoint::AddImage(mojo::gfx::ImagePtr image, |
| 55 uint32_t id) { |
| 56 ImagePipeEndpoint::ProducerAdd(id); |
| 57 delegate_->AddImage(image.Pass(), id); |
| 58 } |
| 59 |
| 60 void ImagePipeConsumerEndpoint::RemoveImage(uint32_t id) { |
| 61 ImagePipeEndpoint::ProducerRemove(id); |
| 62 delegate_->RemoveImage(id); |
| 63 } |
| 64 |
| 65 void ImagePipeConsumerEndpoint::PresentImage( |
| 66 uint32_t id, |
| 67 const PresentImageCallback& callback) { |
| 68 ImagePipeEndpoint::ProducerPresent(id, callback); |
| 69 delegate_->PresentImage(id); |
| 70 } |
| 71 |
| 72 void ImagePipeConsumerEndpoint::FlushImages() { |
| 73 ImagePipeEndpoint::ProducerFlush(); |
| 74 } |
| 75 |
| 76 void ImagePipeConsumerEndpoint::GetSupportedImageProperties( |
| 77 const GetSupportedImagePropertiesCallback& callback) { |
| 78 if (supported_properties_dirty_) { |
| 79 callback.Run(supported_properties_.Clone()); |
| 80 supported_properties_dirty_ = false; |
| 81 } else { |
| 82 supported_properties_callback_ = callback; |
| 83 supported_properties_callback_pending_ = true; |
| 84 } |
| 85 } |
| 86 |
| 87 bool ImagePipeConsumerEndpoint::AcquireNextImage(uint32_t& id) { |
| 88 return ImagePipeEndpoint::AcquireNextImage(id); |
| 89 } |
| 90 |
| 91 } // namespace image_pipe |
OLD | NEW |