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

Side by Side Diff: ui/gfx/codec/png_codec.cc

Issue 397673002: ui/gfx: optimize RGBA to RGB conversion by using memcpy in png_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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/codec/png_codec.h" 5 #include "ui/gfx/codec/png_codec.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "third_party/libpng/png.h" 9 #include "third_party/libpng/png.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 15 matching lines...) Expand all
26 unsigned char* pixel_out = &output[x * 4]; 26 unsigned char* pixel_out = &output[x * 4];
27 pixel_out[0] = pixel_in[2]; 27 pixel_out[0] = pixel_in[2];
28 pixel_out[1] = pixel_in[1]; 28 pixel_out[1] = pixel_in[1];
29 pixel_out[2] = pixel_in[0]; 29 pixel_out[2] = pixel_in[0];
30 pixel_out[3] = pixel_in[3]; 30 pixel_out[3] = pixel_in[3];
31 } 31 }
32 } 32 }
33 33
34 void ConvertRGBAtoRGB(const unsigned char* rgba, int pixel_width, 34 void ConvertRGBAtoRGB(const unsigned char* rgba, int pixel_width,
35 unsigned char* rgb, bool* is_opaque) { 35 unsigned char* rgb, bool* is_opaque) {
36 for (int x = 0; x < pixel_width; x++) { 36 for (int x = 0; x < pixel_width; x++)
37 const unsigned char* pixel_in = &rgba[x * 4]; 37 memcpy(&rgb[x * 3], &rgba[x * 4], 3);
38 unsigned char* pixel_out = &rgb[x * 3];
39 pixel_out[0] = pixel_in[0];
40 pixel_out[1] = pixel_in[1];
41 pixel_out[2] = pixel_in[2];
42 }
43 } 38 }
44 39
45 void ConvertSkiatoRGB(const unsigned char* skia, int pixel_width, 40 void ConvertSkiatoRGB(const unsigned char* skia, int pixel_width,
46 unsigned char* rgb, bool* is_opaque) { 41 unsigned char* rgb, bool* is_opaque) {
47 for (int x = 0; x < pixel_width; x++) { 42 for (int x = 0; x < pixel_width; x++) {
48 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[x * 4]); 43 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[x * 4]);
49 unsigned char* pixel_out = &rgb[x * 3]; 44 unsigned char* pixel_out = &rgb[x * 3];
50 45
51 int alpha = SkGetPackedA32(pixel_in); 46 int alpha = SkGetPackedA32(pixel_in);
52 if (alpha != 0 && alpha != 255) { 47 if (alpha != 0 && alpha != 255) {
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 801 }
807 802
808 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) 803 PNGCodec::Comment::Comment(const std::string& k, const std::string& t)
809 : key(k), text(t) { 804 : key(k), text(t) {
810 } 805 }
811 806
812 PNGCodec::Comment::~Comment() { 807 PNGCodec::Comment::~Comment() {
813 } 808 }
814 809
815 } // namespace gfx 810 } // namespace gfx
OLDNEW
« 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