vaapi_picture_factory.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright 2017 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. #ifndef MEDIA_GPU_VAAPI_VAAPI_PICTURE_FACTORY_H_
  5. #define MEDIA_GPU_VAAPI_VAAPI_PICTURE_FACTORY_H_
  6. #include <stdint.h>
  7. #include "base/memory/ref_counted.h"
  8. #include "media/gpu/vaapi/vaapi_picture.h"
  9. #include "ui/gfx/geometry/size.h"
  10. #include "ui/gl/gl_implementation.h"
  11. namespace media {
  12. class PictureBuffer;
  13. class VaapiWrapper;
  14. using CreatePictureCB = base::RepeatingCallback<std::unique_ptr<VaapiPicture>(
  15. scoped_refptr<VaapiWrapper>,
  16. const MakeGLContextCurrentCallback&,
  17. const BindGLImageCallback&,
  18. const PictureBuffer&,
  19. const gfx::Size&,
  20. uint32_t,
  21. uint32_t)>;
  22. // Factory of platform dependent VaapiPictures.
  23. class MEDIA_GPU_EXPORT VaapiPictureFactory {
  24. public:
  25. enum VaapiImplementation {
  26. kVaapiImplementationNone = 0,
  27. kVaapiImplementationDrm,
  28. kVaapiImplementationX11,
  29. kVaapiImplementationAngle,
  30. };
  31. VaapiPictureFactory();
  32. VaapiPictureFactory(const VaapiPictureFactory&) = delete;
  33. VaapiPictureFactory& operator=(const VaapiPictureFactory&) = delete;
  34. virtual ~VaapiPictureFactory();
  35. // Creates a VaapiPicture of picture_buffer.size() associated with
  36. // picture_buffer.id().
  37. virtual std::unique_ptr<VaapiPicture> Create(
  38. scoped_refptr<VaapiWrapper> vaapi_wrapper,
  39. const MakeGLContextCurrentCallback& make_context_current_cb,
  40. const BindGLImageCallback& bind_image_cb,
  41. const PictureBuffer& picture_buffer,
  42. const gfx::Size& visible_size);
  43. // Return the type of the VaapiPicture implementation for the given GL
  44. // implementation.
  45. VaapiImplementation GetVaapiImplementation(gl::GLImplementation gl_impl);
  46. // Determines whether the DownloadFromSurface() method of the VaapiPictures
  47. // created by this factory requires a processing pipeline VaapiWrapper.
  48. bool NeedsProcessingPipelineForDownloading() const;
  49. // Gets the texture target used to bind EGLImages (either GL_TEXTURE_2D on X11
  50. // or GL_TEXTURE_EXTERNAL_OES on DRM).
  51. uint32_t GetGLTextureTarget();
  52. // Buffer format to use for output buffers backing PictureBuffers. This is
  53. // the format decoded frames in VASurfaces are converted into.
  54. gfx::BufferFormat GetBufferFormat();
  55. std::unique_ptr<VaapiPicture> CreateVaapiPictureNative(
  56. scoped_refptr<VaapiWrapper> vaapi_wrapper,
  57. const MakeGLContextCurrentCallback& make_context_current_cb,
  58. const BindGLImageCallback& bind_image_cb,
  59. const PictureBuffer& picture_buffer,
  60. const gfx::Size& visible_size,
  61. uint32_t client_texture_id,
  62. uint32_t service_texture_id);
  63. std::map<gl::GLImplementation, VaapiPictureFactory::VaapiImplementation>
  64. vaapi_impl_pairs_;
  65. private:
  66. void DeterminePictureCreationAndDownloadingMechanism();
  67. CreatePictureCB create_picture_cb_;
  68. bool needs_vpp_for_downloading_ = false;
  69. };
  70. } // namespace media
  71. #endif // MEDIA_GPU_VAAPI_VAAPI_PICTURE_FACTORY_H_