Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1222)

Unified Diff: media/renderers/mock_gpu_video_accelerator_factories.cc

Issue 1412223009: Reland: GpuMemoryBuffer interface change: Map(**) to Map() and memory(plane); stride(plane) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Win X64 compile fix Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>(
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698