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

Unified Diff: cc/test/test_gpu_memory_buffer_manager.cc

Issue 806653006: Update GPU memory buffers to use StrideInBytes internally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit Created 5 years, 11 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 | « no previous file | content/common/gpu/client/gpu_memory_buffer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/test_gpu_memory_buffer_manager.cc
diff --git a/cc/test/test_gpu_memory_buffer_manager.cc b/cc/test/test_gpu_memory_buffer_manager.cc
index 3583ff30da7093beaf9af8a7f2fd444e15abd04b..196922f2fc94858242f124d8175eb9ea3dd965b6 100644
--- a/cc/test/test_gpu_memory_buffer_manager.cc
+++ b/cc/test/test_gpu_memory_buffer_manager.cc
@@ -10,12 +10,12 @@
namespace cc {
namespace {
-size_t BytesPerPixel(gfx::GpuMemoryBuffer::Format format) {
+size_t StrideInBytes(size_t width, gfx::GpuMemoryBuffer::Format format) {
switch (format) {
case gfx::GpuMemoryBuffer::RGBA_8888:
case gfx::GpuMemoryBuffer::RGBX_8888:
case gfx::GpuMemoryBuffer::BGRA_8888:
- return 4;
+ return width * 4;
}
NOTREACHED();
@@ -35,7 +35,8 @@ class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
// Overridden from gfx::GpuMemoryBuffer:
void* Map() override {
DCHECK(!mapped_);
- if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(format_)))
+ if (!shared_memory_->Map(StrideInBytes(size_.width(), format_) *
+ size_.height()))
return NULL;
mapped_ = true;
return shared_memory_->memory();
@@ -48,7 +49,7 @@ class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
bool IsMapped() const override { return mapped_; }
Format GetFormat() const override { return format_; }
uint32 GetStride() const override {
- return size_.width() * BytesPerPixel(format_);
+ return StrideInBytes(size_.width(), format_);
}
gfx::GpuMemoryBufferHandle GetHandle() const override {
gfx::GpuMemoryBufferHandle handle;
@@ -81,7 +82,8 @@ TestGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
gfx::GpuMemoryBuffer::Format format,
gfx::GpuMemoryBuffer::Usage usage) {
scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory);
- if (!shared_memory->CreateAnonymous(size.GetArea() * BytesPerPixel(format)))
+ if (!shared_memory->CreateAnonymous(StrideInBytes(size.width(), format) *
+ size.height()))
return nullptr;
return make_scoped_ptr<gfx::GpuMemoryBuffer>(
new GpuMemoryBufferImpl(size, format, shared_memory.Pass()));
« no previous file with comments | « no previous file | content/common/gpu/client/gpu_memory_buffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698