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

Side by Side Diff: mojo/services/gfx/images/cpp/image_pipe_consumer_endpoint.cc

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 #include "image_pipe_consumer_endpoint.h"
6
7 namespace image_pipe {
8
9 void ImagePipeConsumerEndpoint::CloseEndpoint() {
10 image_pipe_binding_.Close();
11 delegate_->HandleEndpointClosed();
12 }
13
14 ImagePipeConsumerEndpoint::ImagePipeConsumerEndpoint(
15 mojo::InterfaceRequest<mojo::gfx::ImagePipe> request,
16 mojo::gfx::SupportedImagePropertiesPtr supported_properties,
17 ImagePipeConsumerDelegate* delegate)
18 : state_tracker_(false, [this]() { CloseEndpoint(); }),
19 delegate_(delegate),
20 supported_properties_dirty_(true),
21 supported_properties_callback_pending_(false),
22 image_pipe_binding_(this, request.Pass()) {
23 image_pipe_binding_.set_connection_error_handler([this]() {
24 MOJO_LOG(ERROR) << "Image Pipe Connection Error for Consumer!";
25 CloseEndpoint();
26 });
27
28 supported_properties_ = supported_properties.Pass();
29 }
30
31 ImagePipeConsumerEndpoint::~ImagePipeConsumerEndpoint() {}
32
33 void ImagePipeConsumerEndpoint::ReleaseImage(
34 uint32_t id,
35 mojo::gfx::PresentationStatus status) {
36 state_tracker_.ConsumerRelease(id, status);
37 }
38
39 void ImagePipeConsumerEndpoint::SetSupportedImageProperties(
40 mojo::gfx::SupportedImagePropertiesPtr supported_properties) {
41 supported_properties_ = supported_properties.Pass();
42 supported_properties_dirty_ = true;
43
44 if (supported_properties_callback_pending_) {
45 supported_properties_callback_.Run(supported_properties_.Clone());
46 supported_properties_callback_pending_ = false;
47 supported_properties_dirty_ = false;
48 }
49 }
50
51 // mojo::gfx::ImagePipe implementation
52 void ImagePipeConsumerEndpoint::AddImage(mojo::gfx::ImagePtr image,
53 uint32_t id) {
54 state_tracker_.ProducerAdd(id);
55 delegate_->AddImage(image.Pass(), id);
56 }
57
58 void ImagePipeConsumerEndpoint::RemoveImage(uint32_t id) {
59 state_tracker_.ProducerRemove(id);
60 delegate_->RemoveImage(id);
61 }
62
63 void ImagePipeConsumerEndpoint::PresentImage(
64 uint32_t id,
65 const PresentImageCallback& callback) {
66 state_tracker_.ProducerPresent(id, callback);
67 delegate_->PresentImage(id);
68 }
69
70 void ImagePipeConsumerEndpoint::FlushImages() {
71 state_tracker_.ProducerFlush();
72 }
73
74 void ImagePipeConsumerEndpoint::GetSupportedImageProperties(
75 const GetSupportedImagePropertiesCallback& callback) {
76 if (supported_properties_dirty_) {
77 callback.Run(supported_properties_.Clone());
78 supported_properties_dirty_ = false;
79 } else {
80 supported_properties_callback_ = callback;
81 supported_properties_callback_pending_ = true;
82 }
83 }
84
85 bool ImagePipeConsumerEndpoint::AcquireNextImage(uint32_t* id) {
86 return state_tracker_.AcquireNextImage(id);
87 }
88
89 void ImagePipeConsumerEndpoint::DisableFatalErrorsForTesting() {
90 state_tracker_.DisableFatalErrorsForTesting();
91 }
92
93 } // namespace image_pipe
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698