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

Side by Side 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 unified diff | 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 »
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_memory.h" 5 #include "ui/gl/gl_image_memory.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/gl/gl_bindings.h" 9 #include "ui/gl/gl_bindings.h"
10 #include "ui/gl/scoped_binders.h" 10 #include "ui/gl/scoped_binders.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 GLImageMemory::~GLImageMemory() { 94 GLImageMemory::~GLImageMemory() {
95 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ 95 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
96 defined(USE_OZONE) 96 defined(USE_OZONE)
97 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); 97 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
98 DCHECK_EQ(0u, egl_texture_id_); 98 DCHECK_EQ(0u, egl_texture_id_);
99 #endif 99 #endif
100 } 100 }
101 101
102 // static 102 // static
103 size_t GLImageMemory::BytesPerPixel(gfx::GpuMemoryBuffer::Format format) { 103 bool GLImageMemory::StrideInBytes(size_t width,
104 gfx::GpuMemoryBuffer::Format format,
105 size_t* stride_in_bytes) {
106 base::CheckedNumeric<size_t> s = width;
104 switch (format) { 107 switch (format) {
105 case gfx::GpuMemoryBuffer::RGBA_8888: 108 case gfx::GpuMemoryBuffer::RGBA_8888:
106 case gfx::GpuMemoryBuffer::BGRA_8888: 109 case gfx::GpuMemoryBuffer::BGRA_8888:
107 return 4; 110 s *= 4;
111 if (!s.IsValid())
112 return false;
113
114 *stride_in_bytes = s.ValueOrDie();
115 return true;
108 case gfx::GpuMemoryBuffer::RGBX_8888: 116 case gfx::GpuMemoryBuffer::RGBX_8888:
109 NOTREACHED(); 117 NOTREACHED();
110 return 0; 118 return false;
111 } 119 }
112 120
113 NOTREACHED(); 121 NOTREACHED();
114 return 0; 122 return false;
115 } 123 }
116 124
117 bool GLImageMemory::Initialize(const unsigned char* memory, 125 bool GLImageMemory::Initialize(const unsigned char* memory,
118 gfx::GpuMemoryBuffer::Format format) { 126 gfx::GpuMemoryBuffer::Format format) {
119 if (!ValidInternalFormat(internalformat_)) { 127 if (!ValidInternalFormat(internalformat_)) {
120 LOG(ERROR) << "Invalid internalformat: " << internalformat_; 128 LOG(ERROR) << "Invalid internalformat: " << internalformat_;
121 return false; 129 return false;
122 } 130 }
123 131
124 if (!ValidFormat(format)) { 132 if (!ValidFormat(format)) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 TextureFormat(format_), 288 TextureFormat(format_),
281 size_.width(), 289 size_.width(),
282 size_.height(), 290 size_.height(),
283 0, // border 291 0, // border
284 DataFormat(format_), 292 DataFormat(format_),
285 DataType(format_), 293 DataType(format_),
286 memory_); 294 memory_);
287 } 295 }
288 296
289 } // namespace gfx 297 } // namespace gfx
OLDNEW
« 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