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

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: Fix raster-on-demand codepath 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..c24b2c47f760efc9383eca6e11c1cc9fd340ae5a 100644
--- a/cc/scheduler/texture_uploader.cc
+++ b/cc/scheduler/texture_uploader.cc
@@ -77,13 +77,15 @@ unsigned TextureUploader::Query::Value() {
TextureUploader::TextureUploader(WebKit::WebGraphicsContext3D* context,
bool use_map_tex_sub_image,
- bool use_shallow_flush)
+ bool use_shallow_flush,
+ bool use_16_bit_textures)
: context_(context),
num_blocking_texture_uploads_(0),
use_map_tex_sub_image_(use_map_tex_sub_image),
sub_image_size_(0),
use_shallow_flush_(use_shallow_flush),
- num_texture_uploads_since_last_flush_(0) {
+ num_texture_uploads_since_last_flush_(0),
+ use_16_bit_textures_(use_16_bit_textures) {
for (size_t i = kUploadHistorySizeInitial; i > 0; i--)
textures_per_second_history_.insert(kDefaultEstimatedTexturesPerSecond);
}
@@ -207,11 +209,13 @@ 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);
+ unsigned int bytes_per_pixel = Resource::BytesPerPixel(format,
+ use_16_bit_textures_);
+ // TODO(kaanb): anything to do to GL_UNPACK_ALIGNMENT for 16_bit?
Sami 2013/09/05 14:13:26 Yes, it needs to be set to 2 bytes. Otherwise odd-
kaanb 2013/09/06 02:05:54 Silly question, how and where should it be set?
// Use 4-byte row alignment (OpenGL default) for upload performance.
// Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
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()) {
@@ -233,6 +237,8 @@ void TextureUploader::UploadWithTexSubImage(const uint8* image,
pixel_source = &sub_image_[0];
}
+ GLenum texture_data_type = use_16_bit_textures_
+ ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_BYTE;
context_->texSubImage2D(GL_TEXTURE_2D,
0,
dest_offset.x(),
@@ -240,7 +246,7 @@ void TextureUploader::UploadWithTexSubImage(const uint8* image,
source_rect.width(),
source_rect.height(),
format,
- GL_UNSIGNED_BYTE,
+ texture_data_type,
pixel_source);
}
@@ -277,12 +283,16 @@ 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);
+ unsigned int bytes_per_pixel = Resource::BytesPerPixel(format,
+ use_16_bit_textures_);
+ // TODO(kaanb): anything to do to GL_UNPACK_ALIGNMENT for 16 bit?
// Use 4-byte row alignment (OpenGL default) for upload performance.
// Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
unsigned int upload_image_stride =
- RoundUp(bytes_per_pixel * source_rect.width(), 4u);
+ RoundUp(bytes_per_pixel * source_rect.width(), bytes_per_pixel);
+ GLenum texture_data_type = use_16_bit_textures_
+ ? GL_UNSIGNED_SHORT_4_4_4_4 : GL_UNSIGNED_BYTE;
// Upload tile data via a mapped transfer buffer
uint8* pixel_dest = static_cast<uint8*>(
context_->mapTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
@@ -292,7 +302,7 @@ void TextureUploader::UploadWithMapTexSubImage(const uint8* image,
source_rect.width(),
source_rect.height(),
format,
- GL_UNSIGNED_BYTE,
+ texture_data_type,
GL_WRITE_ONLY));
if (!pixel_dest) {

Powered by Google App Engine
This is Rietveld 408576698