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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch 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.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/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return true; 176 return true;
177 case gfx::GpuMemoryBuffer::RGBX_8888: 177 case gfx::GpuMemoryBuffer::RGBX_8888:
178 NOTREACHED(); 178 NOTREACHED();
179 return false; 179 return false;
180 } 180 }
181 181
182 NOTREACHED(); 182 NOTREACHED();
183 return false; 183 return false;
184 } 184 }
185 185
186 // static
187 bool GLImageMemory::ValidSize(const gfx::Size& size,
188 gfx::GpuMemoryBuffer::Format format) {
189 switch (format) {
190 case gfx::GpuMemoryBuffer::ATC:
191 case gfx::GpuMemoryBuffer::ATCIA:
192 case gfx::GpuMemoryBuffer::DXT1:
193 case gfx::GpuMemoryBuffer::DXT5:
194 case gfx::GpuMemoryBuffer::ETC1:
195 // Compressed images must have a width and height that's evenly divisible
196 // by the block size.
197 return size.width() % 4 == 0 && size.height() % 4 == 0;
198 case gfx::GpuMemoryBuffer::RGBA_8888:
199 case gfx::GpuMemoryBuffer::BGRA_8888:
200 return true;
201 case gfx::GpuMemoryBuffer::RGBX_8888:
202 NOTREACHED();
203 return false;
204 }
205
206 NOTREACHED();
207 return false;
208 }
209
210 bool GLImageMemory::Initialize(const unsigned char* memory, 186 bool GLImageMemory::Initialize(const unsigned char* memory,
211 gfx::GpuMemoryBuffer::Format format) { 187 gfx::GpuMemoryBuffer::Format format) {
212 if (!ValidInternalFormat(internalformat_)) { 188 if (!ValidInternalFormat(internalformat_)) {
213 LOG(ERROR) << "Invalid internalformat: " << internalformat_; 189 LOG(ERROR) << "Invalid internalformat: " << internalformat_;
214 return false; 190 return false;
215 } 191 }
216 192
217 if (!ValidFormat(format)) { 193 if (!ValidFormat(format)) {
218 LOG(ERROR) << "Invalid format: " << format; 194 LOG(ERROR) << "Invalid format: " << format;
219 return false; 195 return false;
220 } 196 }
221 197
222 DCHECK(memory); 198 DCHECK(memory);
223 DCHECK(!memory_); 199 DCHECK(!memory_);
200 DCHECK_IMPLIES(IsCompressedFormat(format), size_.width() % 4 == 0);
201 DCHECK_IMPLIES(IsCompressedFormat(format), size_.height() % 4 == 0);
224 memory_ = memory; 202 memory_ = memory;
225 format_ = format; 203 format_ = format;
226 return true; 204 return true;
227 } 205 }
228 206
229 void GLImageMemory::Destroy(bool have_context) { 207 void GLImageMemory::Destroy(bool have_context) {
230 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ 208 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
231 defined(USE_OZONE) 209 defined(USE_OZONE)
232 if (egl_image_ != EGL_NO_IMAGE_KHR) { 210 if (egl_image_ != EGL_NO_IMAGE_KHR) {
233 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); 211 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 size_.width(), 390 size_.width(),
413 size_.height(), 391 size_.height(),
414 0, // border 392 0, // border
415 DataFormat(format_), 393 DataFormat(format_),
416 DataType(format_), 394 DataType(format_),
417 memory_); 395 memory_);
418 } 396 }
419 } 397 }
420 398
421 } // namespace gfx 399 } // 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