This source file includes following definitions.
- mapped_
- IsFormatValid
- BytesPerPixel
- IsMapped
- GetStride
#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
#include "ui/gl/gl_bindings.h"
namespace content {
GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::Size size,
unsigned internalformat)
: size_(size), internalformat_(internalformat), mapped_(false) {
DCHECK(IsFormatValid(internalformat));
}
GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {}
bool GpuMemoryBufferImpl::IsFormatValid(unsigned internalformat) {
switch (internalformat) {
case GL_BGRA8_EXT:
case GL_RGBA8_OES:
return true;
default:
return false;
}
}
size_t GpuMemoryBufferImpl::BytesPerPixel(unsigned internalformat) {
switch (internalformat) {
case GL_BGRA8_EXT:
case GL_RGBA8_OES:
return 4;
default:
NOTREACHED();
return 0;
}
}
bool GpuMemoryBufferImpl::IsMapped() const { return mapped_; }
uint32 GpuMemoryBufferImpl::GetStride() const {
return size_.width() * BytesPerPixel(internalformat_);
}
}