| Index: media/renderers/mock_gpu_video_accelerator_factories.cc
|
| diff --git a/media/renderers/mock_gpu_video_accelerator_factories.cc b/media/renderers/mock_gpu_video_accelerator_factories.cc
|
| index 7bf6bf0fb3c30b50f637cb61ce95c6ad403d37e7..84ee888a01560df82b3512ad20d5652b8b7fee8e 100644
|
| --- a/media/renderers/mock_gpu_video_accelerator_factories.cc
|
| +++ b/media/renderers/mock_gpu_video_accelerator_factories.cc
|
| @@ -14,7 +14,9 @@ namespace {
|
| class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
|
| public:
|
| GpuMemoryBufferImpl(const gfx::Size& size, gfx::BufferFormat format)
|
| - : format_(format), size_(size),
|
| + : mapped_(false),
|
| + format_(format),
|
| + size_(size),
|
| num_planes_(gfx::NumberOfPlanesForBufferFormat(format)) {
|
| DCHECK(gfx::BufferFormat::R_8 == format_ ||
|
| gfx::BufferFormat::YUV_420_BIPLANAR == format_ ||
|
| @@ -28,21 +30,28 @@ class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
|
| }
|
|
|
| // Overridden from gfx::GpuMemoryBuffer:
|
| - bool Map(void** data) override {
|
| - for (size_t plane = 0; plane < num_planes_; ++plane)
|
| - data[plane] = &bytes_[plane][0];
|
| + bool Map() override {
|
| + DCHECK(!mapped_);
|
| + mapped_ = true;
|
| return true;
|
| }
|
| - void Unmap() override {}
|
| + void* memory(size_t plane) override {
|
| + DCHECK(mapped_);
|
| + DCHECK_LT(plane, num_planes_);
|
| + return &bytes_[plane][0];
|
| + }
|
| + void Unmap() override {
|
| + DCHECK(mapped_);
|
| + mapped_ = false;
|
| + }
|
| gfx::Size GetSize() const override { return size_; }
|
| gfx::BufferFormat GetFormat() const override {
|
| return format_;
|
| }
|
| - void GetStride(int* strides) const override {
|
| - for (int plane = 0; plane < static_cast<int>(num_planes_); ++plane) {
|
| - strides[plane] = static_cast<int>(
|
| - gfx::RowSizeForBufferFormat(size_.width(), format_, plane));
|
| - }
|
| + int stride(size_t plane) const override {
|
| + DCHECK_LT(plane, num_planes_);
|
| + return static_cast<int>(gfx::RowSizeForBufferFormat(
|
| + size_.width(), format_, static_cast<int>(plane)));
|
| }
|
| gfx::GpuMemoryBufferId GetId() const override {
|
| NOTREACHED();
|
| @@ -59,6 +68,7 @@ class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
|
| private:
|
| static const size_t kMaxPlanes = 3;
|
|
|
| + bool mapped_;
|
| gfx::BufferFormat format_;
|
| const gfx::Size size_;
|
| size_t num_planes_;
|
| @@ -81,7 +91,7 @@ scoped_ptr<gfx::GpuMemoryBuffer>
|
| MockGpuVideoAcceleratorFactories::AllocateGpuMemoryBuffer(
|
| const gfx::Size& size,
|
| gfx::BufferFormat format,
|
| - gfx::BufferUsage usage) {
|
| + gfx::BufferUsage /* usage */) {
|
| if (fail_to_allocate_gpu_memory_buffer_)
|
| return nullptr;
|
| return make_scoped_ptr<gfx::GpuMemoryBuffer>(
|
|
|