OLD | NEW |
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 "SkCodec.h" | 8 #include "SkCodec.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkSampler.h" | 10 #include "SkSampler.h" |
11 #include "SkUtils.h" | 11 #include "SkUtils.h" |
12 | 12 |
13 void SkSampler::Fill(const SkImageInfo& info, void* dst, size_t rowBytes, | 13 void SkSampler::Fill(const SkImageInfo& info, void* dst, size_t rowBytes, |
14 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) { | 14 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) { |
15 SkASSERT(dst != nullptr); | 15 SkASSERT(dst != nullptr); |
16 | 16 |
17 // Calculate bytes to fill. We use getSafeSize since the last row may not b
e padded. | 17 // Calculate bytes to fill. We use getSafeSize since the last row may not b
e padded. |
18 const size_t bytesToFill = info.getSafeSize(rowBytes); | 18 const size_t bytesToFill = info.getSafeSize(rowBytes); |
19 const int width = info.width(); | 19 const int width = info.width(); |
20 const int numRows = info.height(); | 20 const int numRows = info.height(); |
21 | 21 |
22 // Use the proper memset routine to fill the remaining bytes | 22 // Use the proper memset routine to fill the remaining bytes |
23 switch (info.colorType()) { | 23 switch (info.colorType()) { |
24 case kN32_SkColorType: { | 24 case kRGBA_8888_SkColorType: |
| 25 case kBGRA_8888_SkColorType: { |
25 // If memory is zero initialized, we may not need to fill | 26 // If memory is zero initialized, we may not need to fill |
26 uint32_t color = colorOrIndex; | 27 uint32_t color = colorOrIndex; |
27 if (SkCodec::kYes_ZeroInitialized == zeroInit && 0 == color) { | 28 if (SkCodec::kYes_ZeroInitialized == zeroInit && 0 == color) { |
28 return; | 29 return; |
29 } | 30 } |
30 | 31 |
31 // We must fill row by row in the case of unaligned row bytes | 32 // We must fill row by row in the case of unaligned row bytes |
32 if (SkIsAlign4((size_t) dst) && SkIsAlign4(rowBytes)) { | 33 if (SkIsAlign4((size_t) dst) && SkIsAlign4(rowBytes)) { |
33 sk_memset32((uint32_t*) dst, color, | 34 sk_memset32((uint32_t*) dst, color, |
34 (uint32_t) bytesToFill / sizeof(SkPMColor)); | 35 (uint32_t) bytesToFill / sizeof(SkPMColor)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 94 } |
94 | 95 |
95 memset(dst, (uint8_t) colorOrIndex, bytesToFill); | 96 memset(dst, (uint8_t) colorOrIndex, bytesToFill); |
96 break; | 97 break; |
97 default: | 98 default: |
98 SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing
nothing.\n"); | 99 SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing
nothing.\n"); |
99 SkASSERT(false); | 100 SkASSERT(false); |
100 break; | 101 break; |
101 } | 102 } |
102 } | 103 } |
OLD | NEW |