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

Unified Diff: gpu/command_buffer/tests/gl_manager.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
Index: gpu/command_buffer/tests/gl_manager.cc
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc
index bb803bbf55f927ad9632fbe4ea5a12279fe5af41..2dbcfb9348c1755f102f8c7941c7b8dae556c622 100644
--- a/gpu/command_buffer/tests/gl_manager.cc
+++ b/gpu/command_buffer/tests/gl_manager.cc
@@ -49,31 +49,33 @@ class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
GpuMemoryBufferImpl(base::RefCountedBytes* bytes,
const gfx::Size& size,
gfx::BufferFormat format)
- : bytes_(bytes), size_(size), format_(format) {}
+ : mapped_(false), bytes_(bytes), size_(size), format_(format) {}
static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer) {
return reinterpret_cast<GpuMemoryBufferImpl*>(buffer);
}
// Overridden from gfx::GpuMemoryBuffer:
- bool Map(void** data) override {
- size_t offset = 0;
- size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format_);
- for (size_t i = 0; i < num_planes; ++i) {
- data[i] = reinterpret_cast<uint8*>(&bytes_->data().front()) + offset;
- offset +=
- gfx::RowSizeForBufferFormat(size_.width(), format_, i) *
- (size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i));
- }
+ bool Map() override {
+ DCHECK(!mapped_);
+ mapped_ = true;
return true;
}
- void Unmap() override {}
+ void* memory(size_t plane) override {
+ DCHECK(mapped_);
+ DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
+ return reinterpret_cast<uint8*>(&bytes_->data().front()) +
+ gfx::BufferOffsetForBufferFormat(size_, format_, plane);
+ }
+ void Unmap() override {
+ DCHECK(mapped_);
+ mapped_ = false;
+ }
gfx::Size GetSize() const override { return size_; }
gfx::BufferFormat GetFormat() const override { return format_; }
- void GetStride(int* stride) const override {
- size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format_);
- for (size_t i = 0; i < num_planes; ++i)
- stride[i] = gfx::RowSizeForBufferFormat(size_.width(), format_, i);
+ int stride(size_t plane) const override {
+ DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
+ return gfx::RowSizeForBufferFormat(size_.width(), format_, plane);
}
gfx::GpuMemoryBufferId GetId() const override {
NOTREACHED();
@@ -90,6 +92,7 @@ class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
base::RefCountedBytes* bytes() { return bytes_.get(); }
private:
+ bool mapped_;
scoped_refptr<base::RefCountedBytes> bytes_;
const gfx::Size size_;
gfx::BufferFormat format_;
« no previous file with comments | « gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc ('k') | media/renderers/mock_gpu_video_accelerator_factories.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698