OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #ifndef MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_CONSUMER_ENDPOINT_H_ |
| 5 #define MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_CONSUMER_ENDPOINT_H_ |
| 6 |
| 7 #include "image_pipe_endpoint.h" |
| 8 #include "mojo/public/c/system/macros.h" |
| 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 10 #include "mojo/services/gfx/images/cpp/image_pipe_consumer_delegate.h" |
| 11 #include "mojo/services/gfx/images/interfaces/image_pipe.mojom.h" |
| 12 |
| 13 namespace image_pipe { |
| 14 |
| 15 // |ImagePipeConsumerEndpoint| is a state tracking wrapper for the consumer end |
| 16 // of an |ImagePipe| that enforces the constraints documented in the mojom |
| 17 // interface. Using |ImagePipeConsumerEndpoint| is not required to use |
| 18 // |ImagePipe|, but it may help you use it correctly |
| 19 class ImagePipeConsumerEndpoint : private mojo::gfx::ImagePipe { |
| 20 public: |
| 21 ImagePipeConsumerEndpoint( |
| 22 mojo::InterfaceRequest<mojo::gfx::ImagePipe> request, |
| 23 ImagePipeConsumerDelegate* delegate); |
| 24 ~ImagePipeConsumerEndpoint() override; |
| 25 |
| 26 // Aquire the Image presented least recently (queue like behavior). If no |
| 27 // images are available that match the selection criteria this function will |
| 28 // return false otherwise it will write the selected id into its id argument |
| 29 // and return true. |
| 30 bool AcquireNextImage(uint32_t* out_id); |
| 31 |
| 32 // Releases an image back to the producer. |
| 33 void ReleaseImage(uint32_t id, mojo::gfx::PresentationStatus status); |
| 34 |
| 35 // For testing only, makes fatal errors not quite fatal, which allows tests |
| 36 // to cause a fatal error and check that it was caught correctly without |
| 37 // dying a horrible death in the process. If you are using this for something |
| 38 // other than testing you are probably doing something very wrong. |
| 39 void DisableFatalErrorsForTesting(); |
| 40 |
| 41 private: |
| 42 void CloseEndpoint(); |
| 43 |
| 44 // Inherited from mojo::gfx::ImagePipe, see image_pipe.mojom for comments |
| 45 void AddImage(mojo::gfx::ImagePtr image, uint32_t id) override; |
| 46 void RemoveImage(uint32_t id) override; |
| 47 void PresentImage(uint32_t id, const PresentImageCallback& callback) override; |
| 48 void FlushImages() override; |
| 49 |
| 50 ImagePipeEndpoint state_tracker_; |
| 51 ImagePipeConsumerDelegate* delegate_; |
| 52 |
| 53 mojo::Binding<mojo::gfx::ImagePipe> image_pipe_binding_; |
| 54 |
| 55 MOJO_DISALLOW_COPY_AND_ASSIGN(ImagePipeConsumerEndpoint); |
| 56 }; |
| 57 |
| 58 } // namespace image_pipe |
| 59 |
| 60 #endif // MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_CONSUMER_ENDPOINT_H_ |
OLD | NEW |