Commit d30df395 authored by Miguel Casas-Sanchez's avatar Miguel Casas-Sanchez Committed by Commit Bot

vaapi: minor style cleanup of inner classes

This CL updates code in a few locations in vaapi_decode_accelerator.cc:
- inlines the ctor and emtpy destructor of Vaapi{H264,VP8,VP9}Picture
 because, since they're in a .cc file anyway, separating declaration
 and definition is unnecessary.
- makes some members const in VaapiDecodeSurface.
- makes ctors explicit and uses scoped_refptr (and not const&), see
[1] and the discussion in [2]:

"If the function (at least sometimes) takes a ref on a refcounted
object, declare the param as scoped_refptr<T>. The caller can
decide whether it wishes to transfer ownership (by calling
std::move(t) when passing t) or retain its ref (by simply passing
t directly)."
"A great deal of Chromium code predates the above rules. In
particular, some functions take ownership of params passed as T*,
or take const scoped_refptr<T>& instead of T*, [...]. Try to clean
up such code when you find it"

[1] https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#object-ownership-and-calling-conventions
[2] https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/TlL1D-Djta0

TEST= **No new code intended**. Compiled simplechrome and
loaded on Soraka, then played videos making sure (via
chrome://media-internals) that GpuVideoDecoder was used.


Bug: 717265
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I6006fb23325d23841c8613fa41d65f8707a5446c
Reviewed-on: https://chromium-review.googlesource.com/746369Reviewed-by: default avatarKuang-che Wu <kcwu@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513108}
parent ac270dea
......@@ -95,8 +95,8 @@ class VaapiVideoDecodeAccelerator::VaapiDecodeSurface
friend class base::RefCountedThreadSafe<VaapiDecodeSurface>;
~VaapiDecodeSurface();
int32_t bitstream_id_;
scoped_refptr<VASurface> va_surface_;
const int32_t bitstream_id_;
const scoped_refptr<VASurface> va_surface_;
gfx::Rect visible_rect_;
};
......@@ -109,9 +109,9 @@ VaapiVideoDecodeAccelerator::VaapiDecodeSurface::~VaapiDecodeSurface() {}
class VaapiH264Picture : public H264Picture {
public:
VaapiH264Picture(
const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
dec_surface);
explicit VaapiH264Picture(
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> surface)
: dec_surface_(surface) {}
VaapiH264Picture* AsVaapiH264Picture() override { return this; }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface() {
......@@ -119,20 +119,13 @@ class VaapiH264Picture : public H264Picture {
}
private:
~VaapiH264Picture() override;
~VaapiH264Picture() override {}
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface_;
DISALLOW_COPY_AND_ASSIGN(VaapiH264Picture);
};
VaapiH264Picture::VaapiH264Picture(
const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
dec_surface)
: dec_surface_(dec_surface) {}
VaapiH264Picture::~VaapiH264Picture() {}
class VaapiVideoDecodeAccelerator::VaapiH264Accelerator
: public H264Decoder::H264Accelerator {
public:
......@@ -181,9 +174,9 @@ class VaapiVideoDecodeAccelerator::VaapiH264Accelerator
class VaapiVP8Picture : public VP8Picture {
public:
VaapiVP8Picture(
const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
dec_surface);
explicit VaapiVP8Picture(
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> surface)
: dec_surface_(surface) {}
VaapiVP8Picture* AsVaapiVP8Picture() override { return this; }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface() {
......@@ -191,20 +184,13 @@ class VaapiVP8Picture : public VP8Picture {
}
private:
~VaapiVP8Picture() override;
~VaapiVP8Picture() override {}
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface_;
DISALLOW_COPY_AND_ASSIGN(VaapiVP8Picture);
};
VaapiVP8Picture::VaapiVP8Picture(
const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
dec_surface)
: dec_surface_(dec_surface) {}
VaapiVP8Picture::~VaapiVP8Picture() {}
class VaapiVideoDecodeAccelerator::VaapiVP8Accelerator
: public VP8Decoder::VP8Accelerator {
public:
......@@ -235,9 +221,9 @@ class VaapiVideoDecodeAccelerator::VaapiVP8Accelerator
class VaapiVP9Picture : public VP9Picture {
public:
VaapiVP9Picture(
const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
dec_surface);
explicit VaapiVP9Picture(
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> surface)
: dec_surface_(surface) {}
VaapiVP9Picture* AsVaapiVP9Picture() override { return this; }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface() {
......@@ -245,20 +231,13 @@ class VaapiVP9Picture : public VP9Picture {
}
private:
~VaapiVP9Picture() override;
~VaapiVP9Picture() override {}
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface_;
DISALLOW_COPY_AND_ASSIGN(VaapiVP9Picture);
};
VaapiVP9Picture::VaapiVP9Picture(
const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
dec_surface)
: dec_surface_(dec_surface) {}
VaapiVP9Picture::~VaapiVP9Picture() {}
class VaapiVideoDecodeAccelerator::VaapiVP9Accelerator
: public VP9Decoder::VP9Accelerator {
public:
......@@ -293,6 +272,7 @@ class VaapiVideoDecodeAccelerator::VaapiVP9Accelerator
};
VaapiVideoDecodeAccelerator::InputBuffer::InputBuffer() = default;
VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() = default;
void VaapiVideoDecodeAccelerator::NotifyError(Error error) {
......@@ -1194,7 +1174,7 @@ VaapiVideoDecodeAccelerator::VaapiH264Accelerator::CreateH264Picture() {
if (!va_surface)
return nullptr;
return new VaapiH264Picture(va_surface);
return new VaapiH264Picture(std::move(va_surface));
}
// Fill |va_pic| with default/neutral values.
......@@ -1527,7 +1507,7 @@ VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::CreateVP8Picture() {
if (!va_surface)
return nullptr;
return new VaapiVP8Picture(va_surface);
return new VaapiVP8Picture(std::move(va_surface));
}
#define ARRAY_MEMCPY_CHECKED(to, from) \
......@@ -1756,7 +1736,7 @@ VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::CreateVP9Picture() {
if (!va_surface)
return nullptr;
return new VaapiVP9Picture(va_surface);
return new VaapiVP9Picture(std::move(va_surface));
}
bool VaapiVideoDecodeAccelerator::VaapiVP9Accelerator::SubmitDecode(
......
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