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

Side by Side Diff: ui/gl/gl_image_shared_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: Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_image_shared_memory.h" 5 #include "ui/gl/gl_image_shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/numerics/safe_math.h" 8 #include "base/numerics/safe_math.h"
9 #include "base/process/process_handle.h" 9 #include "base/process/process_handle.h"
10 10
11 namespace gfx { 11 namespace gfx {
12 namespace { 12 namespace {
13 13
14 // Returns true if the size is valid and false otherwise. 14 // Returns true if the size is valid and false otherwise.
15 bool SizeInBytes(const gfx::Size& size, 15 bool SizeInBytes(const gfx::Size& size,
16 gfx::GpuMemoryBuffer::Format format, 16 gfx::GpuMemoryBuffer::Format format,
17 size_t* size_in_bytes) { 17 size_t* size_in_bytes) {
18 if (size.IsEmpty()) 18 if (size.IsEmpty())
19 return false; 19 return false;
20 base::CheckedNumeric<size_t> s = GLImageMemory::BytesPerPixel(format); 20 DCHECK_EQ(size.GetArea() * GLImageMemory::BitsPerPixel(format) % 8, 0u);
reveman 2014/12/15 17:33:34 Hm, so this will fail for a 1x1 buffer with bpp <
christiank 2014/12/16 12:02:52 Currently we don't support images with a width and
reveman 2014/12/16 16:40:12 A renderer should not be able cause the GPU servic
21 base::CheckedNumeric<size_t> s = GLImageMemory::BitsPerPixel(format);
21 s *= size.width(); 22 s *= size.width();
22 s *= size.height(); 23 s *= size.height();
24 s /= 8;
23 if (!s.IsValid()) 25 if (!s.IsValid())
24 return false; 26 return false;
25 *size_in_bytes = s.ValueOrDie(); 27 *size_in_bytes = s.ValueOrDie();
26 return true; 28 return true;
27 } 29 }
28 30
29 } // namespace 31 } // namespace
30 32
31 GLImageSharedMemory::GLImageSharedMemory(const gfx::Size& size, 33 GLImageSharedMemory::GLImageSharedMemory(const gfx::Size& size,
32 unsigned internalformat) 34 unsigned internalformat)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 shared_memory_ = duped_shared_memory.Pass(); 74 shared_memory_ = duped_shared_memory.Pass();
73 return true; 75 return true;
74 } 76 }
75 77
76 void GLImageSharedMemory::Destroy(bool have_context) { 78 void GLImageSharedMemory::Destroy(bool have_context) {
77 GLImageMemory::Destroy(have_context); 79 GLImageMemory::Destroy(have_context);
78 shared_memory_.reset(); 80 shared_memory_.reset();
79 } 81 }
80 82
81 } // namespace gfx 83 } // namespace gfx
OLDNEW
« content/common/gpu/client/gpu_memory_buffer_impl.h ('K') | « ui/gl/gl_image_memory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698