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

Side by Side Diff: ui/gl/gl_image_shared_memory.cc

Issue 916083002: Add support for compressed GPU memory buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ozone Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « ui/gl/gl_image_memory.cc ('k') | ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20
21 if (!GLImageMemory::ValidSize(size, format))
22 return false;
23
21 size_t stride_in_bytes = 0; 24 size_t stride_in_bytes = 0;
22 if (!GLImageMemory::StrideInBytes(size.width(), format, &stride_in_bytes)) 25 if (!GLImageMemory::StrideInBytes(size.width(), format, &stride_in_bytes))
23 return false; 26 return false;
24 base::CheckedNumeric<size_t> s = stride_in_bytes; 27 base::CheckedNumeric<size_t> s = stride_in_bytes;
25 s *= size.height(); 28 s *= size.height();
26 if (!s.IsValid()) 29 if (!s.IsValid())
27 return false; 30 return false;
28 *size_in_bytes = s.ValueOrDie(); 31 *size_in_bytes = s.ValueOrDie();
29 return true; 32 return true;
30 } 33 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 shared_memory_ = duped_shared_memory.Pass(); 78 shared_memory_ = duped_shared_memory.Pass();
76 return true; 79 return true;
77 } 80 }
78 81
79 void GLImageSharedMemory::Destroy(bool have_context) { 82 void GLImageSharedMemory::Destroy(bool have_context) {
80 GLImageMemory::Destroy(have_context); 83 GLImageMemory::Destroy(have_context);
81 shared_memory_.reset(); 84 shared_memory_.reset();
82 } 85 }
83 86
84 } // namespace gfx 87 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_memory.cc ('k') | ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698