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

Side by Side Diff: mojo/services/gfx/images/cpp/image_pipe_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_CPP_IMAGE_PIPE_ENDPOINT_H_
6 #define MOJO_SERVICES_GFX_IMAGES_CPP_IMAGE_PIPE_ENDPOINT_H_
7
8 #include <deque>
9 #include <string>
10 #include <unordered_map>
11 #include <unordered_set>
12 #include <vector>
13
14 #include "mojo/public/c/system/macros.h"
15 #include "mojo/services/gfx/images/interfaces/image_pipe.mojom.h"
16
17 namespace image_pipe {
18
19 class ImagePipeEndpoint {
20 public:
21 ImagePipeEndpoint(bool is_producer,
22 std::function<void()> fatal_error_handler);
23 virtual ~ImagePipeEndpoint();
24
25 void ProducerFatalError(const std::string& message, uint32_t id);
26 void ConsumerFatalError(const std::string& message, uint32_t id);
27
28 bool AcquireNextImage(uint32_t* id);
jeffbrown 2016/03/03 23:27:49 nit: out_id
Forrest Reiling 2016/03/04 21:04:28 Done.
29
30 void ProducerAdd(uint32_t id);
31 void ProducerRemove(uint32_t id);
32 void ProducerPresent(uint32_t id,
33 mojo::gfx::ImagePipe::PresentImageCallback callback);
34 void ConsumerRelease(uint32_t id, mojo::gfx::PresentationStatus status);
35 void ProducerFlush();
36
37 // For testing only, makes fatal errors not quite fatal, which allows tests
38 // to cause a fatal error and check that it was caught correctly without
39 // dying a horrible death in the process. If you are using this for something
40 // other than testing you are probably doing something very wrong.
41 void DisableFatalErrorsForTesting();
42
43 private:
44 bool IsInPool(uint32_t id) const;
45 bool IsConsumerOwned(uint32_t id) const;
46 bool IsConsumerAcquirable(uint32_t id) const;
47 bool IsProducerOwned(uint32_t id) const;
48 bool IsProducerAcquirable(uint32_t id) const;
49 void CallPresentCallback(uint32_t id, mojo::gfx::PresentationStatus status);
50 void ReleaseInternal(uint32_t id, bool released_by_producer);
51
52 static void ImagePipeLogError(const std::string& entity,
53 const std::string& message,
54 uint32_t id);
55
56 // Used for internal state tracking and validation
57 std::unordered_map<uint32_t, mojo::gfx::ImagePipe::PresentImageCallback>
58 present_callback_map_;
59
60 // ids that have been added to the pipe's image pool and have not been removed
61 std::unordered_set<uint32_t> image_pool_ids_;
62
63 // images that have been aquired by the consumer
64 std::unordered_set<uint32_t> consumer_owned_ids_;
65 // images that have been presented by the producer but have not been aquired
66 // by the consumer
67 std::deque<uint32_t> consumer_acquirable_ids_;
68
69 // images that have been aquired by the producer
70 std::unordered_set<uint32_t> producer_owned_ids_;
71 // images that have been released by the producer but have not been aquired
72 // by the consumer
73 std::deque<uint32_t> producer_acquirable_ids_;
74
75 bool is_producer_;
76 bool is_checked_;
77 std::function<void()> fatal_error_handler_;
78 };
79 }
80
81 #endif // MOJO_SERVICES_GFX_IMAGES_CPP_IMAGE_PIPE_ENDPOINT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698