Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce invariants based on VASurfaceID.
Create a FakeSurface class to keep track of surfaces that have been created. FakeDriver stores an ObjectTracker<FakeSurface> to keep track of all created FakeSurfaces. Ensure that all methods that require valid VASurfaceIDs check if a FakeSurface class with a corresponding ID exists. Implement functionality in the fake driver to create and destroy these FakeSurface objects. Change-Id: I52fc6d26b85f4ec1bab3db90e8600ee7ffbdd54f Bug: b:260845551 Test: LIBVA_DRIVERS_PATH=./{buildpath} LIBVA_DRIVER_NAME=libfake ./{buildpath}/fake_libva_driver_unittest Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4060623 Commit-Queue: Grayson LaFleur <graysonlafleur@google.com> Reviewed-by: Andres Calderon Jaramillo <andrescj@chromium.org> Reviewed-by: Pilar Molina Lopez <pmolinalopez@google.com> Reviewed-by: Pilar Molina Lopez <pmolinalopez@chromium.org> Cr-Commit-Position: refs/heads/main@{#1084513}
- Loading branch information
Grayson LaFleur
authored and
Chromium LUCI CQ
committed
Dec 16, 2022
1 parent
18466ed
commit d3915a7
Showing
6 changed files
with
189 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "media/gpu/vaapi/test/fake_libva_driver/fake_surface.h" | ||
|
||
namespace media::internal { | ||
|
||
FakeSurface::FakeSurface(FakeSurface::IdType id, | ||
unsigned int format, | ||
unsigned int width, | ||
unsigned int height, | ||
std::vector<VASurfaceAttrib> attrib_list) | ||
: id_(id), | ||
format_(format), | ||
width_(width), | ||
height_(height), | ||
attrib_list_(std::move(attrib_list)) {} | ||
FakeSurface::~FakeSurface() = default; | ||
|
||
FakeSurface::IdType FakeSurface::GetID() const { | ||
return id_; | ||
} | ||
|
||
unsigned int FakeSurface::GetFormat() const { | ||
return format_; | ||
} | ||
|
||
unsigned int FakeSurface::GetWidth() const { | ||
return width_; | ||
} | ||
|
||
unsigned int FakeSurface::GetHeight() const { | ||
return height_; | ||
} | ||
|
||
const std::vector<VASurfaceAttrib>& FakeSurface::GetSurfaceAttribs() const { | ||
return attrib_list_; | ||
} | ||
|
||
} // namespace media::internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef MEDIA_GPU_VAAPI_TEST_FAKE_LIBVA_DRIVER_FAKE_SURFACE_H_ | ||
#define MEDIA_GPU_VAAPI_TEST_FAKE_LIBVA_DRIVER_FAKE_SURFACE_H_ | ||
|
||
#include <va/va.h> | ||
|
||
#include <vector> | ||
|
||
namespace media::internal { | ||
|
||
// Class used for tracking a VASurface and all information relevant to it. | ||
// All objects of this class are immutable and thread safe. | ||
class FakeSurface { | ||
public: | ||
using IdType = VASurfaceID; | ||
|
||
FakeSurface(IdType id, | ||
unsigned int format, | ||
unsigned int width, | ||
unsigned int height, | ||
std::vector<VASurfaceAttrib> attrib_list); | ||
FakeSurface(const FakeSurface&) = delete; | ||
FakeSurface& operator=(const FakeSurface&) = delete; | ||
~FakeSurface(); | ||
|
||
IdType GetID() const; | ||
unsigned int GetFormat() const; | ||
unsigned int GetWidth() const; | ||
unsigned int GetHeight() const; | ||
const std::vector<VASurfaceAttrib>& GetSurfaceAttribs() const; | ||
|
||
private: | ||
const IdType id_; | ||
const unsigned int format_; | ||
const unsigned int width_; | ||
const unsigned int height_; | ||
const std::vector<VASurfaceAttrib> attrib_list_; | ||
}; | ||
|
||
} // namespace media::internal | ||
|
||
#endif // MEDIA_GPU_VAAPI_TEST_FAKE_LIBVA_DRIVER_FAKE_SURFACE_H_ |