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

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

Issue 1152693002: ui: Add sub region copy support to GLImage::CopyTexImage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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_stub.h » ('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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // Defer DoBindTexImage if not currently in use. 257 // Defer DoBindTexImage if not currently in use.
258 if (!in_use_) { 258 if (!in_use_) {
259 need_do_bind_tex_image_ = true; 259 need_do_bind_tex_image_ = true;
260 return true; 260 return true;
261 } 261 }
262 262
263 DoBindTexImage(target); 263 DoBindTexImage(target);
264 return true; 264 return true;
265 } 265 }
266 266
267 bool GLImageMemory::CopyTexImage(unsigned target) { 267 bool GLImageMemory::CopyTexSubImage(unsigned target,
268 TRACE_EVENT0("gpu", "GLImageMemory::CopyTexImage"); 268 const Point& offset,
269 const Rect& rect) {
270 TRACE_EVENT2("gpu", "GLImageMemory::CopyTexSubImage", "width", rect.width(),
271 "height", rect.height());
269 272
270 // GL_TEXTURE_EXTERNAL_OES is not a supported CopyTexImage target. 273 // GL_TEXTURE_EXTERNAL_OES is not a supported CopyTexSubImage target.
271 if (target == GL_TEXTURE_EXTERNAL_OES) 274 if (target == GL_TEXTURE_EXTERNAL_OES)
272 return false; 275 return false;
273 276
277 // Sub width is not supported.
278 if (rect.width() != size_.width())
279 return false;
280
281 // Height must be a multiple of 4 if compressed.
282 if (IsCompressedFormat(format_) && rect.height() % 4)
283 return false;
284
285 size_t stride_in_bytes = 0;
286 bool rv = StrideInBytes(size_.width(), format_, &stride_in_bytes);
287 DCHECK(rv);
274 DCHECK(memory_); 288 DCHECK(memory_);
289 const unsigned char* data = memory_ + rect.y() * stride_in_bytes;
275 if (IsCompressedFormat(format_)) { 290 if (IsCompressedFormat(format_)) {
276 glCompressedTexSubImage2D(target, 291 glCompressedTexSubImage2D(target,
277 0, // level 292 0, // level
278 0, // x-offset 293 offset.x(), offset.y(), rect.width(),
279 0, // y-offset 294 rect.height(), DataFormat(format_),
280 size_.width(), size_.height(), 295 SizeInBytes(rect.size(), format_), data);
281 DataFormat(format_), SizeInBytes(size_, format_),
282 memory_);
283 } else { 296 } else {
284 glTexSubImage2D(target, 0, // level 297 glTexSubImage2D(target, 0, // level
285 0, // x 298 offset.x(), offset.y(), rect.width(), rect.height(),
286 0, // y 299 DataFormat(format_), DataType(format_), data);
287 size_.width(), size_.height(), DataFormat(format_),
288 DataType(format_), memory_);
289 } 300 }
290 301
291 return true; 302 return true;
292 } 303 }
293 304
294 void GLImageMemory::WillUseTexImage() { 305 void GLImageMemory::WillUseTexImage() {
295 DCHECK(!in_use_); 306 DCHECK(!in_use_);
296 in_use_ = true; 307 in_use_ = true;
297 308
298 if (!need_do_bind_tex_image_) 309 if (!need_do_bind_tex_image_)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 size_.width(), 422 size_.width(),
412 size_.height(), 423 size_.height(),
413 0, // border 424 0, // border
414 DataFormat(format_), 425 DataFormat(format_),
415 DataType(format_), 426 DataType(format_),
416 memory_); 427 memory_);
417 } 428 }
418 } 429 }
419 430
420 } // namespace gfx 431 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_memory.h ('k') | ui/gl/gl_image_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698