| // camera/mojo/gpu/jpeg_encode_accelerator.mojom.cc is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2013 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #if defined(__clang__) |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wunused-private-field" |
| #endif |
| |
| #include "camera/mojo/gpu/jpeg_encode_accelerator.mojom.h" |
| |
| #include <math.h> |
| #include <stdint.h> |
| #include <utility> |
| |
| #include "base/debug/alias.h" |
| #include "base/hash/md5_constexpr.h" |
| #include "base/run_loop.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/task/thread_pool/thread_pool_instance.h" |
| #include "base/trace_event/trace_event.h" |
| #include "base/trace_event/typed_macros.h" |
| #include "mojo/public/cpp/bindings/features.h" |
| #include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h" |
| #include "mojo/public/cpp/bindings/lib/generated_code_util.h" |
| #include "mojo/public/cpp/bindings/lib/message_internal.h" |
| #include "mojo/public/cpp/bindings/lib/proxy_to_responder.h" |
| #include "mojo/public/cpp/bindings/lib/send_message_helper.h" |
| #include "mojo/public/cpp/bindings/lib/serialization_util.h" |
| #include "mojo/public/cpp/bindings/lib/unserialized_message_context.h" |
| #include "mojo/public/cpp/bindings/lib/validate_params.h" |
| #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| #include "mojo/public/cpp/bindings/mojo_buildflags.h" |
| #include "mojo/public/cpp/bindings/urgent_message_scope.h" |
| #include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h" |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value.h" |
| |
| #include "camera/mojo/gpu/jpeg_encode_accelerator.mojom-params-data.h" |
| #include "camera/mojo/gpu/jpeg_encode_accelerator.mojom-shared-message-ids.h" |
| |
| #include "camera/mojo/gpu/jpeg_encode_accelerator.mojom-import-headers.h" |
| #include "camera/mojo/gpu/jpeg_encode_accelerator.mojom-test-utils.h" |
| |
| |
| namespace cros::mojom { |
| const char JpegEncodeAccelerator::Name_[] = "cros.mojom.JpegEncodeAccelerator"; |
| |
| JpegEncodeAccelerator::IPCStableHashFunction JpegEncodeAccelerator::MessageToMethodInfo_(mojo::Message& message) { |
| #if !BUILDFLAG(IS_FUCHSIA) |
| switch (static_cast<messages::JpegEncodeAccelerator>(message.name())) { |
| case messages::JpegEncodeAccelerator::kInitialize: { |
| return &JpegEncodeAccelerator::Initialize_Sym::IPCStableHash; |
| } |
| case messages::JpegEncodeAccelerator::kEncodeWithFD: { |
| return &JpegEncodeAccelerator::EncodeWithFD_Sym::IPCStableHash; |
| } |
| case messages::JpegEncodeAccelerator::kEncodeWithDmaBuf: { |
| return &JpegEncodeAccelerator::EncodeWithDmaBuf_Sym::IPCStableHash; |
| } |
| } |
| #endif // !BUILDFLAG(IS_FUCHSIA) |
| return nullptr; |
| } |
| |
| |
| const char* JpegEncodeAccelerator::MessageToMethodName_(mojo::Message& message) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| bool is_response = message.has_flag(mojo::Message::kFlagIsResponse); |
| if (!is_response) { |
| switch (static_cast<messages::JpegEncodeAccelerator>(message.name())) { |
| case messages::JpegEncodeAccelerator::kInitialize: |
| return "Receive cros::mojom::JpegEncodeAccelerator::Initialize"; |
| case messages::JpegEncodeAccelerator::kEncodeWithFD: |
| return "Receive cros::mojom::JpegEncodeAccelerator::EncodeWithFD"; |
| case messages::JpegEncodeAccelerator::kEncodeWithDmaBuf: |
| return "Receive cros::mojom::JpegEncodeAccelerator::EncodeWithDmaBuf"; |
| } |
| } else { |
| switch (static_cast<messages::JpegEncodeAccelerator>(message.name())) { |
| case messages::JpegEncodeAccelerator::kInitialize: |
| return "Receive reply cros::mojom::JpegEncodeAccelerator::Initialize"; |
| case messages::JpegEncodeAccelerator::kEncodeWithFD: |
| return "Receive reply cros::mojom::JpegEncodeAccelerator::EncodeWithFD"; |
| case messages::JpegEncodeAccelerator::kEncodeWithDmaBuf: |
| return "Receive reply cros::mojom::JpegEncodeAccelerator::EncodeWithDmaBuf"; |
| } |
| } |
| return "Receive unknown mojo message"; |
| #else |
| bool is_response = message.has_flag(mojo::Message::kFlagIsResponse); |
| if (is_response) { |
| return "Receive mojo reply"; |
| } else { |
| return "Receive mojo message"; |
| } |
| #endif // BUILDFLAG(MOJO_TRACE_ENABLED) |
| } |
| |
| #if !BUILDFLAG(IS_FUCHSIA) |
| uint32_t JpegEncodeAccelerator::Initialize_Sym::IPCStableHash() { |
| // This method's address is used for indetifiying the mojo method name after |
| // symbolization. So each IPCStableHash should have a unique address. |
| // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of |
| // __LINE__ value, which is not unique accross different mojo modules. |
| // The code below is very similar to NO_CODE_FOLDING, but it uses a unique |
| // hash instead of __LINE__. |
| constexpr uint32_t kHash = base::MD5Hash32Constexpr( |
| "(Impl)cros::mojom::JpegEncodeAccelerator::Initialize"); |
| const uint32_t hash = kHash; |
| base::debug::Alias(&hash); |
| return hash; |
| } |
| uint32_t JpegEncodeAccelerator::EncodeWithFD_Sym::IPCStableHash() { |
| // This method's address is used for indetifiying the mojo method name after |
| // symbolization. So each IPCStableHash should have a unique address. |
| // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of |
| // __LINE__ value, which is not unique accross different mojo modules. |
| // The code below is very similar to NO_CODE_FOLDING, but it uses a unique |
| // hash instead of __LINE__. |
| constexpr uint32_t kHash = base::MD5Hash32Constexpr( |
| "(Impl)cros::mojom::JpegEncodeAccelerator::EncodeWithFD"); |
| const uint32_t hash = kHash; |
| base::debug::Alias(&hash); |
| return hash; |
| } |
| uint32_t JpegEncodeAccelerator::EncodeWithDmaBuf_Sym::IPCStableHash() { |
| // This method's address is used for indetifiying the mojo method name after |
| // symbolization. So each IPCStableHash should have a unique address. |
| // We cannot use NO_CODE_FOLDING() here - it relies on the uniqueness of |
| // __LINE__ value, which is not unique accross different mojo modules. |
| // The code below is very similar to NO_CODE_FOLDING, but it uses a unique |
| // hash instead of __LINE__. |
| constexpr uint32_t kHash = base::MD5Hash32Constexpr( |
| "(Impl)cros::mojom::JpegEncodeAccelerator::EncodeWithDmaBuf"); |
| const uint32_t hash = kHash; |
| base::debug::Alias(&hash); |
| return hash; |
| } |
| # endif // !BUILDFLAG(IS_FUCHSIA) |
| |
| class JpegEncodeAccelerator_Initialize_ForwardToCallback |
| : public mojo::MessageReceiver { |
| public: |
| JpegEncodeAccelerator_Initialize_ForwardToCallback( |
| JpegEncodeAccelerator::InitializeCallback callback |
| ) : callback_(std::move(callback)) { |
| } |
| |
| JpegEncodeAccelerator_Initialize_ForwardToCallback(const JpegEncodeAccelerator_Initialize_ForwardToCallback&) = delete; |
| JpegEncodeAccelerator_Initialize_ForwardToCallback& operator=(const JpegEncodeAccelerator_Initialize_ForwardToCallback&) = delete; |
| |
| bool Accept(mojo::Message* message) override; |
| private: |
| JpegEncodeAccelerator::InitializeCallback callback_; |
| }; |
| |
| class JpegEncodeAccelerator_EncodeWithFD_ForwardToCallback |
| : public mojo::MessageReceiver { |
| public: |
| JpegEncodeAccelerator_EncodeWithFD_ForwardToCallback( |
| JpegEncodeAccelerator::EncodeWithFDCallback callback |
| ) : callback_(std::move(callback)) { |
| } |
| |
| JpegEncodeAccelerator_EncodeWithFD_ForwardToCallback(const JpegEncodeAccelerator_EncodeWithFD_ForwardToCallback&) = delete; |
| JpegEncodeAccelerator_EncodeWithFD_ForwardToCallback& operator=(const JpegEncodeAccelerator_EncodeWithFD_ForwardToCallback&) = delete; |
| |
| bool Accept(mojo::Message* message) override; |
| private: |
| JpegEncodeAccelerator::EncodeWithFDCallback callback_; |
| }; |
| |
| class JpegEncodeAccelerator_EncodeWithDmaBuf_ForwardToCallback |
| : public mojo::MessageReceiver { |
| public: |
| JpegEncodeAccelerator_EncodeWithDmaBuf_ForwardToCallback( |
| JpegEncodeAccelerator::EncodeWithDmaBufCallback callback |
| ) : callback_(std::move(callback)) { |
| } |
| |
| JpegEncodeAccelerator_EncodeWithDmaBuf_ForwardToCallback(const JpegEncodeAccelerator_EncodeWithDmaBuf_ForwardToCallback&) = delete; |
| JpegEncodeAccelerator_EncodeWithDmaBuf_ForwardToCallback& operator=(const JpegEncodeAccelerator_EncodeWithDmaBuf_ForwardToCallback&) = delete; |
| |
| bool Accept(mojo::Message* message) override; |
| private: |
| JpegEncodeAccelerator::EncodeWithDmaBufCallback callback_; |
| }; |
| |
| JpegEncodeAcceleratorProxy::JpegEncodeAcceleratorProxy(mojo::MessageReceiverWithResponder* receiver) |
| : receiver_(receiver) { |
| } |
| |
| void JpegEncodeAcceleratorProxy::Initialize( |
| InitializeCallback callback) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT0("mojom", "Send cros::mojom::JpegEncodeAccelerator::Initialize"); |
| #endif |
| |
| const bool kExpectsResponse = true; |
| const bool kIsSync = false; |
| const bool kAllowInterrupt = true; |
| const bool is_urgent = false; |
| |
| const uint32_t kFlags = |
| ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) | |
| ((kIsSync) ? mojo::Message::kFlagIsSync : 0) | |
| ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) | |
| ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0); |
| |
| const size_t estimated_payload_size = |
| 0; |
| mojo::Message message( |
| base::to_underlying(messages::JpegEncodeAccelerator::kInitialize), kFlags, estimated_payload_size); |
| mojo::internal::MessageFragment< |
| ::cros::mojom::internal::JpegEncodeAccelerator_Initialize_Params_Data> params( |
| message); |
| params.Allocate(); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(JpegEncodeAccelerator::Name_); |
| message.set_method_name("Initialize"); |
| #endif |
| std::unique_ptr<mojo::MessageReceiver> responder( |
| new JpegEncodeAccelerator_Initialize_ForwardToCallback( |
| std::move(callback))); |
| ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder)); |
| } |
| |
| void JpegEncodeAcceleratorProxy::EncodeWithFD( |
| int32_t in_task_id, ::mojo::ScopedHandle in_input_fd, uint32_t in_input_buffer_size, int32_t in_coded_size_width, int32_t in_coded_size_height, ::mojo::ScopedHandle in_exif_fd, uint32_t in_exif_buffer_size, ::mojo::ScopedHandle in_output_fd, uint32_t in_output_buffer_size, EncodeWithFDCallback callback) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send cros::mojom::JpegEncodeAccelerator::EncodeWithFD", "input_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("task_id"), in_task_id, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("input_fd"), in_input_fd, |
| "<value of type ::mojo::ScopedHandle>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("input_buffer_size"), in_input_buffer_size, |
| "<value of type uint32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("coded_size_width"), in_coded_size_width, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("coded_size_height"), in_coded_size_height, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("exif_fd"), in_exif_fd, |
| "<value of type ::mojo::ScopedHandle>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("exif_buffer_size"), in_exif_buffer_size, |
| "<value of type uint32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("output_fd"), in_output_fd, |
| "<value of type ::mojo::ScopedHandle>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("output_buffer_size"), in_output_buffer_size, |
| "<value of type uint32_t>"); |
| }); |
| #endif |
| |
| const bool kExpectsResponse = true; |
| const bool kIsSync = false; |
| const bool kAllowInterrupt = true; |
| const bool is_urgent = false; |
| |
| const uint32_t kFlags = |
| ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) | |
| ((kIsSync) ? mojo::Message::kFlagIsSync : 0) | |
| ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) | |
| ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0); |
| |
| const size_t estimated_payload_size = |
| 0; |
| mojo::Message message( |
| base::to_underlying(messages::JpegEncodeAccelerator::kEncodeWithFD), kFlags, estimated_payload_size); |
| mojo::internal::MessageFragment< |
| ::cros::mojom::internal::JpegEncodeAccelerator_EncodeWithFD_Params_Data> params( |
| message); |
| params.Allocate(); |
| params->task_id = in_task_id; |
| mojo::internal::Serialize<mojo::ScopedHandle>( |
| in_input_fd, ¶ms->input_fd, ¶ms.message()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| !mojo::internal::IsHandleOrInterfaceValid(params->input_fd), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
| "invalid input_fd in JpegEncodeAccelerator.EncodeWithFD request"); |
| params->input_buffer_size = in_input_buffer_size; |
| params->coded_size_width = in_coded_size_width; |
| params->coded_size_height = in_coded_size_height; |
| mojo::internal::Serialize<mojo::ScopedHandle>( |
| in_exif_fd, ¶ms->exif_fd, ¶ms.message()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| !mojo::internal::IsHandleOrInterfaceValid(params->exif_fd), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
| "invalid exif_fd in JpegEncodeAccelerator.EncodeWithFD request"); |
| params->exif_buffer_size = in_exif_buffer_size; |
| mojo::internal::Serialize<mojo::ScopedHandle>( |
| in_output_fd, ¶ms->output_fd, ¶ms.message()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| !mojo::internal::IsHandleOrInterfaceValid(params->output_fd), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
| "invalid output_fd in JpegEncodeAccelerator.EncodeWithFD request"); |
| params->output_buffer_size = in_output_buffer_size; |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(JpegEncodeAccelerator::Name_); |
| message.set_method_name("EncodeWithFD"); |
| #endif |
| std::unique_ptr<mojo::MessageReceiver> responder( |
| new JpegEncodeAccelerator_EncodeWithFD_ForwardToCallback( |
| std::move(callback))); |
| ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder)); |
| } |
| |
| void JpegEncodeAcceleratorProxy::EncodeWithDmaBuf( |
| int32_t in_task_id, uint32_t in_input_format, std::vector<::cros::mojom::DmaBufPlanePtr> in_input_planes, std::vector<::cros::mojom::DmaBufPlanePtr> in_output_planes, ::mojo::ScopedHandle in_exif_handle, uint32_t in_exif_buffer_size, int32_t in_coded_size_width, int32_t in_coded_size_height, int32_t in_quality, bool in_has_input_modifier, uint64_t in_input_modifier, EncodeWithDmaBufCallback callback) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send cros::mojom::JpegEncodeAccelerator::EncodeWithDmaBuf", "input_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("task_id"), in_task_id, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("input_format"), in_input_format, |
| "<value of type uint32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("input_planes"), in_input_planes, |
| "<value of type std::vector<::cros::mojom::DmaBufPlanePtr>>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("output_planes"), in_output_planes, |
| "<value of type std::vector<::cros::mojom::DmaBufPlanePtr>>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("exif_handle"), in_exif_handle, |
| "<value of type ::mojo::ScopedHandle>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("exif_buffer_size"), in_exif_buffer_size, |
| "<value of type uint32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("coded_size_width"), in_coded_size_width, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("coded_size_height"), in_coded_size_height, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("quality"), in_quality, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("has_input_modifier"), in_has_input_modifier, |
| "<value of type bool>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("input_modifier"), in_input_modifier, |
| "<value of type uint64_t>"); |
| }); |
| #endif |
| |
| const bool kExpectsResponse = true; |
| const bool kIsSync = false; |
| const bool kAllowInterrupt = true; |
| const bool is_urgent = false; |
| |
| const uint32_t kFlags = |
| ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) | |
| ((kIsSync) ? mojo::Message::kFlagIsSync : 0) | |
| ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt) | |
| ((is_urgent) ? mojo::Message::kFlagIsUrgent : 0); |
| |
| const size_t estimated_payload_size = |
| 0; |
| mojo::Message message( |
| base::to_underlying(messages::JpegEncodeAccelerator::kEncodeWithDmaBuf), kFlags, estimated_payload_size); |
| mojo::internal::MessageFragment< |
| ::cros::mojom::internal::JpegEncodeAccelerator_EncodeWithDmaBuf_Params_Data> params( |
| message); |
| params.Allocate(); |
| params->task_id = in_task_id; |
| params->input_format = in_input_format; |
| mojo::internal::MessageFragment< |
| typename decltype(params->input_planes)::BaseType> |
| input_planes_fragment(params.message()); |
| constexpr const mojo::internal::ContainerValidateParams& input_planes_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| mojo::internal::Serialize<mojo::ArrayDataView<::cros::mojom::DmaBufPlaneDataView>>( |
| in_input_planes, input_planes_fragment, &input_planes_validate_params); |
| params->input_planes.Set( |
| input_planes_fragment.is_null() ? nullptr : input_planes_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| params->input_planes.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null input_planes in JpegEncodeAccelerator.EncodeWithDmaBuf request"); |
| mojo::internal::MessageFragment< |
| typename decltype(params->output_planes)::BaseType> |
| output_planes_fragment(params.message()); |
| constexpr const mojo::internal::ContainerValidateParams& output_planes_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| mojo::internal::Serialize<mojo::ArrayDataView<::cros::mojom::DmaBufPlaneDataView>>( |
| in_output_planes, output_planes_fragment, &output_planes_validate_params); |
| params->output_planes.Set( |
| output_planes_fragment.is_null() ? nullptr : output_planes_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| params->output_planes.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null output_planes in JpegEncodeAccelerator.EncodeWithDmaBuf request"); |
| mojo::internal::Serialize<mojo::ScopedHandle>( |
| in_exif_handle, ¶ms->exif_handle, ¶ms.message()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| !mojo::internal::IsHandleOrInterfaceValid(params->exif_handle), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
| "invalid exif_handle in JpegEncodeAccelerator.EncodeWithDmaBuf request"); |
| params->exif_buffer_size = in_exif_buffer_size; |
| params->coded_size_width = in_coded_size_width; |
| params->coded_size_height = in_coded_size_height; |
| params->quality = in_quality; |
| params->has_input_modifier = in_has_input_modifier; |
| params->input_modifier = in_input_modifier; |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(JpegEncodeAccelerator::Name_); |
| message.set_method_name("EncodeWithDmaBuf"); |
| #endif |
| std::unique_ptr<mojo::MessageReceiver> responder( |
| new JpegEncodeAccelerator_EncodeWithDmaBuf_ForwardToCallback( |
| std::move(callback))); |
| ::mojo::internal::SendMojoMessage(*receiver_, message, std::move(responder)); |
| } |
| class JpegEncodeAccelerator_Initialize_ProxyToResponder : public ::mojo::internal::ProxyToResponder { |
| public: |
| static JpegEncodeAccelerator::InitializeCallback CreateCallback( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { |
| std::unique_ptr<JpegEncodeAccelerator_Initialize_ProxyToResponder> proxy( |
| new JpegEncodeAccelerator_Initialize_ProxyToResponder( |
| message, std::move(responder))); |
| return base::BindOnce(&JpegEncodeAccelerator_Initialize_ProxyToResponder::Run, |
| std::move(proxy)); |
| } |
| |
| ~JpegEncodeAccelerator_Initialize_ProxyToResponder() { |
| #if DCHECK_IS_ON() |
| if (responder_) { |
| // If we're being destroyed without being run, we want to ensure the |
| // binding endpoint has been closed. This checks for that asynchronously. |
| // We pass a bound generated callback to handle the response so that any |
| // resulting DCHECK stack will have useful interface type information. |
| // Instantiate a ScopedFizzleBlockShutdownTasks to allow this request to |
| // fizzle if this happens after shutdown and the endpoint is bound to a |
| // BLOCK_SHUTDOWN sequence. |
| base::ThreadPoolInstance::ScopedFizzleBlockShutdownTasks fizzler; |
| responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete)); |
| } |
| #endif |
| } |
| |
| private: |
| JpegEncodeAccelerator_Initialize_ProxyToResponder( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) |
| : ::mojo::internal::ProxyToResponder(message, std::move(responder)) { |
| } |
| |
| #if DCHECK_IS_ON() |
| static void OnIsConnectedComplete(bool connected) { |
| DCHECK(!connected) |
| << "JpegEncodeAccelerator::InitializeCallback was destroyed without " |
| << "first either being run or its corresponding binding being closed. " |
| << "It is an error to drop response callbacks which still correspond " |
| << "to an open interface pipe."; |
| } |
| #endif |
| |
| void Run( |
| bool in_success); |
| }; |
| |
| bool JpegEncodeAccelerator_Initialize_ForwardToCallback::Accept( |
| mojo::Message* message) { |
| DCHECK(message->is_serialized()); |
| internal::JpegEncodeAccelerator_Initialize_ResponseParams_Data* params = |
| reinterpret_cast< |
| internal::JpegEncodeAccelerator_Initialize_ResponseParams_Data*>( |
| message->mutable_payload()); |
| |
| |
| // Validation for JpegEncodeAccelerator.0 |
| bool success = true; |
| bool p_success{}; |
| JpegEncodeAccelerator_Initialize_ResponseParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_success = input_data_view.success(); |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| JpegEncodeAccelerator::Name_, 0, true); |
| return false; |
| } |
| if (!callback_.is_null()) |
| std::move(callback_).Run( |
| std::move(p_success)); |
| return true; |
| } |
| |
| void JpegEncodeAccelerator_Initialize_ProxyToResponder::Run( |
| bool in_success) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send reply cros::mojom::JpegEncodeAccelerator::Initialize", "async_response_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("success"), in_success, |
| "<value of type bool>"); |
| }); |
| #endif |
| |
| const uint32_t kFlags = mojo::Message::kFlagIsResponse | |
| ((is_sync_) ? mojo::Message::kFlagIsSync : 0) | |
| ((true) ? 0 : mojo::Message::kFlagNoInterrupt) | |
| ((false) ? mojo::Message::kFlagIsUrgent : 0); |
| |
| const size_t estimated_payload_size = |
| 0; |
| mojo::Message message( |
| base::to_underlying(messages::JpegEncodeAccelerator::kInitialize), kFlags, estimated_payload_size); |
| mojo::internal::MessageFragment< |
| ::cros::mojom::internal::JpegEncodeAccelerator_Initialize_ResponseParams_Data> params( |
| message); |
| params.Allocate(); |
| params->success = in_success; |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(JpegEncodeAccelerator::Name_); |
| message.set_method_name("Initialize"); |
| #endif |
| |
| message.set_request_id(request_id_); |
| message.set_trace_nonce(trace_nonce_); |
| ::mojo::internal::SendMojoMessage(*responder_, message); |
| // SendMojoMessage() fails silently if the responder connection is closed, |
| // or if the message is malformed. |
| // |
| // TODO(darin): If Accept() returns false due to a malformed message, that |
| // may be good reason to close the connection. However, we don't have a |
| // way to do that from here. We should add a way. |
| responder_ = nullptr; |
| } |
| class JpegEncodeAccelerator_EncodeWithFD_ProxyToResponder : public ::mojo::internal::ProxyToResponder { |
| public: |
| static JpegEncodeAccelerator::EncodeWithFDCallback CreateCallback( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { |
| std::unique_ptr<JpegEncodeAccelerator_EncodeWithFD_ProxyToResponder> proxy( |
| new JpegEncodeAccelerator_EncodeWithFD_ProxyToResponder( |
| message, std::move(responder))); |
| return base::BindOnce(&JpegEncodeAccelerator_EncodeWithFD_ProxyToResponder::Run, |
| std::move(proxy)); |
| } |
| |
| ~JpegEncodeAccelerator_EncodeWithFD_ProxyToResponder() { |
| #if DCHECK_IS_ON() |
| if (responder_) { |
| // If we're being destroyed without being run, we want to ensure the |
| // binding endpoint has been closed. This checks for that asynchronously. |
| // We pass a bound generated callback to handle the response so that any |
| // resulting DCHECK stack will have useful interface type information. |
| // Instantiate a ScopedFizzleBlockShutdownTasks to allow this request to |
| // fizzle if this happens after shutdown and the endpoint is bound to a |
| // BLOCK_SHUTDOWN sequence. |
| base::ThreadPoolInstance::ScopedFizzleBlockShutdownTasks fizzler; |
| responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete)); |
| } |
| #endif |
| } |
| |
| private: |
| JpegEncodeAccelerator_EncodeWithFD_ProxyToResponder( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) |
| : ::mojo::internal::ProxyToResponder(message, std::move(responder)) { |
| } |
| |
| #if DCHECK_IS_ON() |
| static void OnIsConnectedComplete(bool connected) { |
| DCHECK(!connected) |
| << "JpegEncodeAccelerator::EncodeWithFDCallback was destroyed without " |
| << "first either being run or its corresponding binding being closed. " |
| << "It is an error to drop response callbacks which still correspond " |
| << "to an open interface pipe."; |
| } |
| #endif |
| |
| void Run( |
| int32_t in_task_id, uint32_t in_encoded_buffer_size, EncodeStatus in_status); |
| }; |
| |
| bool JpegEncodeAccelerator_EncodeWithFD_ForwardToCallback::Accept( |
| mojo::Message* message) { |
| DCHECK(message->is_serialized()); |
| internal::JpegEncodeAccelerator_EncodeWithFD_ResponseParams_Data* params = |
| reinterpret_cast< |
| internal::JpegEncodeAccelerator_EncodeWithFD_ResponseParams_Data*>( |
| message->mutable_payload()); |
| |
| |
| // Validation for JpegEncodeAccelerator.1 |
| bool success = true; |
| int32_t p_task_id{}; |
| uint32_t p_encoded_buffer_size{}; |
| EncodeStatus p_status{}; |
| JpegEncodeAccelerator_EncodeWithFD_ResponseParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_task_id = input_data_view.task_id(); |
| if (success) |
| p_encoded_buffer_size = input_data_view.encoded_buffer_size(); |
| if (success && !input_data_view.ReadStatus(&p_status)) |
| success = false; |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| JpegEncodeAccelerator::Name_, 1, true); |
| return false; |
| } |
| if (!callback_.is_null()) |
| std::move(callback_).Run( |
| std::move(p_task_id), |
| std::move(p_encoded_buffer_size), |
| std::move(p_status)); |
| return true; |
| } |
| |
| void JpegEncodeAccelerator_EncodeWithFD_ProxyToResponder::Run( |
| int32_t in_task_id, uint32_t in_encoded_buffer_size, EncodeStatus in_status) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send reply cros::mojom::JpegEncodeAccelerator::EncodeWithFD", "async_response_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("task_id"), in_task_id, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("encoded_buffer_size"), in_encoded_buffer_size, |
| "<value of type uint32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("status"), in_status, |
| "<value of type EncodeStatus>"); |
| }); |
| #endif |
| |
| const uint32_t kFlags = mojo::Message::kFlagIsResponse | |
| ((is_sync_) ? mojo::Message::kFlagIsSync : 0) | |
| ((true) ? 0 : mojo::Message::kFlagNoInterrupt) | |
| ((false) ? mojo::Message::kFlagIsUrgent : 0); |
| |
| const size_t estimated_payload_size = |
| 0; |
| mojo::Message message( |
| base::to_underlying(messages::JpegEncodeAccelerator::kEncodeWithFD), kFlags, estimated_payload_size); |
| mojo::internal::MessageFragment< |
| ::cros::mojom::internal::JpegEncodeAccelerator_EncodeWithFD_ResponseParams_Data> params( |
| message); |
| params.Allocate(); |
| params->task_id = in_task_id; |
| params->encoded_buffer_size = in_encoded_buffer_size; |
| mojo::internal::Serialize<::cros::mojom::EncodeStatus>( |
| in_status, ¶ms->status); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(JpegEncodeAccelerator::Name_); |
| message.set_method_name("EncodeWithFD"); |
| #endif |
| |
| message.set_request_id(request_id_); |
| message.set_trace_nonce(trace_nonce_); |
| ::mojo::internal::SendMojoMessage(*responder_, message); |
| // SendMojoMessage() fails silently if the responder connection is closed, |
| // or if the message is malformed. |
| // |
| // TODO(darin): If Accept() returns false due to a malformed message, that |
| // may be good reason to close the connection. However, we don't have a |
| // way to do that from here. We should add a way. |
| responder_ = nullptr; |
| } |
| class JpegEncodeAccelerator_EncodeWithDmaBuf_ProxyToResponder : public ::mojo::internal::ProxyToResponder { |
| public: |
| static JpegEncodeAccelerator::EncodeWithDmaBufCallback CreateCallback( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { |
| std::unique_ptr<JpegEncodeAccelerator_EncodeWithDmaBuf_ProxyToResponder> proxy( |
| new JpegEncodeAccelerator_EncodeWithDmaBuf_ProxyToResponder( |
| message, std::move(responder))); |
| return base::BindOnce(&JpegEncodeAccelerator_EncodeWithDmaBuf_ProxyToResponder::Run, |
| std::move(proxy)); |
| } |
| |
| ~JpegEncodeAccelerator_EncodeWithDmaBuf_ProxyToResponder() { |
| #if DCHECK_IS_ON() |
| if (responder_) { |
| // If we're being destroyed without being run, we want to ensure the |
| // binding endpoint has been closed. This checks for that asynchronously. |
| // We pass a bound generated callback to handle the response so that any |
| // resulting DCHECK stack will have useful interface type information. |
| // Instantiate a ScopedFizzleBlockShutdownTasks to allow this request to |
| // fizzle if this happens after shutdown and the endpoint is bound to a |
| // BLOCK_SHUTDOWN sequence. |
| base::ThreadPoolInstance::ScopedFizzleBlockShutdownTasks fizzler; |
| responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete)); |
| } |
| #endif |
| } |
| |
| private: |
| JpegEncodeAccelerator_EncodeWithDmaBuf_ProxyToResponder( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) |
| : ::mojo::internal::ProxyToResponder(message, std::move(responder)) { |
| } |
| |
| #if DCHECK_IS_ON() |
| static void OnIsConnectedComplete(bool connected) { |
| DCHECK(!connected) |
| << "JpegEncodeAccelerator::EncodeWithDmaBufCallback was destroyed without " |
| << "first either being run or its corresponding binding being closed. " |
| << "It is an error to drop response callbacks which still correspond " |
| << "to an open interface pipe."; |
| } |
| #endif |
| |
| void Run( |
| uint32_t in_encoded_buffer_size, EncodeStatus in_status); |
| }; |
| |
| bool JpegEncodeAccelerator_EncodeWithDmaBuf_ForwardToCallback::Accept( |
| mojo::Message* message) { |
| DCHECK(message->is_serialized()); |
| internal::JpegEncodeAccelerator_EncodeWithDmaBuf_ResponseParams_Data* params = |
| reinterpret_cast< |
| internal::JpegEncodeAccelerator_EncodeWithDmaBuf_ResponseParams_Data*>( |
| message->mutable_payload()); |
| |
| |
| // Validation for JpegEncodeAccelerator.2 |
| bool success = true; |
| uint32_t p_encoded_buffer_size{}; |
| EncodeStatus p_status{}; |
| JpegEncodeAccelerator_EncodeWithDmaBuf_ResponseParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_encoded_buffer_size = input_data_view.encoded_buffer_size(); |
| if (success && !input_data_view.ReadStatus(&p_status)) |
| success = false; |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| JpegEncodeAccelerator::Name_, 2, true); |
| return false; |
| } |
| if (!callback_.is_null()) |
| std::move(callback_).Run( |
| std::move(p_encoded_buffer_size), |
| std::move(p_status)); |
| return true; |
| } |
| |
| void JpegEncodeAccelerator_EncodeWithDmaBuf_ProxyToResponder::Run( |
| uint32_t in_encoded_buffer_size, EncodeStatus in_status) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send reply cros::mojom::JpegEncodeAccelerator::EncodeWithDmaBuf", "async_response_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("encoded_buffer_size"), in_encoded_buffer_size, |
| "<value of type uint32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("status"), in_status, |
| "<value of type EncodeStatus>"); |
| }); |
| #endif |
| |
| const uint32_t kFlags = mojo::Message::kFlagIsResponse | |
| ((is_sync_) ? mojo::Message::kFlagIsSync : 0) | |
| ((true) ? 0 : mojo::Message::kFlagNoInterrupt) | |
| ((false) ? mojo::Message::kFlagIsUrgent : 0); |
| |
| const size_t estimated_payload_size = |
| 0; |
| mojo::Message message( |
| base::to_underlying(messages::JpegEncodeAccelerator::kEncodeWithDmaBuf), kFlags, estimated_payload_size); |
| mojo::internal::MessageFragment< |
| ::cros::mojom::internal::JpegEncodeAccelerator_EncodeWithDmaBuf_ResponseParams_Data> params( |
| message); |
| params.Allocate(); |
| params->encoded_buffer_size = in_encoded_buffer_size; |
| mojo::internal::Serialize<::cros::mojom::EncodeStatus>( |
| in_status, ¶ms->status); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(JpegEncodeAccelerator::Name_); |
| message.set_method_name("EncodeWithDmaBuf"); |
| #endif |
| |
| message.set_request_id(request_id_); |
| message.set_trace_nonce(trace_nonce_); |
| ::mojo::internal::SendMojoMessage(*responder_, message); |
| // SendMojoMessage() fails silently if the responder connection is closed, |
| // or if the message is malformed. |
| // |
| // TODO(darin): If Accept() returns false due to a malformed message, that |
| // may be good reason to close the connection. However, we don't have a |
| // way to do that from here. We should add a way. |
| responder_ = nullptr; |
| } |
| |
| // static |
| bool JpegEncodeAcceleratorStubDispatch::Accept( |
| JpegEncodeAccelerator* impl, |
| mojo::Message* message) { |
| switch (static_cast<messages::JpegEncodeAccelerator>(message->header()->name)) { |
| case messages::JpegEncodeAccelerator::kInitialize: { |
| break; |
| } |
| case messages::JpegEncodeAccelerator::kEncodeWithFD: { |
| break; |
| } |
| case messages::JpegEncodeAccelerator::kEncodeWithDmaBuf: { |
| break; |
| } |
| } |
| return false; |
| } |
| |
| // static |
| bool JpegEncodeAcceleratorStubDispatch::AcceptWithResponder( |
| JpegEncodeAccelerator* impl, |
| mojo::Message* message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { |
| [[maybe_unused]] const bool message_is_sync = |
| message->has_flag(mojo::Message::kFlagIsSync); |
| [[maybe_unused]] const uint64_t request_id = message->request_id(); |
| switch (static_cast<messages::JpegEncodeAccelerator>(message->header()->name)) { |
| case messages::JpegEncodeAccelerator::kInitialize: { |
| internal::JpegEncodeAccelerator_Initialize_Params_Data* params = |
| reinterpret_cast< |
| internal::JpegEncodeAccelerator_Initialize_Params_Data*>( |
| message->mutable_payload()); |
| |
| |
| // Validation for JpegEncodeAccelerator.0 |
| bool success = true; |
| JpegEncodeAccelerator_Initialize_ParamsDataView input_data_view(params, message); |
| |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| JpegEncodeAccelerator::Name_, 0, false); |
| return false; |
| } |
| JpegEncodeAccelerator::InitializeCallback callback = |
| JpegEncodeAccelerator_Initialize_ProxyToResponder::CreateCallback( |
| *message, std::move(responder)); |
| // A null |impl| means no implementation was bound. |
| DCHECK(impl); |
| impl->Initialize(std::move(callback)); |
| return true; |
| } |
| case messages::JpegEncodeAccelerator::kEncodeWithFD: { |
| internal::JpegEncodeAccelerator_EncodeWithFD_Params_Data* params = |
| reinterpret_cast< |
| internal::JpegEncodeAccelerator_EncodeWithFD_Params_Data*>( |
| message->mutable_payload()); |
| |
| |
| // Validation for JpegEncodeAccelerator.1 |
| bool success = true; |
| int32_t p_task_id{}; |
| ::mojo::ScopedHandle p_input_fd{}; |
| uint32_t p_input_buffer_size{}; |
| int32_t p_coded_size_width{}; |
| int32_t p_coded_size_height{}; |
| ::mojo::ScopedHandle p_exif_fd{}; |
| uint32_t p_exif_buffer_size{}; |
| ::mojo::ScopedHandle p_output_fd{}; |
| uint32_t p_output_buffer_size{}; |
| JpegEncodeAccelerator_EncodeWithFD_ParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_task_id = input_data_view.task_id(); |
| if (success) |
| p_input_fd = input_data_view.TakeInputFd(); |
| if (success) |
| p_input_buffer_size = input_data_view.input_buffer_size(); |
| if (success) |
| p_coded_size_width = input_data_view.coded_size_width(); |
| if (success) |
| p_coded_size_height = input_data_view.coded_size_height(); |
| if (success) |
| p_exif_fd = input_data_view.TakeExifFd(); |
| if (success) |
| p_exif_buffer_size = input_data_view.exif_buffer_size(); |
| if (success) |
| p_output_fd = input_data_view.TakeOutputFd(); |
| if (success) |
| p_output_buffer_size = input_data_view.output_buffer_size(); |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| JpegEncodeAccelerator::Name_, 1, false); |
| return false; |
| } |
| JpegEncodeAccelerator::EncodeWithFDCallback callback = |
| JpegEncodeAccelerator_EncodeWithFD_ProxyToResponder::CreateCallback( |
| *message, std::move(responder)); |
| // A null |impl| means no implementation was bound. |
| DCHECK(impl); |
| impl->EncodeWithFD( |
| std::move(p_task_id), |
| std::move(p_input_fd), |
| std::move(p_input_buffer_size), |
| std::move(p_coded_size_width), |
| std::move(p_coded_size_height), |
| std::move(p_exif_fd), |
| std::move(p_exif_buffer_size), |
| std::move(p_output_fd), |
| std::move(p_output_buffer_size), std::move(callback)); |
| return true; |
| } |
| case messages::JpegEncodeAccelerator::kEncodeWithDmaBuf: { |
| internal::JpegEncodeAccelerator_EncodeWithDmaBuf_Params_Data* params = |
| reinterpret_cast< |
| internal::JpegEncodeAccelerator_EncodeWithDmaBuf_Params_Data*>( |
| message->mutable_payload()); |
| |
| |
| // Validation for JpegEncodeAccelerator.2 |
| bool success = true; |
| int32_t p_task_id{}; |
| uint32_t p_input_format{}; |
| std::vector<::cros::mojom::DmaBufPlanePtr> p_input_planes{}; |
| std::vector<::cros::mojom::DmaBufPlanePtr> p_output_planes{}; |
| ::mojo::ScopedHandle p_exif_handle{}; |
| uint32_t p_exif_buffer_size{}; |
| int32_t p_coded_size_width{}; |
| int32_t p_coded_size_height{}; |
| int32_t p_quality{}; |
| bool p_has_input_modifier{}; |
| uint64_t p_input_modifier{}; |
| JpegEncodeAccelerator_EncodeWithDmaBuf_ParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_task_id = input_data_view.task_id(); |
| if (success) |
| p_input_format = input_data_view.input_format(); |
| if (success && !input_data_view.ReadInputPlanes(&p_input_planes)) |
| success = false; |
| if (success && !input_data_view.ReadOutputPlanes(&p_output_planes)) |
| success = false; |
| if (success) |
| p_exif_handle = input_data_view.TakeExifHandle(); |
| if (success) |
| p_exif_buffer_size = input_data_view.exif_buffer_size(); |
| if (success) |
| p_coded_size_width = input_data_view.coded_size_width(); |
| if (success) |
| p_coded_size_height = input_data_view.coded_size_height(); |
| if (success) |
| p_quality = input_data_view.quality(); |
| if (success) |
| p_has_input_modifier = input_data_view.has_input_modifier(); |
| if (success) |
| p_input_modifier = input_data_view.input_modifier(); |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| JpegEncodeAccelerator::Name_, 2, false); |
| return false; |
| } |
| JpegEncodeAccelerator::EncodeWithDmaBufCallback callback = |
| JpegEncodeAccelerator_EncodeWithDmaBuf_ProxyToResponder::CreateCallback( |
| *message, std::move(responder)); |
| // A null |impl| means no implementation was bound. |
| DCHECK(impl); |
| impl->EncodeWithDmaBuf( |
| std::move(p_task_id), |
| std::move(p_input_format), |
| std::move(p_input_planes), |
| std::move(p_output_planes), |
| std::move(p_exif_handle), |
| std::move(p_exif_buffer_size), |
| std::move(p_coded_size_width), |
| std::move(p_coded_size_height), |
| std::move(p_quality), |
| std::move(p_has_input_modifier), |
| std::move(p_input_modifier), std::move(callback)); |
| return true; |
| } |
| } |
| return false; |
| } |
| namespace { |
| } // namespace |
| static const mojo::internal::GenericValidationInfo kJpegEncodeAcceleratorValidationInfo[] = { |
| { &internal::JpegEncodeAccelerator_Initialize_Params_Data::Validate, |
| &internal::JpegEncodeAccelerator_Initialize_ResponseParams_Data::Validate}, |
| { &internal::JpegEncodeAccelerator_EncodeWithFD_Params_Data::Validate, |
| &internal::JpegEncodeAccelerator_EncodeWithFD_ResponseParams_Data::Validate}, |
| { &internal::JpegEncodeAccelerator_EncodeWithDmaBuf_Params_Data::Validate, |
| &internal::JpegEncodeAccelerator_EncodeWithDmaBuf_ResponseParams_Data::Validate}, |
| }; |
| |
| bool JpegEncodeAcceleratorRequestValidator::Accept(mojo::Message* message) { |
| const char* name = ::cros::mojom::JpegEncodeAccelerator::Name_; |
| return mojo::internal::ValidateRequestGenericPacked(message, name, kJpegEncodeAcceleratorValidationInfo); |
| } |
| |
| bool JpegEncodeAcceleratorResponseValidator::Accept(mojo::Message* message) { |
| const char* name = ::cros::mojom::JpegEncodeAccelerator::Name_; |
| return mojo::internal::ValidateResponseGenericPacked(message, name, kJpegEncodeAcceleratorValidationInfo); |
| } |
| |
| |
| } // cros::mojom |
| |
| |
| namespace mojo { |
| |
| } // namespace mojo |
| |
| |
| // Symbols declared in the -test-utils.h header are defined here instead of a |
| // separate .cc file to save compile time. |
| |
| |
| namespace cros::mojom { |
| |
| |
| void JpegEncodeAcceleratorInterceptorForTesting::Initialize(InitializeCallback callback) { |
| GetForwardingInterface()->Initialize(std::move(callback)); |
| } |
| void JpegEncodeAcceleratorInterceptorForTesting::EncodeWithFD(int32_t task_id, ::mojo::ScopedHandle input_fd, uint32_t input_buffer_size, int32_t coded_size_width, int32_t coded_size_height, ::mojo::ScopedHandle exif_fd, uint32_t exif_buffer_size, ::mojo::ScopedHandle output_fd, uint32_t output_buffer_size, EncodeWithFDCallback callback) { |
| GetForwardingInterface()->EncodeWithFD(std::move(task_id), std::move(input_fd), std::move(input_buffer_size), std::move(coded_size_width), std::move(coded_size_height), std::move(exif_fd), std::move(exif_buffer_size), std::move(output_fd), std::move(output_buffer_size), std::move(callback)); |
| } |
| void JpegEncodeAcceleratorInterceptorForTesting::EncodeWithDmaBuf(int32_t task_id, uint32_t input_format, std::vector<::cros::mojom::DmaBufPlanePtr> input_planes, std::vector<::cros::mojom::DmaBufPlanePtr> output_planes, ::mojo::ScopedHandle exif_handle, uint32_t exif_buffer_size, int32_t coded_size_width, int32_t coded_size_height, int32_t quality, bool has_input_modifier, uint64_t input_modifier, EncodeWithDmaBufCallback callback) { |
| GetForwardingInterface()->EncodeWithDmaBuf(std::move(task_id), std::move(input_format), std::move(input_planes), std::move(output_planes), std::move(exif_handle), std::move(exif_buffer_size), std::move(coded_size_width), std::move(coded_size_height), std::move(quality), std::move(has_input_modifier), std::move(input_modifier), std::move(callback)); |
| } |
| JpegEncodeAcceleratorAsyncWaiter::JpegEncodeAcceleratorAsyncWaiter( |
| JpegEncodeAccelerator* proxy) : proxy_(proxy) {} |
| |
| JpegEncodeAcceleratorAsyncWaiter::~JpegEncodeAcceleratorAsyncWaiter() = default; |
| |
| void JpegEncodeAcceleratorAsyncWaiter::Initialize( |
| bool* out_success) { |
| base::RunLoop loop; |
| proxy_->Initialize( |
| base::BindOnce( |
| [](base::RunLoop* loop, |
| bool* out_success |
| , |
| bool success) {*out_success = std::move(success); |
| loop->Quit(); |
| }, |
| &loop, |
| out_success)); |
| loop.Run(); |
| } |
| |
| bool JpegEncodeAcceleratorAsyncWaiter::Initialize( |
| ) { |
| bool async_wait_result; |
| Initialize(&async_wait_result); |
| return async_wait_result; |
| } |
| |
| void JpegEncodeAcceleratorAsyncWaiter::EncodeWithFD( |
| int32_t task_id, ::mojo::ScopedHandle input_fd, uint32_t input_buffer_size, int32_t coded_size_width, int32_t coded_size_height, ::mojo::ScopedHandle exif_fd, uint32_t exif_buffer_size, ::mojo::ScopedHandle output_fd, uint32_t output_buffer_size, int32_t* out_task_id, uint32_t* out_encoded_buffer_size, EncodeStatus* out_status) { |
| base::RunLoop loop; |
| proxy_->EncodeWithFD(std::move(task_id),std::move(input_fd),std::move(input_buffer_size),std::move(coded_size_width),std::move(coded_size_height),std::move(exif_fd),std::move(exif_buffer_size),std::move(output_fd),std::move(output_buffer_size), |
| base::BindOnce( |
| [](base::RunLoop* loop, |
| int32_t* out_task_id |
| , |
| uint32_t* out_encoded_buffer_size |
| , |
| EncodeStatus* out_status |
| , |
| int32_t task_id, |
| uint32_t encoded_buffer_size, |
| EncodeStatus status) {*out_task_id = std::move(task_id);*out_encoded_buffer_size = std::move(encoded_buffer_size);*out_status = std::move(status); |
| loop->Quit(); |
| }, |
| &loop, |
| out_task_id, |
| out_encoded_buffer_size, |
| out_status)); |
| loop.Run(); |
| } |
| |
| |
| |
| void JpegEncodeAcceleratorAsyncWaiter::EncodeWithDmaBuf( |
| int32_t task_id, uint32_t input_format, std::vector<::cros::mojom::DmaBufPlanePtr> input_planes, std::vector<::cros::mojom::DmaBufPlanePtr> output_planes, ::mojo::ScopedHandle exif_handle, uint32_t exif_buffer_size, int32_t coded_size_width, int32_t coded_size_height, int32_t quality, bool has_input_modifier, uint64_t input_modifier, uint32_t* out_encoded_buffer_size, EncodeStatus* out_status) { |
| base::RunLoop loop; |
| proxy_->EncodeWithDmaBuf(std::move(task_id),std::move(input_format),std::move(input_planes),std::move(output_planes),std::move(exif_handle),std::move(exif_buffer_size),std::move(coded_size_width),std::move(coded_size_height),std::move(quality),std::move(has_input_modifier),std::move(input_modifier), |
| base::BindOnce( |
| [](base::RunLoop* loop, |
| uint32_t* out_encoded_buffer_size |
| , |
| EncodeStatus* out_status |
| , |
| uint32_t encoded_buffer_size, |
| EncodeStatus status) {*out_encoded_buffer_size = std::move(encoded_buffer_size);*out_status = std::move(status); |
| loop->Quit(); |
| }, |
| &loop, |
| out_encoded_buffer_size, |
| out_status)); |
| loop.Run(); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| } // cros::mojom |
| |
| |
| #if defined(__clang__) |
| #pragma clang diagnostic pop |
| #endif |