| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This file contains an implementation of picture allocation for the | 5 // This file contains an implementation of picture allocation for the |
| 6 // Ozone window system used by VaapiVideoDecodeAccelerator to produce | 6 // Ozone window system used by VaapiVideoDecodeAccelerator to produce |
| 7 // output pictures. | 7 // output pictures. |
| 8 | 8 |
| 9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_ | 9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_ |
| 10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_ | 10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_ |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "content/common/gpu/media/vaapi_picture.h" | 15 #include "content/common/gpu/media/vaapi_picture.h" |
| 16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gl { |
| 19 class GLImage; | 19 class GLImage; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace ui { | 22 namespace ui { |
| 23 class NativePixmap; | 23 class NativePixmap; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 28 class VaapiWrapper; | 28 class VaapiWrapper; |
| 29 | 29 |
| 30 // Implementation of VaapiPicture for the ozone/drm backed chromium. | 30 // Implementation of VaapiPicture for the ozone/drm backed chromium. |
| 31 class VaapiDrmPicture : public VaapiPicture { | 31 class VaapiDrmPicture : public VaapiPicture { |
| 32 public: | 32 public: |
| 33 VaapiDrmPicture(VaapiWrapper* vaapi_wrapper, | 33 VaapiDrmPicture(VaapiWrapper* vaapi_wrapper, |
| 34 const base::Callback<bool(void)>& make_context_current, | 34 const base::Callback<bool(void)>& make_context_current, |
| 35 int32 picture_buffer_id, | 35 int32 picture_buffer_id, |
| 36 uint32 texture_id, | 36 uint32 texture_id, |
| 37 const gfx::Size& size); | 37 const gfx::Size& size); |
| 38 | 38 |
| 39 ~VaapiDrmPicture() override; | 39 ~VaapiDrmPicture() override; |
| 40 | 40 |
| 41 bool Initialize() override; | 41 bool Initialize() override; |
| 42 | 42 |
| 43 bool DownloadFromSurface(const scoped_refptr<VASurface>& va_surface) override; | 43 bool DownloadFromSurface(const scoped_refptr<VASurface>& va_surface) override; |
| 44 | 44 |
| 45 scoped_refptr<gfx::GLImage> GetImageToBind() override; | 45 scoped_refptr<gl::GLImage> GetImageToBind() override; |
| 46 | 46 |
| 47 bool AllowOverlay() const override; | 47 bool AllowOverlay() const override; |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 // Calls ScalePixmap() if weak_ptr is not NULL. | 50 // Calls ScalePixmap() if weak_ptr is not NULL. |
| 51 static scoped_refptr<ui::NativePixmap> CallScalePixmap( | 51 static scoped_refptr<ui::NativePixmap> CallScalePixmap( |
| 52 base::WeakPtr<VaapiDrmPicture> weak_ptr, | 52 base::WeakPtr<VaapiDrmPicture> weak_ptr, |
| 53 gfx::Size new_size); | 53 gfx::Size new_size); |
| 54 // Use VPP to scale underlying pixmap_ to |new_size| and return the | 54 // Use VPP to scale underlying pixmap_ to |new_size| and return the |
| 55 // scaling result with a new pixmap. | 55 // scaling result with a new pixmap. |
| 56 scoped_refptr<ui::NativePixmap> ScalePixmap(gfx::Size new_size); | 56 scoped_refptr<ui::NativePixmap> ScalePixmap(gfx::Size new_size); |
| 57 scoped_refptr<VASurface> CreateVASurfaceForPixmap( | 57 scoped_refptr<VASurface> CreateVASurfaceForPixmap( |
| 58 scoped_refptr<ui::NativePixmap> pixmap, | 58 scoped_refptr<ui::NativePixmap> pixmap, |
| 59 gfx::Size pixmap_size); | 59 gfx::Size pixmap_size); |
| 60 scoped_refptr<ui::NativePixmap> CreateNativePixmap(gfx::Size size); | 60 scoped_refptr<ui::NativePixmap> CreateNativePixmap(gfx::Size size); |
| 61 | 61 |
| 62 VaapiWrapper* vaapi_wrapper_; // Not owned. | 62 VaapiWrapper* vaapi_wrapper_; // Not owned. |
| 63 base::Callback<bool(void)> make_context_current_; | 63 base::Callback<bool(void)> make_context_current_; |
| 64 | 64 |
| 65 // Ozone buffer, the storage of the EGLImage and the VASurface. | 65 // Ozone buffer, the storage of the EGLImage and the VASurface. |
| 66 scoped_refptr<ui::NativePixmap> pixmap_; | 66 scoped_refptr<ui::NativePixmap> pixmap_; |
| 67 | 67 |
| 68 // Ozone buffer, the storage of the scaled buffer for overlay. | 68 // Ozone buffer, the storage of the scaled buffer for overlay. |
| 69 scoped_refptr<ui::NativePixmap> scaled_pixmap_; | 69 scoped_refptr<ui::NativePixmap> scaled_pixmap_; |
| 70 | 70 |
| 71 // EGLImage bound to the GL textures used by the VDA client. | 71 // EGLImage bound to the GL textures used by the VDA client. |
| 72 scoped_refptr<gfx::GLImage> gl_image_; | 72 scoped_refptr<gl::GLImage> gl_image_; |
| 73 | 73 |
| 74 // VASurface used to transfer from the decoder's pixel format. | 74 // VASurface used to transfer from the decoder's pixel format. |
| 75 scoped_refptr<VASurface> va_surface_; | 75 scoped_refptr<VASurface> va_surface_; |
| 76 | 76 |
| 77 // VaSurface used to apply scaling. | 77 // VaSurface used to apply scaling. |
| 78 scoped_refptr<VASurface> scaled_va_surface_; | 78 scoped_refptr<VASurface> scaled_va_surface_; |
| 79 | 79 |
| 80 // The WeakPtrFactory for VaapiDrmPicture. | 80 // The WeakPtrFactory for VaapiDrmPicture. |
| 81 base::WeakPtrFactory<VaapiDrmPicture> weak_this_factory_; | 81 base::WeakPtrFactory<VaapiDrmPicture> weak_this_factory_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(VaapiDrmPicture); | 83 DISALLOW_COPY_AND_ASSIGN(VaapiDrmPicture); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 } // namespace content | 86 } // namespace content |
| 87 | 87 |
| 88 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_ | 88 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_ |
| OLD | NEW |