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

Unified Diff: cc/scheduler/texture_uploader.cc

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and feedback Created 7 years, 3 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
Index: cc/scheduler/texture_uploader.cc
diff --git a/cc/scheduler/texture_uploader.cc b/cc/scheduler/texture_uploader.cc
index 920c38e669275d0992d6b5166a1683464aecaad4..32db5e4fd8a8eba2af213bb0c704d4c0d2c5db1f 100644
--- a/cc/scheduler/texture_uploader.cc
+++ b/cc/scheduler/texture_uploader.cc
@@ -136,7 +136,8 @@ void TextureUploader::Upload(const uint8* image,
gfx::Rect source_rect,
gfx::Vector2d dest_offset,
GLenum format,
- gfx::Size size) {
+ gfx::Size size,
+ ResourceProvider::TextureType type) {
CHECK(image_rect.Contains(source_rect));
bool is_full_upload = dest_offset.IsZero() && source_rect.size() == size;
@@ -146,9 +147,10 @@ void TextureUploader::Upload(const uint8* image,
if (use_map_tex_sub_image_) {
UploadWithMapTexSubImage(
- image, image_rect, source_rect, dest_offset, format);
+ image, image_rect, source_rect, dest_offset, format, type);
} else {
- UploadWithTexSubImage(image, image_rect, source_rect, dest_offset, format);
+ UploadWithTexSubImage(
+ image, image_rect, source_rect, dest_offset, format, type);
}
if (is_full_upload)
@@ -174,11 +176,13 @@ void TextureUploader::ReleaseCachedQueries() {
available_queries_.clear();
}
-void TextureUploader::UploadWithTexSubImage(const uint8* image,
- gfx::Rect image_rect,
- gfx::Rect source_rect,
- gfx::Vector2d dest_offset,
- GLenum format) {
+void TextureUploader::UploadWithTexSubImage(
+ const uint8* image,
+ gfx::Rect image_rect,
+ gfx::Rect source_rect,
+ gfx::Vector2d dest_offset,
+ GLenum format,
+ ResourceProvider::TextureType type) {
// Instrumentation to debug issue 156107
int source_rect_x = source_rect.x();
int source_rect_y = source_rect.y();
@@ -207,11 +211,11 @@ void TextureUploader::UploadWithTexSubImage(const uint8* image,
gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
const uint8* pixel_source;
- unsigned int bytes_per_pixel = Resource::BytesPerPixel(format);
- // Use 4-byte row alignment (OpenGL default) for upload performance.
- // Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
+ unsigned int bytes_per_pixel =
+ ResourceProvider::BytesPerPixel(format, type);
+ DCHECK_EQ(0, source_rect.width() % 2);
unsigned int upload_image_stride =
- RoundUp(bytes_per_pixel * source_rect.width(), 4u);
+ RoundUp(bytes_per_pixel * source_rect.width(), bytes_per_pixel);
if (upload_image_stride == image_rect.width() * bytes_per_pixel &&
!offset.x()) {
@@ -240,15 +244,17 @@ void TextureUploader::UploadWithTexSubImage(const uint8* image,
source_rect.width(),
source_rect.height(),
format,
- GL_UNSIGNED_BYTE,
+ ResourceProvider::GetTextureDataType(type),
pixel_source);
}
-void TextureUploader::UploadWithMapTexSubImage(const uint8* image,
- gfx::Rect image_rect,
- gfx::Rect source_rect,
- gfx::Vector2d dest_offset,
- GLenum format) {
+void TextureUploader::UploadWithMapTexSubImage(
+ const uint8* image,
+ gfx::Rect image_rect,
+ gfx::Rect source_rect,
+ gfx::Vector2d dest_offset,
+ GLenum format,
+ ResourceProvider::TextureType type) {
// Instrumentation to debug issue 156107
int source_rect_x = source_rect.x();
int source_rect_y = source_rect.y();
@@ -277,13 +283,12 @@ void TextureUploader::UploadWithMapTexSubImage(const uint8* image,
// Offset from image-rect to source-rect.
gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
- unsigned int bytes_per_pixel = Resource::BytesPerPixel(format);
- // Use 4-byte row alignment (OpenGL default) for upload performance.
- // Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
+ unsigned int bytes_per_pixel =
+ ResourceProvider::BytesPerPixel(format, type);
+ DCHECK_EQ(0, source_rect.width() % 2);
unsigned int upload_image_stride =
- RoundUp(bytes_per_pixel * source_rect.width(), 4u);
+ RoundUp(bytes_per_pixel * source_rect.width(), bytes_per_pixel);
- // Upload tile data via a mapped transfer buffer
uint8* pixel_dest = static_cast<uint8*>(
context_->mapTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
0,
@@ -292,11 +297,13 @@ void TextureUploader::UploadWithMapTexSubImage(const uint8* image,
source_rect.width(),
source_rect.height(),
format,
- GL_UNSIGNED_BYTE,
+ ResourceProvider::GetTextureDataType(
+ type),
GL_WRITE_ONLY));
if (!pixel_dest) {
- UploadWithTexSubImage(image, image_rect, source_rect, dest_offset, format);
+ UploadWithTexSubImage(
+ image, image_rect, source_rect, dest_offset, format, type);
return;
}

Powered by Google App Engine
This is Rietveld 408576698