1 // Copyright 2018 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_NATIVE_PIXMAP_EGL_H_
6 #define MEDIA_GPU_VAAPI_VAAPI_PICTURE_NATIVE_PIXMAP_EGL_H_
7 
8 #include <stdint.h>
9 
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "media/gpu/vaapi/vaapi_picture_native_pixmap.h"
14 #include "ui/gfx/buffer_types.h"
15 #include "ui/gfx/geometry/size.h"
16 
17 namespace gfx {
18 class NativePixmap;
19 }  // namespace gfx
20 
21 namespace media {
22 
23 class VaapiWrapper;
24 
25 // Implementation of VaapiPictureNativePixmap for EGL backends, see
26 // https://crbug.com/785201.
27 class VaapiPictureNativePixmapEgl : public VaapiPictureNativePixmap {
28  public:
29   VaapiPictureNativePixmapEgl(
30       scoped_refptr<VaapiWrapper> vaapi_wrapper,
31       const MakeGLContextCurrentCallback& make_context_current_cb,
32       const BindGLImageCallback& bind_image_cb_,
33       int32_t picture_buffer_id,
34       const gfx::Size& size,
35       const gfx::Size& visible_size,
36       uint32_t texture_id,
37       uint32_t client_texture_id,
38       uint32_t texture_target);
39 
40   ~VaapiPictureNativePixmapEgl() override;
41 
42   // VaapiPicture implementation.
43   bool Allocate(gfx::BufferFormat format) override;
44   bool ImportGpuMemoryBufferHandle(
45       gfx::BufferFormat format,
46       gfx::GpuMemoryBufferHandle gpu_memory_buffer_handle) override;
47 
48  private:
49   bool Initialize(scoped_refptr<gfx::NativePixmap> pixmap);
50 
51   DISALLOW_COPY_AND_ASSIGN(VaapiPictureNativePixmapEgl);
52 };
53 
54 }  // namespace media
55 
56 #endif  // MEDIA_GPU_VAAPI_VAAPI_PICTURE_NATIVE_PIXMAP_EGL_H_
57