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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_memory.cc
diff --git a/ui/gl/gl_image_memory.cc b/ui/gl/gl_image_memory.cc
index 041f0abe9ba43928c242c56d2bb1222a7f15074e..f6269aa427aa4139e60dbb7fd4382c725523f48a 100644
--- a/ui/gl/gl_image_memory.cc
+++ b/ui/gl/gl_image_memory.cc
@@ -264,28 +264,39 @@ bool GLImageMemory::BindTexImage(unsigned target) {
return true;
}
-bool GLImageMemory::CopyTexImage(unsigned target) {
- TRACE_EVENT0("gpu", "GLImageMemory::CopyTexImage");
+bool GLImageMemory::CopyTexSubImage(unsigned target,
+ const Point& offset,
+ const Rect& rect) {
+ TRACE_EVENT2("gpu", "GLImageMemory::CopyTexSubImage", "width", rect.width(),
+ "height", rect.height());
- // GL_TEXTURE_EXTERNAL_OES is not a supported CopyTexImage target.
+ // GL_TEXTURE_EXTERNAL_OES is not a supported CopyTexSubImage target.
if (target == GL_TEXTURE_EXTERNAL_OES)
return false;
+ // Sub width is not supported.
+ if (rect.width() != size_.width())
+ return false;
+
+ // Height must be a multiple of 4 if compressed.
+ if (IsCompressedFormat(format_) && rect.height() % 4)
+ return false;
+
+ size_t stride_in_bytes = 0;
+ bool rv = StrideInBytes(size_.width(), format_, &stride_in_bytes);
+ DCHECK(rv);
DCHECK(memory_);
+ const unsigned char* data = memory_ + rect.y() * stride_in_bytes;
if (IsCompressedFormat(format_)) {
glCompressedTexSubImage2D(target,
0, // level
- 0, // x-offset
- 0, // y-offset
- size_.width(), size_.height(),
- DataFormat(format_), SizeInBytes(size_, format_),
- memory_);
+ offset.x(), offset.y(), rect.width(),
+ rect.height(), DataFormat(format_),
+ SizeInBytes(rect.size(), format_), data);
} else {
glTexSubImage2D(target, 0, // level
- 0, // x
- 0, // y
- size_.width(), size_.height(), DataFormat(format_),
- DataType(format_), memory_);
+ offset.x(), offset.y(), rect.width(), rect.height(),
+ DataFormat(format_), DataType(format_), data);
}
return true;
« 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