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

Side by Side Diff: src/images/SkImageDecoder_libjpeg.cpp

Issue 719213008: SkColorTable locking serves no purpose anymore. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: oops Created 6 years 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 | « src/images/SkDecodingImageGenerator.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 if (NULL == bm.getPixels()) { 1348 if (NULL == bm.getPixels()) {
1349 return false; 1349 return false;
1350 } 1350 }
1351 1351
1352 jpeg_compress_struct cinfo; 1352 jpeg_compress_struct cinfo;
1353 skjpeg_error_mgr sk_err; 1353 skjpeg_error_mgr sk_err;
1354 skjpeg_destination_mgr sk_wstream(stream); 1354 skjpeg_destination_mgr sk_wstream(stream);
1355 1355
1356 // allocate these before set call setjmp 1356 // allocate these before set call setjmp
1357 SkAutoMalloc oneRow; 1357 SkAutoMalloc oneRow;
1358 SkAutoLockColors ctLocker;
1359 1358
1360 cinfo.err = jpeg_std_error(&sk_err); 1359 cinfo.err = jpeg_std_error(&sk_err);
1361 sk_err.error_exit = skjpeg_error_exit; 1360 sk_err.error_exit = skjpeg_error_exit;
1362 if (setjmp(sk_err.fJmpBuf)) { 1361 if (setjmp(sk_err.fJmpBuf)) {
1363 return false; 1362 return false;
1364 } 1363 }
1365 1364
1366 // Keep after setjmp or mark volatile. 1365 // Keep after setjmp or mark volatile.
1367 const WriteScanline writer = ChooseWriter(bm); 1366 const WriteScanline writer = ChooseWriter(bm);
1368 if (NULL == writer) { 1367 if (NULL == writer) {
(...skipping 16 matching lines...) Expand all
1385 jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); 1384 jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
1386 #ifdef DCT_IFAST_SUPPORTED 1385 #ifdef DCT_IFAST_SUPPORTED
1387 cinfo.dct_method = JDCT_IFAST; 1386 cinfo.dct_method = JDCT_IFAST;
1388 #endif 1387 #endif
1389 1388
1390 jpeg_start_compress(&cinfo, TRUE); 1389 jpeg_start_compress(&cinfo, TRUE);
1391 1390
1392 const int width = bm.width(); 1391 const int width = bm.width();
1393 uint8_t* oneRowP = (uint8_t*)oneRow.reset(width * 3); 1392 uint8_t* oneRowP = (uint8_t*)oneRow.reset(width * 3);
1394 1393
1395 const SkPMColor* colors = ctLocker.lockColors(bm); 1394 const SkPMColor* colors = bm.getColorTable() ? bm.getColorTable()->readC olors() : NULL;
1396 const void* srcRow = bm.getPixels(); 1395 const void* srcRow = bm.getPixels();
1397 1396
1398 while (cinfo.next_scanline < cinfo.image_height) { 1397 while (cinfo.next_scanline < cinfo.image_height) {
1399 JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ 1398 JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
1400 1399
1401 writer(oneRowP, srcRow, width, colors); 1400 writer(oneRowP, srcRow, width, colors);
1402 row_pointer[0] = oneRowP; 1401 row_pointer[0] = oneRowP;
1403 (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); 1402 (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
1404 srcRow = (const void*)((const char*)srcRow + bm.rowBytes()); 1403 srcRow = (const void*)((const char*)srcRow + bm.rowBytes());
1405 } 1404 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 return SkImageDecoder::kUnknown_Format; 1446 return SkImageDecoder::kUnknown_Format;
1448 } 1447 }
1449 1448
1450 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { 1449 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
1451 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; 1450 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
1452 } 1451 }
1453 1452
1454 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); 1453 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory);
1455 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); 1454 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg);
1456 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); 1455 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory);
OLDNEW
« no previous file with comments | « src/images/SkDecodingImageGenerator.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698