Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.h

Issue 1595773002: Added ImagePipe (Closed) Base URL: https://github.com/domokit/mojo.git@submit-2
Patch Set: rebased. the ImagePipe interface doesnt pass interfaces anyway so it didnt really change anything Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
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
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);
jeffbrown 2016/03/03 23:27:49 out_id
Forrest Reiling 2016/03/04 21:04:28 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 if and only if the message pipe underlying the image pipe has
46 // enountered 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 DisableFatalErrorsForTesting();
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_tracker_;
66 mojo::gfx::ImagePipePtr image_pipe_ptr_;
67 std::function<void()> endpoint_closed_callback_;
68 };
69
70 } // namespace image_pipe
71
72 #endif // MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_PRODUCER_ENDPOINT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698