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

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: minor changes to make it build with GCC on fnl Created 4 years, 10 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 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 // Base class for ImagePipeConsumerEndpoint and ImagePipeProducerEndpoint that
18 // provides common state state tracking facilities
19 class ImagePipeEndpoint {
20 public:
21 ImagePipeEndpoint(bool is_producer, bool is_checked);
22 virtual ~ImagePipeEndpoint();
23
24 virtual void CloseEndpoint() = 0;
25
26 protected:
27 void ProducerFatalError(const char* message, uint32_t id);
28 void ConsumerFatalError(const char* message, uint32_t id);
29
30 bool AcquireNextImage(uint32_t& id);
31
32 void ProducerAdd(uint32_t id);
33 void ProducerRemove(uint32_t id);
34 void ProducerPresent(uint32_t id,
35 mojo::gfx::ImagePipe::PresentImageCallback callback);
36 void ConsumerRelease(uint32_t id, mojo::gfx::PresentationStatus status);
37 void ProducerFlush();
38
39 private:
40 bool IsInPool(uint32_t id) const;
41 bool IsConsumerOwned(uint32_t id) const;
42 bool IsConsumerAcquirable(uint32_t id) const;
43 bool IsProducerOwned(uint32_t id) const;
44 bool IsProducerAcquirable(uint32_t id) const;
45 void CallPresentCallback(uint32_t id, mojo::gfx::PresentationStatus status);
46 void ReleaseInternal(uint32_t id, bool released_by_producer);
47
48 static void ImagePipeLogError(const char* entity,
49 const char* message,
50 uint32_t id);
51
52 // Used for internal state tracking and validation
53 std::map<uint32_t, mojo::gfx::ImagePipe::PresentImageCallback>
54 present_callback_map_;
55
56 // ids that have been added to the pipe's image pool and have not been removed
57 std::vector<uint32_t> image_pool_ids_;
58
59 // images that have been aquired by the consumer
60 std::vector<uint32_t> consumer_owned_ids_;
61 // images that have been presented by the producer but have not been aquired
62 // by the consumer
63 std::deque<uint32_t> consumer_acquirable_ids_;
64
65 // images that have been aquired by the producer
66 std::vector<uint32_t> producer_owned_ids_;
67 // images that have been released by the producer but have not been aquired
68 // by the consumer
69 std::deque<uint32_t> producer_acquirable_ids_;
70
71 bool is_producer_;
72 bool is_checked_;
73 };
74 }
75
76 #endif // MOJO_SERVICES_GFX_IMAGES_CPP_IMAGE_PIPE_ENDPOINT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698