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