Index: content/common/gpu/media/vaapi_picture_provider.h |
diff --git a/content/common/gpu/media/vaapi_picture_provider.h b/content/common/gpu/media/vaapi_picture_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..26261ab9677477330e157922c152d9f70be8ed19 |
--- /dev/null |
+++ b/content/common/gpu/media/vaapi_picture_provider.h |
@@ -0,0 +1,98 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+// |
+// This file contains an implementation of picture allocation for |
+// different window system (X11/Ozone) used by |
+// VaapiVideoDecodeAccelerator to produce output pictures. |
+ |
+#ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_PROVIDER_H_ |
+#define CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_PROVIDER_H_ |
+ |
+#include "base/callback.h" |
+#include "base/memory/linked_ptr.h" |
+#include "base/threading/non_thread_safe.h" |
+#include "third_party/libva/va/va.h" |
+#include "ui/gfx/size.h" |
+ |
+namespace gfx { |
+class GLContext; |
+} // namespace gfx |
+ |
+namespace content { |
+ |
+class VaapiWrapper; |
+ |
+// VaapiPictureProvider is in charge of allocating pictures for the |
+// window system and binding them to gl textures. |
+class VaapiPictureProvider : public base::NonThreadSafe { |
Pawel Osciak
2014/11/03 01:36:51
Both VaapiWrapper and MakeContextCurrent are now o
llandwerlin-old
2014/11/03 09:30:11
The creation of pictures is fairly different betwe
|
+ public: |
+ // Picture is native pixmap abstraction (X11/Ozone) |
Pawel Osciak
2014/11/03 01:36:51
Please full stop at the end of sentences.
llandwerlin-old
2014/11/03 09:30:11
Acknowledged.
|
+ class Picture : public base::NonThreadSafe { |
+ public: |
+ virtual ~Picture() {} |
+ |
+ // Try to allocate the underlying resources for the picture. |
+ virtual bool Initialize() = 0; |
+ |
+ int32 picture_buffer_id() const { return picture_buffer_id_; } |
+ uint32 texture_id() const { return texture_id_; } |
+ const gfx::Size& size() const { return size_; } |
+ |
+ // Downloads the |va_surface_id| of size |surface_size| into the |
+ // picture, potentially scaling it if needed. |
+ virtual bool DownloadFromSurface(VASurfaceID va_surface_id, |
Pawel Osciak
2014/11/03 01:36:51
Could we use VASurface? We wounldn't need size the
llandwerlin-old
2014/11/03 09:30:11
Acknowledged.
|
+ const gfx::Size& surface_size) = 0; |
+ |
+ protected: |
+ Picture(int32 picture_buffer_id, uint32 texture_id, const gfx::Size& size) |
+ : picture_buffer_id_(picture_buffer_id), |
+ texture_id_(texture_id), |
+ size_(size) {} |
+ |
+ private: |
+ int32 picture_buffer_id_; |
+ uint32 texture_id_; |
+ gfx::Size size_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Picture); |
+ }; |
+ |
+ virtual ~VaapiPictureProvider(); |
+ |
+ // Create an RGBA picture of |size| and allocate all necessary |
+ // underlying buffers and associate it to the given gl |texture_id| |
+ // and |picture_buffer_id|. |
+ linked_ptr<Picture> CreatePicture(int32 picture_buffer_id, |
+ uint32 texture_id, |
+ const gfx::Size& size); |
+ |
+ // Create a platform specific picture provider. |vaapi_wrapper| will |
+ // be used to make libVA calls and |gl_context| and |
+ // |make_context_current| will be used to bind/unbind picture to gl |
+ // textures. |
+ static scoped_ptr<VaapiPictureProvider> Create( |
+ scoped_refptr<VaapiWrapper> vaapi_wrapper, |
+ gfx::GLContext* gl_context, |
+ const base::Callback<bool(void)> make_context_current); |
+ |
+ protected: |
+ VaapiPictureProvider(); |
+ |
+ // Allocates a picture of |size| without actually creating the |
+ // underlying buffer and associate it to the given gl |texture_id| |
+ // and |picture_buffer_id|. |
+ virtual linked_ptr<Picture> AllocatePicture(int32 picture_buffer_id, |
+ uint32 texture_id, |
+ const gfx::Size& size) = 0; |
+ |
+ private: |
+ // Initialize the picture provider. |
+ virtual bool Initialize() = 0; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(VaapiPictureProvider); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_PICTURE_PROVIDER_H_ |