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

Unified 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: minor changes to make it build with GCC on fnl Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.h
diff --git a/mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.h b/mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.h
new file mode 100644
index 0000000000000000000000000000000000000000..77d0ace63ce874090bc8cf4564f192a48eef4042
--- /dev/null
+++ b/mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.h
@@ -0,0 +1,59 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_PRODUCER_ENDPOINT_H_
+#define MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_PRODUCER_ENDPOINT_H_
+
+#include "image_pipe_endpoint.h"
+#include "mojo/public/c/system/macros.h"
+#include "mojo/services/gfx/images/interfaces/image_pipe.mojom.h"
+
+namespace image_pipe {
+
+// This class wraps the producer end of an ImagePipe and validates the sanity
+// of both the producer actions and the consumer actions coming over the
+// message pipe. It also tracks the state of Images in the pipe's image pool
+// and provides conviennce mechanisms for accessing this state (like the ability
+// to get the ID of an available image without having to manually track the
+// lifecycle of these images.
+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.
+ public mojo::gfx::ImagePipe {
+ public:
+ ImagePipeProducerEndpoint(mojo::gfx::ImagePipePtr image_pipe,
+ std::function<void()> endpoint_closed_callback,
+ 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
+
+ ~ImagePipeProducerEndpoint() override;
+
+ // ask the endpoint for an available image to draw into
+ // returns false if no images are available, otherwise returns true and
+ // sets |id| to the acquired ID. If |blocking| is true, this function will
+ // block until an Image is available. If |blocking| is true, but there are no
+ // images in the pool or the underlying message pipe has errors then false
+ // will be returned
+ 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.
+
+ // Inherited from mojo::gfx::ImagePipe, see image_pipe.mojom for comments
+ void AddImage(mojo::gfx::ImagePtr image, uint32_t id) override;
+ void RemoveImage(uint32_t id) override;
+ void PresentImage(uint32_t id, const PresentImageCallback& callback) override;
+ void FlushImages() override;
+ void GetSupportedImageProperties(
+ const GetSupportedImagePropertiesCallback& callback) override;
+
+ void CloseEndpoint() override;
+
+ private:
+ // This exists wrap ImagePipeEndpoint::ConsumerRelease because for some reason
+ // GCC doesnt like us calling protected methods on our base class from inside
+ // a lambda that captures 'this', which breaks the fnl build. Clang handles it
+ // fine, but its unclear whos right here, so we trampoline it as a workaround
+ void ConsumerReleaseInternal(uint32_t id,
+ mojo::gfx::PresentationStatus status);
+ mojo::gfx::ImagePipePtr image_pipe_ptr_;
+ std::function<void()> endpoint_closed_callback_;
+};
+}
+
+#endif // MOJO_SERVICES_GFX_IMAGES_INTERFACES_IMAGE_PIPE_PRODUCER_ENDPOINT_H_
« no previous file with comments | « mojo/services/gfx/images/cpp/image_pipe_endpoint.cc ('k') | mojo/services/gfx/images/cpp/image_pipe_producer_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698