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_CPP_IMAGE_PIPE_ENDPOINT_H_ | |
6 #define MOJO_SERVICES_GFX_IMAGES_CPP_IMAGE_PIPE_ENDPOINT_H_ | |
7 | |
8 #include <deque> | |
9 #include <map> | |
10 #include <vector> | |
11 | |
12 #include "mojo/public/c/system/macros.h" | |
13 #include "mojo/services/gfx/images/interfaces/image_pipe.mojom.h" | |
14 | |
15 namespace image_pipe { | |
16 | |
17 class ImagePipeEndpoint { | |
18 public: | |
19 ImagePipeEndpoint(bool is_producer, | |
20 std::function<void()> fatal_error_handler); | |
21 virtual ~ImagePipeEndpoint(); | |
22 | |
23 void ProducerFatalError(const char* message, uint32_t id); | |
jamesr
2016/02/18 20:40:59
why const char*? it's very rare in c++ code to rea
Forrest Reiling
2016/02/25 00:35:14
Done.
| |
24 void ConsumerFatalError(const char* message, uint32_t id); | |
25 | |
26 bool AcquireNextImage(uint32_t& id); | |
jamesr
2016/02/18 20:40:59
ditto re non-const ref param
Forrest Reiling
2016/02/25 00:35:14
Done.
| |
27 | |
28 void ProducerAdd(uint32_t id); | |
29 void ProducerRemove(uint32_t id); | |
30 void ProducerPresent(uint32_t id, | |
31 mojo::gfx::ImagePipe::PresentImageCallback callback); | |
32 void ConsumerRelease(uint32_t id, mojo::gfx::PresentationStatus status); | |
33 void ProducerFlush(); | |
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 DisableFatalErrors(); | |
jamesr
2016/02/18 20:40:59
make "for testing" part of the function name - you
Forrest Reiling
2016/02/25 00:35:14
Done.
| |
40 | |
41 private: | |
42 bool IsInPool(uint32_t id) const; | |
43 bool IsConsumerOwned(uint32_t id) const; | |
44 bool IsConsumerAcquirable(uint32_t id) const; | |
45 bool IsProducerOwned(uint32_t id) const; | |
46 bool IsProducerAcquirable(uint32_t id) const; | |
47 void CallPresentCallback(uint32_t id, mojo::gfx::PresentationStatus status); | |
48 void ReleaseInternal(uint32_t id, bool released_by_producer); | |
49 | |
50 static void ImagePipeLogError(const char* entity, | |
jamesr
2016/02/18 20:40:59
why const char*?
Forrest Reiling
2016/02/25 00:35:14
Done.
| |
51 const char* message, | |
52 uint32_t id); | |
53 | |
54 // Used for internal state tracking and validation | |
55 std::map<uint32_t, mojo::gfx::ImagePipe::PresentImageCallback> | |
jamesr
2016/02/18 20:40:59
unordered_map?
Forrest Reiling
2016/02/25 00:35:14
I mean theres not likely going to be more than a f
| |
56 present_callback_map_; | |
57 | |
58 // ids that have been added to the pipe's image pool and have not been removed | |
59 std::vector<uint32_t> image_pool_ids_; | |
jamesr
2016/02/18 20:40:59
does the order of these matter? if it's just keepi
Forrest Reiling
2016/02/25 00:35:14
yeah i guess. The ones that are deques I think sho
| |
60 | |
61 // images that have been aquired by the consumer | |
62 std::vector<uint32_t> consumer_owned_ids_; | |
63 // images that have been presented by the producer but have not been aquired | |
64 // by the consumer | |
65 std::deque<uint32_t> consumer_acquirable_ids_; | |
66 | |
67 // images that have been aquired by the producer | |
68 std::vector<uint32_t> producer_owned_ids_; | |
69 // images that have been released by the producer but have not been aquired | |
70 // by the consumer | |
71 std::deque<uint32_t> producer_acquirable_ids_; | |
72 | |
73 bool is_producer_; | |
74 bool is_checked_; | |
75 std::function<void()> fatal_error_handler_; | |
76 }; | |
77 } | |
jamesr
2016/02/18 20:40:59
say what this bracket is closing (i.e. "} // name
Forrest Reiling
2016/02/25 00:35:14
Done.
| |
78 | |
79 #endif // MOJO_SERVICES_GFX_IMAGES_CPP_IMAGE_PIPE_ENDPOINT_H_ | |
OLD | NEW |