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

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

Issue 10977073: Delete some unused code found by -Wunused-function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: leiz Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/layout.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/jpeg_codec.h" 5 #include "ui/gfx/codec/jpeg_codec.h"
6 6
7 #include <setjmp.h> 7 #include <setjmp.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 // update the used byte based on the next byte libjpeg would write to 137 // update the used byte based on the next byte libjpeg would write to
138 state->image_buffer_used = cinfo->dest->next_output_byte - &(*state->out)[0]; 138 state->image_buffer_used = cinfo->dest->next_output_byte - &(*state->out)[0];
139 DCHECK(state->image_buffer_used < state->out->size()) << 139 DCHECK(state->image_buffer_used < state->out->size()) <<
140 "JPEG library busted, got a bad image buffer size"; 140 "JPEG library busted, got a bad image buffer size";
141 141
142 // update our buffer so that it exactly encompases the desired data 142 // update our buffer so that it exactly encompases the desired data
143 state->out->resize(state->image_buffer_used); 143 state->out->resize(state->image_buffer_used);
144 } 144 }
145 145
146 #if !defined(JCS_EXTENSIONS)
146 // Converts RGBA to RGB (removing the alpha values) to prepare to send data to 147 // Converts RGBA to RGB (removing the alpha values) to prepare to send data to
147 // libjpeg. This converts one row of data in rgba with the given width in 148 // libjpeg. This converts one row of data in rgba with the given width in
148 // pixels the the given rgb destination buffer (which should have enough space 149 // pixels the the given rgb destination buffer (which should have enough space
149 // reserved for the final data). 150 // reserved for the final data).
150 void StripAlpha(const unsigned char* rgba, int pixel_width, unsigned char* rgb) 151 void StripAlpha(const unsigned char* rgba, int pixel_width, unsigned char* rgb)
151 { 152 {
152 for (int x = 0; x < pixel_width; x++) { 153 for (int x = 0; x < pixel_width; x++) {
153 const unsigned char* pixel_in = &rgba[x * 4]; 154 const unsigned char* pixel_in = &rgba[x * 4];
154 unsigned char* pixel_out = &rgb[x * 3]; 155 unsigned char* pixel_out = &rgb[x * 3];
155 pixel_out[0] = pixel_in[0]; 156 pixel_out[0] = pixel_in[0];
156 pixel_out[1] = pixel_in[1]; 157 pixel_out[1] = pixel_in[1];
157 pixel_out[2] = pixel_in[2]; 158 pixel_out[2] = pixel_in[2];
158 } 159 }
159 } 160 }
160 161
161 // Converts BGRA to RGB by reordering the color components and dropping the 162 // Converts BGRA to RGB by reordering the color components and dropping the
162 // alpha. This converts one row of data in rgba with the given width in 163 // alpha. This converts one row of data in rgba with the given width in
163 // pixels the the given rgb destination buffer (which should have enough space 164 // pixels the the given rgb destination buffer (which should have enough space
164 // reserved for the final data). 165 // reserved for the final data).
165 void BGRAtoRGB(const unsigned char* bgra, int pixel_width, unsigned char* rgb) 166 void BGRAtoRGB(const unsigned char* bgra, int pixel_width, unsigned char* rgb)
166 { 167 {
167 for (int x = 0; x < pixel_width; x++) { 168 for (int x = 0; x < pixel_width; x++) {
168 const unsigned char* pixel_in = &bgra[x * 4]; 169 const unsigned char* pixel_in = &bgra[x * 4];
169 unsigned char* pixel_out = &rgb[x * 3]; 170 unsigned char* pixel_out = &rgb[x * 3];
170 pixel_out[0] = pixel_in[2]; 171 pixel_out[0] = pixel_in[2];
171 pixel_out[1] = pixel_in[1]; 172 pixel_out[1] = pixel_in[1];
172 pixel_out[2] = pixel_in[0]; 173 pixel_out[2] = pixel_in[0];
173 } 174 }
174 } 175 }
176 #endif // !defined(JCS_EXTENSIONS)
175 177
176 // This class destroys the given jpeg_compress object when it goes out of 178 // This class destroys the given jpeg_compress object when it goes out of
177 // scope. It simplifies the error handling in Encode (and even applies to the 179 // scope. It simplifies the error handling in Encode (and even applies to the
178 // success case). 180 // success case).
179 class CompressDestroyer { 181 class CompressDestroyer {
180 public: 182 public:
181 CompressDestroyer() : cinfo_(NULL) { 183 CompressDestroyer() : cinfo_(NULL) {
182 } 184 }
183 ~CompressDestroyer() { 185 ~CompressDestroyer() {
184 DestroyManagedObject(); 186 DestroyManagedObject();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 388
387 // Our source doesn't need any cleanup, so this is a NOP. 389 // Our source doesn't need any cleanup, so this is a NOP.
388 // 390 //
389 // From the JPEG library: 391 // From the JPEG library:
390 // "Terminate source --- called by jpeg_finish_decompress() after all data has 392 // "Terminate source --- called by jpeg_finish_decompress() after all data has
391 // been read to clean up JPEG source manager. NOT called by jpeg_abort() or 393 // been read to clean up JPEG source manager. NOT called by jpeg_abort() or
392 // jpeg_destroy()." 394 // jpeg_destroy()."
393 void TermSource(j_decompress_ptr cinfo) { 395 void TermSource(j_decompress_ptr cinfo) {
394 } 396 }
395 397
398 #if !defined(JCS_EXTENSIONS)
396 // Converts one row of rgb data to rgba data by adding a fully-opaque alpha 399 // Converts one row of rgb data to rgba data by adding a fully-opaque alpha
397 // value. 400 // value.
398 void AddAlpha(const unsigned char* rgb, int pixel_width, unsigned char* rgba) { 401 void AddAlpha(const unsigned char* rgb, int pixel_width, unsigned char* rgba) {
399 for (int x = 0; x < pixel_width; x++) { 402 for (int x = 0; x < pixel_width; x++) {
400 const unsigned char* pixel_in = &rgb[x * 3]; 403 const unsigned char* pixel_in = &rgb[x * 3];
401 unsigned char* pixel_out = &rgba[x * 4]; 404 unsigned char* pixel_out = &rgba[x * 4];
402 pixel_out[0] = pixel_in[0]; 405 pixel_out[0] = pixel_in[0];
403 pixel_out[1] = pixel_in[1]; 406 pixel_out[1] = pixel_in[1];
404 pixel_out[2] = pixel_in[2]; 407 pixel_out[2] = pixel_in[2];
405 pixel_out[3] = 0xff; 408 pixel_out[3] = 0xff;
406 } 409 }
407 } 410 }
408 411
409 // Converts one row of RGB data to BGRA by reordering the color components and 412 // Converts one row of RGB data to BGRA by reordering the color components and
410 // adding alpha values of 0xff. 413 // adding alpha values of 0xff.
411 void RGBtoBGRA(const unsigned char* bgra, int pixel_width, unsigned char* rgb) 414 void RGBtoBGRA(const unsigned char* bgra, int pixel_width, unsigned char* rgb)
412 { 415 {
413 for (int x = 0; x < pixel_width; x++) { 416 for (int x = 0; x < pixel_width; x++) {
414 const unsigned char* pixel_in = &bgra[x * 3]; 417 const unsigned char* pixel_in = &bgra[x * 3];
415 unsigned char* pixel_out = &rgb[x * 4]; 418 unsigned char* pixel_out = &rgb[x * 4];
416 pixel_out[0] = pixel_in[2]; 419 pixel_out[0] = pixel_in[2];
417 pixel_out[1] = pixel_in[1]; 420 pixel_out[1] = pixel_in[1];
418 pixel_out[2] = pixel_in[0]; 421 pixel_out[2] = pixel_in[0];
419 pixel_out[3] = 0xff; 422 pixel_out[3] = 0xff;
420 } 423 }
421 } 424 }
425 #endif // !defined(JCS_EXTENSIONS)
422 426
423 // This class destroys the given jpeg_decompress object when it goes out of 427 // This class destroys the given jpeg_decompress object when it goes out of
424 // scope. It simplifies the error handling in Decode (and even applies to the 428 // scope. It simplifies the error handling in Decode (and even applies to the
425 // success case). 429 // success case).
426 class DecompressDestroyer { 430 class DecompressDestroyer {
427 public: 431 public:
428 DecompressDestroyer() : cinfo_(NULL) { 432 DecompressDestroyer() : cinfo_(NULL) {
429 } 433 }
430 ~DecompressDestroyer() { 434 ~DecompressDestroyer() {
431 DestroyManagedObject(); 435 DestroyManagedObject();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 616
613 SkBitmap* bitmap = new SkBitmap(); 617 SkBitmap* bitmap = new SkBitmap();
614 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h); 618 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h);
615 bitmap->allocPixels(); 619 bitmap->allocPixels();
616 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length); 620 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length);
617 621
618 return bitmap; 622 return bitmap;
619 } 623 }
620 624
621 } // namespace gfx 625 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/base/layout.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698