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 : private ImagePipeEndpoint, | |
|
jamesr
2016/02/09 21:07:20
i strongly recommend against using implementation
Forrest Reiling
2016/02/10 20:38:42
Acknowledged.
| |
| 21 public mojo::gfx::ImagePipe { | |
| 22 public: | |
| 23 ImagePipeProducerEndpoint(mojo::gfx::ImagePipePtr image_pipe, | |
| 24 std::function<void()> endpoint_closed_callback, | |
| 25 bool is_checked = true); | |
|
jamesr
2016/02/09 21:07:20
default parameters are discouraged (to sometimes b
Forrest Reiling
2016/02/10 20:38:42
The checked parameter exists solely for testing pu
| |
| 26 | |
| 27 ~ImagePipeProducerEndpoint() override; | |
| 28 | |
| 29 // ask the endpoint for an available image to draw into | |
| 30 // returns false if no images are available, otherwise returns true and | |
| 31 // sets |id| to the acquired ID. If |blocking| is true, this function will | |
| 32 // block until an Image is available. If |blocking| is true, but there are no | |
| 33 // images in the pool or the underlying message pipe has errors then false | |
| 34 // will be returned | |
| 35 bool AcquireImage(uint32_t& id, bool blocking = false); | |
|
jamesr
2016/02/09 21:07:20
bool param here is bad - it's really hard to tell
Forrest Reiling
2016/02/10 20:38:42
Acknowledged.
| |
| 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 void CloseEndpoint() override; | |
| 46 | |
| 47 private: | |
| 48 // This exists wrap ImagePipeEndpoint::ConsumerRelease because for some reason | |
| 49 // GCC doesnt like us calling protected methods on our base class from inside | |
| 50 // a lambda that captures 'this', which breaks the fnl build. Clang handles it | |
| 51 // fine, but its unclear whos right here, so we trampoline it as a workaround | |
| 52 void ConsumerReleaseInternal(uint32_t id, | |
| 53 mojo::gfx::PresentationStatus status); | |
| 54 mojo::gfx::ImagePipePtr image_pipe_ptr_; | |
| 55 std::function<void()> endpoint_closed_callback_; | |
| 56 }; | |
| 57 } | |
| 58 | |
| 59 #endif // MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_PRODUCER_ENDPOINT_H_ | |
| OLD | NEW |