| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 void ErrorExit(jpeg_common_struct* cinfo) { | 36 void ErrorExit(jpeg_common_struct* cinfo) { |
| 37 CoderErrorMgr *err = reinterpret_cast<CoderErrorMgr*>(cinfo->err); | 37 CoderErrorMgr *err = reinterpret_cast<CoderErrorMgr*>(cinfo->err); |
| 38 | 38 |
| 39 // Return control to the setjmp point. | 39 // Return control to the setjmp point. |
| 40 longjmp(err->setjmp_buffer, false); | 40 longjmp(err->setjmp_buffer, false); |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 // This method helps identify at run time which library chromium is using. |
| 46 JPEGCodec::LibraryVariant JPEGCodec::JpegLibraryVariant() { |
| 47 #if defined(USE_SYSTEM_LIBJPEG) |
| 48 return SYSTEM_LIBJPEG; |
| 49 #elif defined(USE_LIBJPEG_TURBO) |
| 50 return LIBJPEG_TURBO; |
| 51 #else |
| 52 return IJG_LIBJPEG; |
| 53 #endif |
| 54 } |
| 55 |
| 45 // Encoder --------------------------------------------------------------------- | 56 // Encoder --------------------------------------------------------------------- |
| 46 // | 57 // |
| 47 // This code is based on nsJPEGEncoder from Mozilla. | 58 // This code is based on nsJPEGEncoder from Mozilla. |
| 48 // Copyright 2005 Google Inc. (Brett Wilson, contributor) | 59 // Copyright 2005 Google Inc. (Brett Wilson, contributor) |
| 49 | 60 |
| 50 namespace { | 61 namespace { |
| 51 | 62 |
| 52 // Initial size for the output buffer in the JpegEncoderState below. | 63 // Initial size for the output buffer in the JpegEncoderState below. |
| 53 static const int initial_output_buffer_size = 8192; | 64 static const int initial_output_buffer_size = 8192; |
| 54 | 65 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 612 |
| 602 SkBitmap* bitmap = new SkBitmap(); | 613 SkBitmap* bitmap = new SkBitmap(); |
| 603 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 614 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 604 bitmap->allocPixels(); | 615 bitmap->allocPixels(); |
| 605 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length); | 616 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length); |
| 606 | 617 |
| 607 return bitmap; | 618 return bitmap; |
| 608 } | 619 } |
| 609 | 620 |
| 610 } // namespace gfx | 621 } // namespace gfx |
| OLD | NEW |