Chromium Code Reviews| 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 #ifndef MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_PRODUCER_ENDPOINT_H_ | |
| 6 #define MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_PRODUCER_ENDPOINT_H_ | |
| 7 | |
| 8 #include "image_pipe_endpoint.h" | |
| 9 #include "mojo/public/c/system/macros.h" | |
| 10 #include "mojo/services/gfx/images/interfaces/image_pipe.mojom.h" | |
| 11 | |
| 12 namespace image_pipe { | |
| 13 | |
| 14 // This class wraps the producer end of an ImagePipe and validates the sanity | |
| 15 // of both the producer actions and the consumer actions coming over the | |
| 16 // message pipe. It also tracks the state of Images in the pipe's image pool | |
| 17 // and provides conviennce mechanisms for accessing this state (like the ability | |
| 18 // to get the ID of an available image without having to manually track the | |
| 19 // lifecycle of these images. | |
| 20 class ImagePipeProducerEndpoint : public mojo::gfx::ImagePipe { | |
| 21 public: | |
| 22 ImagePipeProducerEndpoint(mojo::gfx::ImagePipePtr image_pipe, | |
| 23 std::function<void()> endpoint_closed_callback); | |
| 24 | |
| 25 ~ImagePipeProducerEndpoint() override; | |
| 26 | |
| 27 // ask the endpoint for an available image to draw into | |
|
jamesr
2016/02/18 20:40:59
capitalize
Forrest Reiling
2016/02/25 00:35:14
Done.
| |
| 28 // returns false if no images are available, otherwise returns true and | |
| 29 // sets |id| to the acquired ID. | |
| 30 bool AcquireImage(uint32_t& id); | |
|
jamesr
2016/02/18 20:40:59
pointer for out-param
Forrest Reiling
2016/02/25 00:35:15
Done.
| |
| 31 | |
| 32 // The blocking version of the above function. This function will block until | |
| 33 // an Image is available or the deadline is met. If there are no images in the | |
| 34 // pool or the underlying message pipe has errors then false will be returned | |
| 35 bool AcquireImageBlocking(uint32_t& id, MojoDeadline deadline); | |
| 36 | |
| 37 // Inherited from mojo::gfx::ImagePipe, see image_pipe.mojom for comments | |
| 38 void AddImage(mojo::gfx::ImagePtr image, uint32_t id) override; | |
| 39 void RemoveImage(uint32_t id) override; | |
| 40 void PresentImage(uint32_t id, const PresentImageCallback& callback) override; | |
| 41 void FlushImages() override; | |
| 42 void GetSupportedImageProperties( | |
| 43 const GetSupportedImagePropertiesCallback& callback) override; | |
| 44 | |
| 45 // returns true iff the message pipe underlying the image pipe has enountered | |
|
jamesr
2016/02/18 20:40:59
we don't normally say "iff" even when we mean it
Forrest Reiling
2016/02/25 00:35:15
Sure. For the record though I'm pretty sure if you
| |
| 46 // errors or closed | |
| 47 bool HasEncounteredError(); | |
| 48 | |
| 49 // For testing only, makes fatal errors not quite fatal, which allows tests | |
| 50 // to cause a fatal error and check that it was caught correctly without | |
| 51 // dying a horrible death in the process. If you are using this for something | |
| 52 // other than testing you are probably doing something very wrong. | |
| 53 void DisableFatalErrors(); | |
| 54 | |
| 55 private: | |
| 56 void CloseEndpoint(); | |
| 57 | |
| 58 // This exists wrap ImagePipeEndpoint::ConsumerRelease because for some reason | |
| 59 // GCC doesnt like us calling protected methods on our base class from inside | |
| 60 // a lambda that captures 'this', which breaks the fnl build. Clang handles it | |
| 61 // fine, but its unclear whos right here, so we trampoline it as a workaround | |
| 62 void ConsumerReleaseInternal(uint32_t id, | |
| 63 mojo::gfx::PresentationStatus status); | |
| 64 | |
| 65 ImagePipeEndpoint state_tacker_; | |
|
jamesr
2016/02/18 20:40:59
tacker -> tracker? or is this something else? i'm
Forrest Reiling
2016/02/25 00:35:15
'tacker' is typo-copy-pasta cancer. Fixed
| |
| 66 mojo::gfx::ImagePipePtr image_pipe_ptr_; | |
| 67 std::function<void()> endpoint_closed_callback_; | |
| 68 }; | |
| 69 } | |
|
jamesr
2016/02/18 20:40:59
newline, comment
Forrest Reiling
2016/02/25 00:35:14
Done.
| |
| 70 | |
| 71 #endif // MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_PRODUCER_ENDPOINT_H_ | |
| OLD | NEW |