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

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

Issue 249853003: add one-channel output support to webp encoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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 /* 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 const uint8_t* SK_RESTRICT src = (const uint8_t*)in; 540 const uint8_t* SK_RESTRICT src = (const uint8_t*)in;
541 for (int i = 0; i < width; ++i) { 541 for (int i = 0; i < width; ++i) {
542 const uint32_t c = ctable[*src++]; 542 const uint32_t c = ctable[*src++];
543 rgb[0] = SkGetPackedR32(c); 543 rgb[0] = SkGetPackedR32(c);
544 rgb[1] = SkGetPackedG32(c); 544 rgb[1] = SkGetPackedG32(c);
545 rgb[2] = SkGetPackedB32(c); 545 rgb[2] = SkGetPackedB32(c);
546 rgb += 3; 546 rgb += 3;
547 } 547 }
548 } 548 }
549 549
550 static void Alpha8_To_RGB(const uint8_t* in, uint8_t* rgb, int width,
551 const SkPMColor* SK_RESTRICT ctable) {
552 const uint8_t* SK_RESTRICT src = (const uint8_t*)in;
553 for (int i = 0; i < width; ++i) {
554 rgb[0] = rgb[1] = rgb[2] = *src++;
555 rgb += 3;
556 }
557 }
558
550 static ScanlineImporter ChooseImporter(const SkBitmap::Config& config, 559 static ScanlineImporter ChooseImporter(const SkBitmap::Config& config,
551 bool hasAlpha, 560 bool hasAlpha,
552 int* bpp) { 561 int* bpp) {
553 switch (config) { 562 switch (config) {
554 case SkBitmap::kARGB_8888_Config: 563 case SkBitmap::kARGB_8888_Config:
555 if (hasAlpha) { 564 if (hasAlpha) {
556 *bpp = 4; 565 *bpp = 4;
557 return ARGB_8888_To_RGBA; 566 return ARGB_8888_To_RGBA;
558 } else { 567 } else {
559 *bpp = 3; 568 *bpp = 3;
560 return ARGB_8888_To_RGB; 569 return ARGB_8888_To_RGB;
561 } 570 }
562 case SkBitmap::kARGB_4444_Config: 571 case SkBitmap::kARGB_4444_Config:
563 if (hasAlpha) { 572 if (hasAlpha) {
564 *bpp = 4; 573 *bpp = 4;
565 return ARGB_4444_To_RGBA; 574 return ARGB_4444_To_RGBA;
566 } else { 575 } else {
567 *bpp = 3; 576 *bpp = 3;
568 return ARGB_4444_To_RGB; 577 return ARGB_4444_To_RGB;
569 } 578 }
570 case SkBitmap::kRGB_565_Config: 579 case SkBitmap::kRGB_565_Config:
571 *bpp = 3; 580 *bpp = 3;
572 return RGB_565_To_RGB; 581 return RGB_565_To_RGB;
573 case SkBitmap::kIndex8_Config: 582 case SkBitmap::kIndex8_Config:
574 *bpp = 3; 583 *bpp = 3;
575 return Index8_To_RGB; 584 return Index8_To_RGB;
585 case SkBitmap::kA8_Config:
586 *bpp = 3;
587 return Alpha8_To_RGB;
576 default: 588 default:
577 return NULL; 589 return NULL;
578 } 590 }
579 } 591 }
580 592
581 static int stream_writer(const uint8_t* data, size_t data_size, 593 static int stream_writer(const uint8_t* data, size_t data_size,
582 const WebPPicture* const picture) { 594 const WebPPicture* const picture) {
583 SkWStream* const stream = (SkWStream*)picture->custom_ptr; 595 SkWStream* const stream = (SkWStream*)picture->custom_ptr;
584 return stream->write(data, data_size) ? 1 : 0; 596 return stream->write(data, data_size) ? 1 : 0;
585 } 597 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 return SkImageDecoder::kUnknown_Format; 686 return SkImageDecoder::kUnknown_Format;
675 } 687 }
676 688
677 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 689 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
678 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 690 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L;
679 } 691 }
680 692
681 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); 693 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
682 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); 694 static SkImageDecoder_FormatReg gFormatReg(get_format_webp);
683 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); 695 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory);
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