Commit 957c5c2a authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

vaapi: extract vaCreateContext() to its own method in VaapiWrapper

This CL extracts the call to vaCreateContext() out of VaapiWrapper's
CreateSurfaces() and into a new method VaapiWrapper::CreateContext().

The former still calls the latter, but this change allows for separating
the allocation of the surfaces from the creation of the context. In
particular, this is needed for decoding directly on client Surfaces
(see the bug and/or the experimental CL crrev.com/c/986353. from
which this code is separated).

Bug: 822346
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I37f28d2a0fe939264d3153f34bd25bbc6c77ba79
Reviewed-on: https://chromium-review.googlesource.com/995623Reviewed-by: default avatarKristian H. Kristensen <hoegsberg@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548515}
parent 8d662f5e
...@@ -746,19 +746,25 @@ bool VaapiWrapper::CreateSurfaces(unsigned int va_format, ...@@ -746,19 +746,25 @@ bool VaapiWrapper::CreateSurfaces(unsigned int va_format,
} }
// And create a context associated with them. // And create a context associated with them.
va_res = vaCreateContext(va_display_, va_config_id_, size.width(), const bool success = CreateContext(va_format, size, va_surface_ids_);
size.height(), VA_PROGRESSIVE, &va_surface_ids_[0], if (success)
va_surface_ids_.size(), &va_context_id_); *va_surfaces = va_surface_ids_;
else
VA_LOG_ON_ERROR(va_res, "vaCreateContext failed");
if (va_res != VA_STATUS_SUCCESS) {
DestroySurfaces_Locked(); DestroySurfaces_Locked();
return false; return success;
} }
*va_surfaces = va_surface_ids_; bool VaapiWrapper::CreateContext(unsigned int va_format,
va_surface_format_ = va_format; const gfx::Size& size,
return true; const std::vector<VASurfaceID>& va_surfaces) {
VAStatus va_res = vaCreateContext(
va_display_, va_config_id_, size.width(), size.height(), VA_PROGRESSIVE,
&va_surface_ids_[0], va_surface_ids_.size(), &va_context_id_);
VA_LOG_ON_ERROR(va_res, "vaCreateContext failed");
if (va_res == VA_STATUS_SUCCESS)
va_surface_format_ = va_format;
return va_res == VA_STATUS_SUCCESS;
} }
void VaapiWrapper::DestroySurfaces() { void VaapiWrapper::DestroySurfaces() {
......
...@@ -89,7 +89,7 @@ class MEDIA_GPU_EXPORT VaapiWrapper ...@@ -89,7 +89,7 @@ class MEDIA_GPU_EXPORT VaapiWrapper
// Return true when JPEG encode is supported. // Return true when JPEG encode is supported.
static bool IsJpegEncodeSupported(); static bool IsJpegEncodeSupported();
// Create |num_surfaces| backing surfaces in driver for VASurfaces of // Creates |num_surfaces| backing surfaces in driver for VASurfaces of
// |va_format|, each of size |size|. Returns true when successful, with the // |va_format|, each of size |size|. Returns true when successful, with the
// created IDs in |va_surfaces| to be managed and later wrapped in // created IDs in |va_surfaces| to be managed and later wrapped in
// VASurfaces. // VASurfaces.
...@@ -102,7 +102,12 @@ class MEDIA_GPU_EXPORT VaapiWrapper ...@@ -102,7 +102,12 @@ class MEDIA_GPU_EXPORT VaapiWrapper
size_t num_surfaces, size_t num_surfaces,
std::vector<VASurfaceID>* va_surfaces); std::vector<VASurfaceID>* va_surfaces);
// Free all memory allocated in CreateSurfaces. // Creates a VA Context associated with the set of |va_surfaces| of |size|.
bool CreateContext(unsigned int va_format,
const gfx::Size& size,
const std::vector<VASurfaceID>& va_surfaces);
// Frees all memory allocated in CreateSurfaces.
virtual void DestroySurfaces(); virtual void DestroySurfaces();
// Create a VASurface for |pixmap|. The ownership of the surface is // Create a VASurface for |pixmap|. The ownership of the surface is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment