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
3 // found in the LICENSE file.
5 // This file contains an implementation of picture allocation for the
6 // Ozone window system used by VaapiVideoDecodeAccelerator to produce
9 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_
10 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "content/common/gpu/media/vaapi_picture.h"
16 #include "ui/gfx/geometry/size.h"
30 // Implementation of VaapiPicture for the ozone/drm backed chromium.
31 class VaapiDrmPicture
: public VaapiPicture
{
33 VaapiDrmPicture(VaapiWrapper
* vaapi_wrapper
,
34 const base::Callback
<bool(void)>& make_context_current
,
35 int32 picture_buffer_id
,
37 const gfx::Size
& size
);
39 ~VaapiDrmPicture() override
;
41 bool Initialize() override
;
43 bool DownloadFromSurface(const scoped_refptr
<VASurface
>& va_surface
) override
;
45 scoped_refptr
<gfx::GLImage
> GetImageToBind() override
;
47 bool AllowOverlay() const override
;
50 // Calls ScalePixmap() if weak_ptr is not NULL.
51 static scoped_refptr
<ui::NativePixmap
> CallScalePixmap(
52 base::WeakPtr
<VaapiDrmPicture
> weak_ptr
,
54 // Use VPP to scale underlying pixmap_ to |new_size| and return the
55 // scaling result with a new pixmap.
56 scoped_refptr
<ui::NativePixmap
> ScalePixmap(gfx::Size new_size
);
57 scoped_refptr
<VASurface
> CreateVASurfaceForPixmap(
58 scoped_refptr
<ui::NativePixmap
> pixmap
,
59 gfx::Size pixmap_size
);
60 scoped_refptr
<ui::NativePixmap
> CreateNativePixmap(gfx::Size size
);
62 VaapiWrapper
* vaapi_wrapper_
; // Not owned.
63 base::Callback
<bool(void)> make_context_current_
;
65 // Ozone buffer, the storage of the EGLImage and the VASurface.
66 scoped_refptr
<ui::NativePixmap
> pixmap_
;
68 // Ozone buffer, the storage of the scaled buffer for overlay.
69 scoped_refptr
<ui::NativePixmap
> scaled_pixmap_
;
71 // EGLImage bound to the GL textures used by the VDA client.
72 scoped_refptr
<gfx::GLImage
> gl_image_
;
74 // VASurface used to transfer from the decoder's pixel format.
75 scoped_refptr
<VASurface
> va_surface_
;
77 // VaSurface used to apply scaling.
78 scoped_refptr
<VASurface
> scaled_va_surface_
;
80 // The WeakPtrFactory for VaapiDrmPicture.
81 base::WeakPtrFactory
<VaapiDrmPicture
> weak_this_factory_
;
83 DISALLOW_COPY_AND_ASSIGN(VaapiDrmPicture
);
86 } // namespace content
88 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_DRM_PICTURE_H_