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

Unified Diff: cc/scheduler/texture_uploader.cc

Issue 27973002: cc: Adding ETC1 support to UIResourceBitmap and ResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: latest comments Created 7 years, 2 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 | « cc/scheduler/texture_uploader.h ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/texture_uploader.cc
diff --git a/cc/scheduler/texture_uploader.cc b/cc/scheduler/texture_uploader.cc
index cebc98689118949bb9081a33b215552133db0aa4..ba4e3721758f56e12720065c08f6655789bc6562 100644
--- a/cc/scheduler/texture_uploader.cc
+++ b/cc/scheduler/texture_uploader.cc
@@ -143,6 +143,13 @@ void TextureUploader::Upload(const uint8* image,
if (is_full_upload)
BeginQuery();
+ if (format == ETC1) {
+ // ETC1 does not support subimage uploads.
+ DCHECK(is_full_upload);
+ UploadWithTexImageETC1(image, size);
+ return;
+ }
+
if (use_map_tex_sub_image_) {
UploadWithMapTexSubImage(
image, image_rect, source_rect, dest_offset, format);
@@ -190,7 +197,7 @@ void TextureUploader::UploadWithTexSubImage(const uint8* image,
gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
const uint8* pixel_source;
- unsigned bytes_per_pixel = BytesPerPixel(format);
+ unsigned bytes_per_pixel = BitsPerPixel(format) / 8;
// Use 4-byte row alignment (OpenGL default) for upload performance.
// Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
unsigned upload_image_stride =
@@ -239,11 +246,13 @@ void TextureUploader::UploadWithMapTexSubImage(const uint8* image,
if (source_rect.IsEmpty())
return;
DCHECK(image);
+ // Compressed textures have no implementation of mapTexSubImage.
+ DCHECK_NE(ETC1, format);
// Offset from image-rect to source-rect.
gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
- unsigned bytes_per_pixel = BytesPerPixel(format);
+ unsigned bytes_per_pixel = BitsPerPixel(format) / 8;
// Use 4-byte row alignment (OpenGL default) for upload performance.
// Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
unsigned upload_image_stride =
@@ -285,6 +294,22 @@ void TextureUploader::UploadWithMapTexSubImage(const uint8* image,
context_->unmapTexSubImage2DCHROMIUM(pixel_dest);
}
+void TextureUploader::UploadWithTexImageETC1(const uint8* image,
+ gfx::Size size) {
+ TRACE_EVENT0("cc", "TextureUploader::UploadWithTexImageETC1");
+ DCHECK_EQ(0, size.width() % 4);
+ DCHECK_EQ(0, size.height() % 4);
+
+ context_->compressedTexImage2D(GL_TEXTURE_2D,
+ 0,
+ GLInternalFormat(ETC1),
+ size.width(),
+ size.height(),
+ 0,
+ Resource::MemorySizeBytes(size, ETC1),
+ image);
+}
+
void TextureUploader::ProcessQueries() {
while (!pending_queries_.empty()) {
if (pending_queries_.front()->IsPending())
« no previous file with comments | « cc/scheduler/texture_uploader.h ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698