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 interface of output pictures for the Vaapi
6 // video decoder. This is implemented by different window system
7 // (X11/Ozone) and used by VaapiVideoDecodeAccelerator to produce
10 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_
11 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_
13 #include "base/callback.h"
14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/threading/non_thread_safe.h"
17 #include "ui/gfx/geometry/size.h"
28 // Picture is native pixmap abstraction (X11/Ozone).
29 class VaapiPicture
: public base::NonThreadSafe
{
31 virtual ~VaapiPicture() {}
33 // Try to allocate the underlying resources for the picture.
34 virtual bool Initialize() = 0;
36 int32
picture_buffer_id() const { return picture_buffer_id_
; }
37 uint32
texture_id() const { return texture_id_
; }
38 const gfx::Size
& size() const { return size_
; }
40 virtual bool AllowOverlay() const;
42 // Returns the |GLImage|, if any, to bind to the texture.
43 virtual scoped_refptr
<gfx::GLImage
> GetImageToBind() = 0;
45 // Downloads the |va_surface| into the picture, potentially scaling
47 virtual bool DownloadFromSurface(
48 const scoped_refptr
<VASurface
>& va_surface
) = 0;
50 // Create a VaapiPicture of |size| to be associated with
51 // |picture_buffer_id| and bound to |texture_id|.
52 // |make_context_current| is provided for the GL operations.
53 static linked_ptr
<VaapiPicture
> CreatePicture(
54 VaapiWrapper
* vaapi_wrapper
,
55 const base::Callback
<bool(void)> make_context_current
,
56 int32 picture_buffer_id
,
58 const gfx::Size
& size
);
60 // Get the texture target used to bind EGLImages (either
61 // GL_TEXTURE_2D on X11 or GL_TEXTURE_EXTERNAL_OES on DRM).
62 static uint32
GetGLTextureTarget();
65 VaapiPicture(int32 picture_buffer_id
,
67 const gfx::Size
& size
)
68 : picture_buffer_id_(picture_buffer_id
),
69 texture_id_(texture_id
),
73 int32 picture_buffer_id_
;
77 DISALLOW_COPY_AND_ASSIGN(VaapiPicture
);
80 } // namespace content
82 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_H_