diff options
author | christiank <christiank@opera.com> | 2015-01-16 03:31:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-16 11:32:27 +0000 |
commit | 53e678c7962e12efe4bca3b58c9efbf755b86798 (patch) | |
tree | a00691f9c9e071aef0d666a865986db2d9680a44 /gpu/command_buffer/tests | |
parent | ddaf644b623a16181e580a01d01889fa694907c5 (diff) | |
download | chromium_src-53e678c7962e12efe4bca3b58c9efbf755b86798.zip chromium_src-53e678c7962e12efe4bca3b58c9efbf755b86798.tar.gz chromium_src-53e678c7962e12efe4bca3b58c9efbf755b86798.tar.bz2 |
Update GPU memory buffers to use StrideInBytes internally.
Tile texture compression will add support for GPU memory buffer formats
that use less than a byte per pixel.
This CL prepares GPU buffers for this by using a new function
StrideInBytes instead of relying on bytes per pixel calculations when
calculating the number of bytes needed to store a certain number of pixels.
BUG=434699
Review URL: https://codereview.chromium.org/806653006
Cr-Commit-Position: refs/heads/master@{#311862}
Diffstat (limited to 'gpu/command_buffer/tests')
-rw-r--r-- | gpu/command_buffer/tests/gl_manager.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc index 1075c42..8f4b330 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -38,11 +38,11 @@ namespace gpu { 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::BGRA_8888: - return 4; + return width * 4; case gfx::GpuMemoryBuffer::RGBX_8888: NOTREACHED(); return 0; @@ -72,7 +72,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 { NOTREACHED(); @@ -134,7 +134,8 @@ GLManager::~GLManager() { scoped_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer( const gfx::Size& size, gfx::GpuMemoryBuffer::Format format) { - std::vector<unsigned char> data(size.GetArea() * BytesPerPixel(format), 0); + std::vector<unsigned char> data( + StrideInBytes(size.width(), format) * size.height(), 0); scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); return make_scoped_ptr<gfx::GpuMemoryBuffer>( new GpuMemoryBufferImpl(bytes.get(), size, format)); |