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

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc

Issue 968283002: content: Remove use of GLImage from GpuMemoryBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add size check to gmb code Created 5 years, 10 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: content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc
index ade8e1ae47de63201980362bbcf47a27f45b8e28..8daff2a9b80c53572bfb969572d0e4b691ca5535 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc
@@ -24,6 +24,8 @@ GpuMemoryBufferImplSharedMemory::GpuMemoryBufferImplSharedMemory(
scoped_ptr<base::SharedMemory> shared_memory)
: GpuMemoryBufferImpl(id, size, format, callback),
shared_memory_(shared_memory.Pass()) {
+ DCHECK(IsFormatSupported(format));
+ DCHECK(IsSizeValidForFormat(size, format));
}
GpuMemoryBufferImplSharedMemory::~GpuMemoryBufferImplSharedMemory() {
@@ -131,6 +133,29 @@ bool GpuMemoryBufferImplSharedMemory::IsFormatSupported(Format format) {
return false;
}
+// static
+bool GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(
+ const gfx::Size& size,
+ Format format) {
+ switch (format) {
+ case ATC:
+ case ATCIA:
+ case DXT1:
+ case DXT5:
+ case ETC1:
+ // Compressed images must have a width and height that's evenly divisible
+ // by the block size.
+ return size.width() % 4 == 0 && size.height() % 4 == 0;
+ case RGBA_8888:
+ case BGRA_8888:
+ case RGBX_8888:
+ return true;
+ }
+
+ NOTREACHED();
+ return false;
+}
+
void* GpuMemoryBufferImplSharedMemory::Map() {
DCHECK(!mapped_);
mapped_ = true;
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h ('k') | content/common/gpu/gpu_command_buffer_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698