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

Unified Diff: ui/gl/gl_image_memory.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 | « ui/gl/gl_image_memory.h ('k') | ui/gl/gl_image_shared_memory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_memory.cc
diff --git a/ui/gl/gl_image_memory.cc b/ui/gl/gl_image_memory.cc
index 0a67e000665b6a5806a0f935f61e02faaf540a15..5e23d30778dd08389438753a5f3b6c33098ef77f 100644
--- a/ui/gl/gl_image_memory.cc
+++ b/ui/gl/gl_image_memory.cc
@@ -100,18 +100,26 @@ GLImageMemory::~GLImageMemory() {
}
// static
-size_t GLImageMemory::BytesPerPixel(gfx::GpuMemoryBuffer::Format format) {
+bool GLImageMemory::StrideInBytes(size_t width,
+ gfx::GpuMemoryBuffer::Format format,
+ size_t* stride_in_bytes) {
+ base::CheckedNumeric<size_t> s = width;
switch (format) {
case gfx::GpuMemoryBuffer::RGBA_8888:
case gfx::GpuMemoryBuffer::BGRA_8888:
- return 4;
+ s *= 4;
+ if (!s.IsValid())
+ return false;
+
+ *stride_in_bytes = s.ValueOrDie();
+ return true;
case gfx::GpuMemoryBuffer::RGBX_8888:
NOTREACHED();
- return 0;
+ return false;
}
NOTREACHED();
- return 0;
+ return false;
}
bool GLImageMemory::Initialize(const unsigned char* memory,
« no previous file with comments | « ui/gl/gl_image_memory.h ('k') | ui/gl/gl_image_shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698