Index: cc/scheduler/texture_uploader.cc |
diff --git a/cc/scheduler/texture_uploader.cc b/cc/scheduler/texture_uploader.cc |
index 920c38e669275d0992d6b5166a1683464aecaad4..c6c401b24f6a79e4525d4f24bd4e934b6011ea93 100644 |
--- a/cc/scheduler/texture_uploader.cc |
+++ b/cc/scheduler/texture_uploader.cc |
@@ -135,7 +135,7 @@ void TextureUploader::Upload(const uint8* image, |
gfx::Rect image_rect, |
gfx::Rect source_rect, |
gfx::Vector2d dest_offset, |
- GLenum format, |
+ ResourceProvider::Format format, |
gfx::Size size) { |
CHECK(image_rect.Contains(source_rect)); |
@@ -148,7 +148,8 @@ void TextureUploader::Upload(const uint8* image, |
UploadWithMapTexSubImage( |
image, image_rect, source_rect, dest_offset, format); |
} else { |
- UploadWithTexSubImage(image, image_rect, source_rect, dest_offset, format); |
+ UploadWithTexSubImage( |
+ image, image_rect, source_rect, dest_offset, format); |
} |
if (is_full_upload) |
@@ -174,11 +175,12 @@ 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, |
+ ResourceProvider::Format format) { |
// Instrumentation to debug issue 156107 |
int source_rect_x = source_rect.x(); |
int source_rect_y = source_rect.y(); |
@@ -207,11 +209,12 @@ 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); |
+ DCHECK(format != ResourceProvider::RGBA_4444 || |
+ (source_rect.width() % 2) == 0); |
unsigned int upload_image_stride = |
- RoundUp(bytes_per_pixel * source_rect.width(), 4u); |
+ RoundUp(bytes_per_pixel * source_rect.width(), |
+ ResourceProvider::GetStride(format)); |
piman
2013/09/13 04:56:51
I don't understand the change here, to accomodate
kaanb
2013/09/13 19:57:39
Done.
|
if (upload_image_stride == image_rect.width() * bytes_per_pixel && |
!offset.x()) { |
@@ -239,16 +242,17 @@ void TextureUploader::UploadWithTexSubImage(const uint8* image, |
dest_offset.y(), |
source_rect.width(), |
source_rect.height(), |
- format, |
- GL_UNSIGNED_BYTE, |
+ ResourceProvider::GetGLDataFormat(format), |
+ ResourceProvider::GetGLDataType(format), |
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, |
+ ResourceProvider::Format format) { |
// Instrumentation to debug issue 156107 |
int source_rect_x = source_rect.x(); |
int source_rect_y = source_rect.y(); |
@@ -277,13 +281,13 @@ 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); |
enne (OOO)
2013/09/13 01:39:44
unsigned int => size_t, here and elsewhere.
kaanb
2013/09/13 03:43:56
Done.
|
+ DCHECK(format != ResourceProvider::RGBA_4444 || |
+ (source_rect.width() % 2) == 0); |
unsigned int upload_image_stride = |
- RoundUp(bytes_per_pixel * source_rect.width(), 4u); |
+ RoundUp(bytes_per_pixel * source_rect.width(), |
+ ResourceProvider::GetStride(format)); |
- // Upload tile data via a mapped transfer buffer |
uint8* pixel_dest = static_cast<uint8*>( |
context_->mapTexSubImage2DCHROMIUM(GL_TEXTURE_2D, |
0, |
@@ -291,8 +295,10 @@ void TextureUploader::UploadWithMapTexSubImage(const uint8* image, |
dest_offset.y(), |
source_rect.width(), |
source_rect.height(), |
- format, |
- GL_UNSIGNED_BYTE, |
+ ResourceProvider::GetGLDataFormat( |
+ format), |
+ ResourceProvider::GetGLDataType( |
+ format), |
GL_WRITE_ONLY)); |
if (!pixel_dest) { |