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

Side by Side Diff: src/images/SkImageDecoder_libwebp.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/SkImageDecoder_libpng.cpp ('k') | src/images/SkImageEncoder_argb.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 2010, The Android Open Source Project 2 * Copyright 2010, The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 * http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 int bpp = -1; 614 int bpp = -1;
615 const ScanlineImporter scanline_import = ChooseImporter(bm.colorType(), hasA lpha, &bpp); 615 const ScanlineImporter scanline_import = ChooseImporter(bm.colorType(), hasA lpha, &bpp);
616 if (NULL == scanline_import) { 616 if (NULL == scanline_import) {
617 return false; 617 return false;
618 } 618 }
619 if (-1 == bpp) { 619 if (-1 == bpp) {
620 return false; 620 return false;
621 } 621 }
622 622
623 SkAutoLockPixels alp(bm); 623 SkAutoLockPixels alp(bm);
624 SkAutoLockColors ctLocker;
625 if (NULL == bm.getPixels()) { 624 if (NULL == bm.getPixels()) {
626 return false; 625 return false;
627 } 626 }
628 627
629 WebPConfig webp_config; 628 WebPConfig webp_config;
630 if (!WebPConfigPreset(&webp_config, WEBP_PRESET_DEFAULT, (float) quality)) { 629 if (!WebPConfigPreset(&webp_config, WEBP_PRESET_DEFAULT, (float) quality)) {
631 return false; 630 return false;
632 } 631 }
633 632
634 WebPPicture pic; 633 WebPPicture pic;
635 WebPPictureInit(&pic); 634 WebPPictureInit(&pic);
636 pic.width = bm.width(); 635 pic.width = bm.width();
637 pic.height = bm.height(); 636 pic.height = bm.height();
638 pic.writer = stream_writer; 637 pic.writer = stream_writer;
639 pic.custom_ptr = (void*)stream; 638 pic.custom_ptr = (void*)stream;
640 639
641 const SkPMColor* colors = ctLocker.lockColors(bm); 640 const SkPMColor* colors = bm.getColorTable() ? bm.getColorTable()->readColor s() : NULL;
642 const uint8_t* src = (uint8_t*)bm.getPixels(); 641 const uint8_t* src = (uint8_t*)bm.getPixels();
643 const int rgbStride = pic.width * bpp; 642 const int rgbStride = pic.width * bpp;
644 643
645 // Import (for each scanline) the bit-map image (in appropriate color-space) 644 // Import (for each scanline) the bit-map image (in appropriate color-space)
646 // to RGB color space. 645 // to RGB color space.
647 uint8_t* rgb = new uint8_t[rgbStride * pic.height]; 646 uint8_t* rgb = new uint8_t[rgbStride * pic.height];
648 for (int y = 0; y < pic.height; ++y) { 647 for (int y = 0; y < pic.height; ++y) {
649 scanline_import(src + y * bm.rowBytes(), rgb + y * rgbStride, 648 scanline_import(src + y * bm.rowBytes(), rgb + y * rgbStride,
650 pic.width, colors); 649 pic.width, colors);
651 } 650 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 return SkImageDecoder::kUnknown_Format; 687 return SkImageDecoder::kUnknown_Format;
689 } 688 }
690 689
691 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 690 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
692 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 691 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L;
693 } 692 }
694 693
695 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); 694 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
696 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); 695 static SkImageDecoder_FormatReg gFormatReg(get_format_webp);
697 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); 696 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | src/images/SkImageEncoder_argb.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698