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

Unified Diff: ui/gfx/codec/jpeg_codec.cc

Issue 404793004: ui/gfx: optimize color format conversions by using memcpy in jpeg_codec.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/codec/jpeg_codec.cc
diff --git a/ui/gfx/codec/jpeg_codec.cc b/ui/gfx/codec/jpeg_codec.cc
index 5c13e5091d9b9ab2792fe31889ac383bc741b9f9..8a08fe0291afcc8a61c6b4f560396a4a50057da8 100644
--- a/ui/gfx/codec/jpeg_codec.cc
+++ b/ui/gfx/codec/jpeg_codec.cc
@@ -150,13 +150,8 @@ void TermDestination(jpeg_compress_struct* cinfo) {
// reserved for the final data).
void StripAlpha(const unsigned char* rgba, int pixel_width, unsigned char* rgb)
{
- for (int x = 0; x < pixel_width; x++) {
- const unsigned char* pixel_in = &rgba[x * 4];
- unsigned char* pixel_out = &rgb[x * 3];
- pixel_out[0] = pixel_in[0];
- pixel_out[1] = pixel_in[1];
- pixel_out[2] = pixel_in[2];
- }
+ for (int x = 0; x < pixel_width; x++)
+ memcpy(&rgb[x * 3], &rgba[x * 4], 3);
}
// Converts BGRA to RGB by reordering the color components and dropping the
@@ -407,12 +402,8 @@ void TermSource(j_decompress_ptr cinfo) {
// value.
void AddAlpha(const unsigned char* rgb, int pixel_width, unsigned char* rgba) {
for (int x = 0; x < pixel_width; x++) {
- const unsigned char* pixel_in = &rgb[x * 3];
- unsigned char* pixel_out = &rgba[x * 4];
- pixel_out[0] = pixel_in[0];
- pixel_out[1] = pixel_in[1];
- pixel_out[2] = pixel_in[2];
- pixel_out[3] = 0xff;
+ memcpy(&rgba[x * 4], &rgb[x * 3], 3);
+ rgba[x * 4 + 3] = 0xff;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698