| Index: content/browser/renderer_host/media/video_capture_buffer_pool_unittest.cc
|
| diff --git a/content/browser/renderer_host/media/video_capture_buffer_pool_unittest.cc b/content/browser/renderer_host/media/video_capture_buffer_pool_unittest.cc
|
| index e31d4462e7cf77e3e056d4047b708ecd6d1927a2..95c26491eda04784199df6f504900f0cdfdec863 100644
|
| --- a/content/browser/renderer_host/media/video_capture_buffer_pool_unittest.cc
|
| +++ b/content/browser/renderer_host/media/video_capture_buffer_pool_unittest.cc
|
| @@ -23,7 +23,6 @@
|
| #include "cc/test/test_context_provider.h"
|
| #include "cc/test/test_web_graphics_context_3d.h"
|
| #include "components/display_compositor/buffer_queue.h"
|
| -#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
|
| #include "content/browser/renderer_host/media/video_capture_buffer_tracker_factory_impl.h"
|
| #include "content/browser/renderer_host/media/video_capture_controller.h"
|
| #include "media/base/video_frame.h"
|
| @@ -41,10 +40,6 @@ struct PixelFormatAndStorage {
|
| static const PixelFormatAndStorage kCapturePixelFormatAndStorages[] = {
|
| {media::PIXEL_FORMAT_I420, media::PIXEL_STORAGE_CPU},
|
| {media::PIXEL_FORMAT_ARGB, media::PIXEL_STORAGE_CPU},
|
| -#if !defined(OS_ANDROID)
|
| - {media::PIXEL_FORMAT_I420,
|
| - media::PIXEL_STORAGE_GPUMEMORYBUFFER},
|
| -#endif
|
| };
|
|
|
| static const int kTestBufferPoolSize = 3;
|
| @@ -56,71 +51,6 @@ static const int kTestBufferPoolSize = 3;
|
| class VideoCaptureBufferPoolTest
|
| : public testing::TestWithParam<PixelFormatAndStorage> {
|
| protected:
|
| - // A GpuMemoryBuffer Mock to provide a trivial RGBA buffer as Map() backing.
|
| - // We need to allocate on ctor and deallocate on dtor so that consecutive
|
| - // Map()-Unmap() cycles yield the same underlying data pointer.
|
| - class MockGpuMemoryBuffer : public gfx::GpuMemoryBuffer {
|
| - public:
|
| - explicit MockGpuMemoryBuffer(const gfx::Size& size)
|
| - : size_(size),
|
| - data_(new uint8_t[size_.GetArea() * 4]),
|
| - mapped_(false) {}
|
| - ~MockGpuMemoryBuffer() override { delete[] data_; }
|
| -
|
| - bool Map() override {
|
| - EXPECT_FALSE(mapped_);
|
| - mapped_ = true;
|
| - return true;
|
| - }
|
| - void* memory(size_t plane) override {
|
| - EXPECT_TRUE(mapped_);
|
| - EXPECT_EQ(0u, plane);
|
| - return static_cast<void*>(data_);
|
| - }
|
| - void Unmap() override {
|
| - EXPECT_TRUE(mapped_);
|
| - mapped_ = false;
|
| - }
|
| - gfx::Size GetSize() const override { return size_; }
|
| - gfx::BufferFormat GetFormat() const override {
|
| - return gfx::BufferFormat::BGRA_8888;
|
| - }
|
| - int stride(size_t plane) const override {
|
| - EXPECT_EQ(0u, plane);
|
| - return size_.width() * 4;
|
| - }
|
| - gfx::GpuMemoryBufferId GetId() const override {
|
| - return gfx::GpuMemoryBufferId(0);
|
| - }
|
| - gfx::GpuMemoryBufferHandle GetHandle() const override {
|
| - return gfx::GpuMemoryBufferHandle();
|
| - }
|
| - ClientBuffer AsClientBuffer() override { return nullptr; }
|
| -
|
| - private:
|
| - const gfx::Size size_;
|
| - uint8_t* const data_;
|
| - bool mapped_;
|
| - };
|
| -
|
| -#if !defined(OS_ANDROID)
|
| - // The next two classes are needed to replicate the GpuMemoryBuffer allocation
|
| - // on Browser side.
|
| - class StubBrowserGpuMemoryBufferManager
|
| - : public BrowserGpuMemoryBufferManager {
|
| - public:
|
| - StubBrowserGpuMemoryBufferManager() : BrowserGpuMemoryBufferManager(1, 1) {}
|
| -
|
| - std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
|
| - const gfx::Size& size,
|
| - gfx::BufferFormat format,
|
| - gfx::BufferUsage usage,
|
| - gpu::SurfaceHandle surface_handle) override {
|
| - return base::MakeUnique<MockGpuMemoryBuffer>(size);
|
| - }
|
| - };
|
| -#endif
|
| -
|
| // This is a generic Buffer tracker
|
| class Buffer {
|
| public:
|
| @@ -145,12 +75,6 @@ class VideoCaptureBufferPoolTest
|
| base::MakeUnique<VideoCaptureBufferTrackerFactoryImpl>(),
|
| kTestBufferPoolSize)) {}
|
|
|
| -#if !defined(OS_ANDROID)
|
| - void SetUp() override {
|
| - gpu_memory_buffer_manager_.reset(new StubBrowserGpuMemoryBufferManager);
|
| - }
|
| -#endif
|
| -
|
| void ExpectDroppedId(int expected_dropped_id) {
|
| expected_dropped_id_ = expected_dropped_id;
|
| }
|
| @@ -195,10 +119,6 @@ class VideoCaptureBufferPoolTest
|
| scoped_refptr<media::VideoCaptureBufferPool> pool_;
|
|
|
| private:
|
| -#if !defined(OS_ANDROID)
|
| - std::unique_ptr<StubBrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_;
|
| -#endif
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(VideoCaptureBufferPoolTest);
|
| };
|
|
|
| @@ -227,12 +147,9 @@ TEST_P(VideoCaptureBufferPoolTest, BufferPool) {
|
| ASSERT_NE(nullptr, buffer3.get());
|
| ASSERT_EQ(3.0 / kTestBufferPoolSize, pool_->GetBufferPoolUtilization());
|
|
|
| - // GMB backed frames have their platform and format specific allocations.
|
| - if (GetParam().pixel_storage != media::PIXEL_STORAGE_GPUMEMORYBUFFER) {
|
| - ASSERT_LE(format_lo.ImageAllocationSize(), buffer1->mapped_size());
|
| - ASSERT_LE(format_lo.ImageAllocationSize(), buffer2->mapped_size());
|
| - ASSERT_LE(format_lo.ImageAllocationSize(), buffer3->mapped_size());
|
| - }
|
| + ASSERT_LE(format_lo.ImageAllocationSize(), buffer1->mapped_size());
|
| + ASSERT_LE(format_lo.ImageAllocationSize(), buffer2->mapped_size());
|
| + ASSERT_LE(format_lo.ImageAllocationSize(), buffer3->mapped_size());
|
|
|
| ASSERT_NE(nullptr, buffer1->data());
|
| ASSERT_NE(nullptr, buffer2->data());
|
| @@ -335,8 +252,7 @@ TEST_P(VideoCaptureBufferPoolTest, BufferPool) {
|
| ASSERT_EQ(2.0 / kTestBufferPoolSize, pool_->GetBufferPoolUtilization());
|
| buffer2 = ReserveBuffer(size_hi, GetParam());
|
| ASSERT_NE(nullptr, buffer2.get());
|
| - if (GetParam().pixel_storage != media::PIXEL_STORAGE_GPUMEMORYBUFFER)
|
| - ASSERT_LE(format_hi.ImageAllocationSize(), buffer2->mapped_size());
|
| + ASSERT_LE(format_hi.ImageAllocationSize(), buffer2->mapped_size());
|
| ASSERT_EQ(3, buffer2->id());
|
| ASSERT_EQ(3.0 / kTestBufferPoolSize, pool_->GetBufferPoolUtilization());
|
| void* const memory_pointer_hi = buffer2->data();
|
| @@ -349,8 +265,7 @@ TEST_P(VideoCaptureBufferPoolTest, BufferPool) {
|
| << "Decrease in resolution should not reallocate buffer";
|
| ASSERT_NE(nullptr, buffer2.get());
|
| ASSERT_EQ(3, buffer2->id());
|
| - if (GetParam().pixel_storage != media::PIXEL_STORAGE_GPUMEMORYBUFFER)
|
| - ASSERT_LE(format_lo.ImageAllocationSize(), buffer2->mapped_size());
|
| + ASSERT_LE(format_lo.ImageAllocationSize(), buffer2->mapped_size());
|
| ASSERT_EQ(3.0 / kTestBufferPoolSize, pool_->GetBufferPoolUtilization());
|
| ASSERT_FALSE(ReserveBuffer(size_lo, GetParam())) << "Pool should be empty";
|
| ASSERT_EQ(1.0, pool_->GetBufferPoolUtilization());
|
| @@ -447,17 +362,6 @@ TEST_P(VideoCaptureBufferPoolTest, DoesNotResurrectIfPropertiesNotMatched) {
|
| ResurrectLastBuffer(gfx::Size(10, 10), altered_format_or_storage);
|
| ASSERT_EQ(nullptr, resurrected.get());
|
|
|
| - // Expect that the buffer cannot be resurrected if the pixel storage does not
|
| - // match.
|
| - altered_format_or_storage = GetParam();
|
| - altered_format_or_storage.pixel_storage =
|
| - (altered_format_or_storage.pixel_storage == media::PIXEL_STORAGE_CPU)
|
| - ? media::PIXEL_STORAGE_GPUMEMORYBUFFER
|
| - : media::PIXEL_STORAGE_CPU;
|
| - resurrected =
|
| - ResurrectLastBuffer(gfx::Size(10, 10), altered_format_or_storage);
|
| - ASSERT_EQ(nullptr, resurrected.get());
|
| -
|
| // Finally, check that the buffer CAN be resurrected if all properties match.
|
| resurrected = ResurrectLastBuffer(gfx::Size(10, 10), GetParam());
|
| ASSERT_NE(nullptr, resurrected.get());
|
|
|