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

Side by Side Diff: src/codec/SkAndroidCodec.cpp

Issue 2288163003: Add Alpha8 support to SkPNGImageEncoder Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 3 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 | src/codec/SkPngCodec.cpp » ('j') | src/codec/SkPngCodec.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
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 #include "SkAndroidCodec.h" 8 #include "SkAndroidCodec.h"
9 #include "SkCodec.h" 9 #include "SkCodec.h"
10 #include "SkCodecPriv.h" 10 #include "SkCodecPriv.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 case kIndex_8_SkColorType: 79 case kIndex_8_SkColorType:
80 if (kIndex_8_SkColorType == suggestedColorType) { 80 if (kIndex_8_SkColorType == suggestedColorType) {
81 return kIndex_8_SkColorType; 81 return kIndex_8_SkColorType;
82 } 82 }
83 break; 83 break;
84 case kAlpha_8_SkColorType: 84 case kAlpha_8_SkColorType:
85 // Fall through to kGray_8. Before kGray_8_SkColorType existed, 85 // Fall through to kGray_8. Before kGray_8_SkColorType existed,
86 // we allowed clients to request kAlpha_8 when they wanted a 86 // we allowed clients to request kAlpha_8 when they wanted a
87 // grayscale decode. 87 // grayscale decode.
88 case kGray_8_SkColorType: 88 case kGray_8_SkColorType:
89 if (kGray_8_SkColorType == suggestedColorType) { 89 if (kGray_8_SkColorType == suggestedColorType ||
90 kAlpha_8_SkColorType == suggestedColorType)
91 {
90 return kGray_8_SkColorType; 92 return kGray_8_SkColorType;
91 } 93 }
92 break; 94 break;
93 case kRGB_565_SkColorType: 95 case kRGB_565_SkColorType:
94 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) { 96 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) {
95 return kRGB_565_SkColorType; 97 return kRGB_565_SkColorType;
96 } 98 }
97 break; 99 break;
98 default: 100 default:
99 break; 101 break;
100 } 102 }
101 103
102 // Android has limited support for kGray_8 (using kAlpha_8). We will not 104 // Android has limited support for kGray_8 and kAlpha_8. We will not use th ese types for
103 // use kGray_8 for Android unless they specifically ask for it. 105 // Android unless they specifically ask for it.
104 if (kGray_8_SkColorType == suggestedColorType) { 106 if (kGray_8_SkColorType == suggestedColorType || kAlpha_8_SkColorType == sug gestedColorType) {
105 return kN32_SkColorType; 107 return kN32_SkColorType;
106 } 108 }
107 109
108 // This may be kN32_SkColorType or kIndex_8_SkColorType. 110 // This may be kN32_SkColorType or kIndex_8_SkColorType.
109 return suggestedColorType; 111 return suggestedColorType;
110 } 112 }
111 113
112 SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) { 114 SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) {
113 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) { 115 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) {
114 return kOpaque_SkAlphaType; 116 return kOpaque_SkAlphaType;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 190 }
189 } 191 }
190 192
191 return this->onGetAndroidPixels(info, pixels, rowBytes, *options); 193 return this->onGetAndroidPixels(info, pixels, rowBytes, *options);
192 } 194 }
193 195
194 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void* pixels, 196 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void* pixels,
195 size_t rowBytes) { 197 size_t rowBytes) {
196 return this->getAndroidPixels(info, pixels, rowBytes, nullptr); 198 return this->getAndroidPixels(info, pixels, rowBytes, nullptr);
197 } 199 }
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkPngCodec.cpp » ('j') | src/codec/SkPngCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698