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

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: Use StrideInBytes 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_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 size_t GLImageMemory::StrideInBytes(
104 size_t width, gfx::GpuMemoryBuffer::Format format) {
104 switch (format) { 105 switch (format) {
105 case gfx::GpuMemoryBuffer::RGBA_8888: 106 case gfx::GpuMemoryBuffer::RGBA_8888:
106 case gfx::GpuMemoryBuffer::BGRA_8888: 107 case gfx::GpuMemoryBuffer::BGRA_8888:
107 return 4; 108 return width * 4;
reveman 2014/12/18 18:49:57 Can this overflow? Should it be using CheckedNumer
christiank 2015/01/12 10:35:23 Yes, think it can. It's now updated to use Checked
108 case gfx::GpuMemoryBuffer::RGBX_8888: 109 case gfx::GpuMemoryBuffer::RGBX_8888:
109 NOTREACHED(); 110 NOTREACHED();
110 return 0; 111 return 0;
111 } 112 }
112 113
113 NOTREACHED(); 114 NOTREACHED();
114 return 0; 115 return 0;
115 } 116 }
116 117
117 bool GLImageMemory::Initialize(const unsigned char* memory, 118 bool GLImageMemory::Initialize(const unsigned char* memory,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 TextureFormat(format_), 281 TextureFormat(format_),
281 size_.width(), 282 size_.width(),
282 size_.height(), 283 size_.height(),
283 0, // border 284 0, // border
284 DataFormat(format_), 285 DataFormat(format_),
285 DataType(format_), 286 DataType(format_),
286 memory_); 287 memory_);
287 } 288 }
288 289
289 } // namespace gfx 290 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698