OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "picture_utils.h" | 8 #include "picture_utils.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
11 #include "SkHalf.h" | 11 #include "SkHalf.h" |
12 #include "SkImageEncoder.h" | 12 #include "SkImageEncoder.h" |
13 #include "SkOSFile.h" | 13 #include "SkOSFile.h" |
14 #include "SkPM4fPriv.h" | 14 #include "SkPM4fPriv.h" |
15 #include "SkPicture.h" | 15 #include "SkPicture.h" |
16 #include "SkStream.h" | 16 #include "SkStream.h" |
17 #include "SkString.h" | 17 #include "SkString.h" |
18 | 18 |
19 namespace sk_tools { | 19 namespace sk_tools { |
20 void force_all_opaque(const SkBitmap& bitmap) { | 20 void force_all_opaque(const SkBitmap& bitmap) { |
21 SkASSERT(nullptr == bitmap.getTexture()); | |
22 SkASSERT(kN32_SkColorType == bitmap.colorType()); | 21 SkASSERT(kN32_SkColorType == bitmap.colorType()); |
23 if (bitmap.getTexture() || kN32_SkColorType == bitmap.colorType()) { | 22 if (kN32_SkColorType == bitmap.colorType()) { |
24 return; | 23 return; |
25 } | 24 } |
26 | 25 |
27 SkAutoLockPixels lock(bitmap); | 26 SkAutoLockPixels lock(bitmap); |
28 for (int y = 0; y < bitmap.height(); y++) { | 27 for (int y = 0; y < bitmap.height(); y++) { |
29 for (int x = 0; x < bitmap.width(); x++) { | 28 for (int x = 0; x < bitmap.width(); x++) { |
30 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 29 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
31 } | 30 } |
32 } | 31 } |
33 } | 32 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 kUnpremul_SkAlphaType), | 137 kUnpremul_SkAlphaType), |
139 rgba, 4*w, 0,0)) { | 138 rgba, 4*w, 0,0)) { |
140 return nullptr; | 139 return nullptr; |
141 } | 140 } |
142 } | 141 } |
143 | 142 |
144 return SkData::MakeFromMalloc(rgba.release(), w*h*sizeof(uint32_t)); | 143 return SkData::MakeFromMalloc(rgba.release(), w*h*sizeof(uint32_t)); |
145 } | 144 } |
146 | 145 |
147 } // namespace sk_tools | 146 } // namespace sk_tools |
OLD | NEW |