image_processor_backend.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Copyright 2019 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. #include "media/gpu/chromeos/image_processor_backend.h"
  5. #include <memory>
  6. #include <ostream>
  7. #include <sstream>
  8. #include "base/bind.h"
  9. #include "base/strings/stringprintf.h"
  10. #include "base/task/task_traits.h"
  11. #include "media/gpu/macros.h"
  12. namespace media {
  13. namespace {
  14. template <class T>
  15. std::string VectorToString(const std::vector<T>& vec) {
  16. std::ostringstream result;
  17. std::string delim;
  18. result << "[";
  19. for (const T& v : vec) {
  20. result << delim << v;
  21. if (delim.size() == 0)
  22. delim = ", ";
  23. }
  24. result << "]";
  25. return result.str();
  26. }
  27. } // namespace
  28. ImageProcessorBackend::PortConfig::PortConfig(const PortConfig&) = default;
  29. ImageProcessorBackend::PortConfig::PortConfig(
  30. Fourcc fourcc,
  31. const gfx::Size& size,
  32. const std::vector<ColorPlaneLayout>& planes,
  33. const gfx::Rect& visible_rect,
  34. const std::vector<VideoFrame::StorageType>& preferred_storage_types)
  35. : fourcc(fourcc),
  36. size(size),
  37. planes(planes),
  38. visible_rect(visible_rect),
  39. preferred_storage_types(preferred_storage_types) {}
  40. ImageProcessorBackend::PortConfig::~PortConfig() = default;
  41. std::string ImageProcessorBackend::PortConfig::ToString() const {
  42. return base::StringPrintf(
  43. "PortConfig(format:%s, size:%s, planes: %s, visible_rect:%s, "
  44. "storage_types:%s)",
  45. fourcc.ToString().c_str(), size.ToString().c_str(),
  46. VectorToString(planes).c_str(), visible_rect.ToString().c_str(),
  47. VectorToString(preferred_storage_types).c_str());
  48. }
  49. ImageProcessorBackend::ImageProcessorBackend(
  50. const PortConfig& input_config,
  51. const PortConfig& output_config,
  52. OutputMode output_mode,
  53. VideoRotation relative_rotation,
  54. ErrorCB error_cb,
  55. scoped_refptr<base::SequencedTaskRunner> backend_task_runner)
  56. : input_config_(input_config),
  57. output_config_(output_config),
  58. output_mode_(output_mode),
  59. relative_rotation_(relative_rotation),
  60. error_cb_(error_cb),
  61. backend_task_runner_(std::move(backend_task_runner)) {
  62. DETACH_FROM_SEQUENCE(backend_sequence_checker_);
  63. }
  64. ImageProcessorBackend::~ImageProcessorBackend() = default;
  65. void ImageProcessorBackend::Destroy() {
  66. DCHECK_CALLED_ON_VALID_SEQUENCE(backend_sequence_checker_);
  67. delete this;
  68. }
  69. void ImageProcessorBackend::ProcessLegacy(scoped_refptr<VideoFrame> frame,
  70. LegacyFrameReadyCB cb) {
  71. DCHECK_CALLED_ON_VALID_SEQUENCE(backend_sequence_checker_);
  72. NOTIMPLEMENTED();
  73. }
  74. void ImageProcessorBackend::Reset() {
  75. DVLOGF(3);
  76. DCHECK_CALLED_ON_VALID_SEQUENCE(backend_sequence_checker_);
  77. // Do nothing as the default action.
  78. }
  79. bool ImageProcessorBackend::needs_linear_output_buffers() const {
  80. return false;
  81. }
  82. bool ImageProcessorBackend::supports_incoherent_buffers() const {
  83. return false;
  84. }
  85. } // namespace media
  86. namespace std {
  87. void default_delete<media::ImageProcessorBackend>::operator()(
  88. media::ImageProcessorBackend* ptr) const {
  89. ptr->Destroy();
  90. }
  91. } // namespace std