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 : state_tacker_(false, [this]() { CloseEndpoint(); }), | |
19 delegate_(delegate), | |
20 supported_properties_dirty_(true), | |
21 supported_properties_callback_pending_(false), | |
22 image_pipe_binding_(this, request.Pass()) { | |
23 image_pipe_binding_.set_connection_error_handler([this]() { | |
24 MOJO_LOG(ERROR) << "Image Pipe Connection Error for Consumer!"; | |
25 CloseEndpoint(); | |
26 }); | |
27 | |
28 supported_properties_ = supported_properties.Pass(); | |
29 } | |
30 | |
31 ImagePipeConsumerEndpoint::~ImagePipeConsumerEndpoint() {} | |
32 | |
33 void ImagePipeConsumerEndpoint::ReleaseImage( | |
34 uint32_t id, | |
35 mojo::gfx::PresentationStatus status) { | |
36 state_tacker_.ConsumerRelease(id, status); | |
37 } | |
38 | |
39 void ImagePipeConsumerEndpoint::SetSupportedImageProperties( | |
40 mojo::gfx::SupportedImagePropertiesPtr supported_properties) { | |
41 supported_properties_ = supported_properties.Pass(); | |
42 supported_properties_dirty_ = true; | |
43 | |
44 // this should be conditional on whether | |
45 if (supported_properties_callback_pending_) { | |
46 supported_properties_callback_.Run(supported_properties_.Clone()); | |
47 supported_properties_callback_pending_ = false; | |
48 supported_properties_dirty_ = false; | |
49 } | |
50 } | |
51 | |
52 /* mojo::gfx::ImagePipe implementation */ | |
jamesr
2016/02/18 20:40:58
prefer // style comments
Forrest Reiling
2016/02/25 00:35:14
Done.
| |
53 void ImagePipeConsumerEndpoint::AddImage(mojo::gfx::ImagePtr image, | |
54 uint32_t id) { | |
55 state_tacker_.ProducerAdd(id); | |
56 delegate_->AddImage(image.Pass(), id); | |
57 } | |
58 | |
59 void ImagePipeConsumerEndpoint::RemoveImage(uint32_t id) { | |
60 state_tacker_.ProducerRemove(id); | |
61 delegate_->RemoveImage(id); | |
62 } | |
63 | |
64 void ImagePipeConsumerEndpoint::PresentImage( | |
65 uint32_t id, | |
66 const PresentImageCallback& callback) { | |
67 state_tacker_.ProducerPresent(id, callback); | |
68 delegate_->PresentImage(id); | |
69 } | |
70 | |
71 void ImagePipeConsumerEndpoint::FlushImages() { | |
72 state_tacker_.ProducerFlush(); | |
73 } | |
74 | |
75 void ImagePipeConsumerEndpoint::GetSupportedImageProperties( | |
76 const GetSupportedImagePropertiesCallback& callback) { | |
77 if (supported_properties_dirty_) { | |
78 callback.Run(supported_properties_.Clone()); | |
79 supported_properties_dirty_ = false; | |
80 } else { | |
81 supported_properties_callback_ = callback; | |
82 supported_properties_callback_pending_ = true; | |
83 } | |
84 } | |
85 | |
86 bool ImagePipeConsumerEndpoint::AcquireNextImage(uint32_t& id) { | |
87 return state_tacker_.AcquireNextImage(id); | |
88 } | |
89 | |
90 void ImagePipeConsumerEndpoint::DisableFatalErrors() { | |
91 state_tacker_.DisableFatalErrors(); | |
92 } | |
93 | |
94 } // namespace image_pipe | |
OLD | NEW |