OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkOpts.h" | 8 #include "SkOpts.h" |
9 #include "SkSmallAllocator.h" | 9 #include "SkSmallAllocator.h" |
10 #include "SkSpriteBlitter.h" | 10 #include "SkSpriteBlitter.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 special blitters regardless of these settings. Ignoring filtertype seems
fine | 142 special blitters regardless of these settings. Ignoring filtertype seems
fine |
143 since by definition there is no scale in the matrix. Ignoring antialiasi
ng is | 143 since by definition there is no scale in the matrix. Ignoring antialiasi
ng is |
144 a bit of a hack, since we "could" pass in the fractional left/top for th
e bitmap, | 144 a bit of a hack, since we "could" pass in the fractional left/top for th
e bitmap, |
145 and respect that by blending the edges of the bitmap against the device.
To support | 145 and respect that by blending the edges of the bitmap against the device.
To support |
146 this we could either add more special blitters here, or detect antialias
ing in the | 146 this we could either add more special blitters here, or detect antialias
ing in the |
147 paint and return null if it is set, forcing the client to take the slow
shader case | 147 paint and return null if it is set, forcing the client to take the slow
shader case |
148 (which does respect soft edges). | 148 (which does respect soft edges). |
149 */ | 149 */ |
150 SkASSERT(allocator != nullptr); | 150 SkASSERT(allocator != nullptr); |
151 | 151 |
| 152 // Defer to the general code if the pixels are unpremultipled. This case is
not common, |
| 153 // and this simplifies the code. |
| 154 if (source.alphaType() == kUnpremul_SkAlphaType) { |
| 155 return nullptr; |
| 156 } |
| 157 |
152 SkSpriteBlitter* blitter = nullptr; | 158 SkSpriteBlitter* blitter = nullptr; |
153 | 159 |
154 if (SkSpriteBlitter_Src_SrcOver::Supports(dst, source, paint)) { | 160 if (SkSpriteBlitter_Src_SrcOver::Supports(dst, source, paint)) { |
155 blitter = allocator->createT<SkSpriteBlitter_Src_SrcOver>(source); | 161 blitter = allocator->createT<SkSpriteBlitter_Src_SrcOver>(source); |
156 } else { | 162 } else { |
157 switch (dst.colorType()) { | 163 switch (dst.colorType()) { |
158 case kRGB_565_SkColorType: | 164 case kRGB_565_SkColorType: |
159 blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator); | 165 blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator); |
160 break; | 166 break; |
161 case kN32_SkColorType: | 167 case kN32_SkColorType: |
162 if (dst.info().isSRGB()) { | 168 if (dst.info().isSRGB()) { |
163 blitter = SkSpriteBlitter::ChooseS32(source, paint, allocato
r); | 169 blitter = SkSpriteBlitter::ChooseS32(source, paint, allocato
r); |
164 } else { | 170 } else { |
165 blitter = SkSpriteBlitter::ChooseL32(source, paint, allocato
r); | 171 blitter = SkSpriteBlitter::ChooseL32(source, paint, allocato
r); |
166 } | 172 } |
167 break; | 173 break; |
168 case kRGBA_F16_SkColorType: | 174 case kRGBA_F16_SkColorType: |
169 blitter = SkSpriteBlitter::ChooseF16(source, paint, allocator); | 175 blitter = SkSpriteBlitter::ChooseF16(source, paint, allocator); |
170 break; | 176 break; |
171 default: | 177 default: |
172 break; | 178 break; |
173 } | 179 } |
174 } | 180 } |
175 | 181 |
176 if (blitter) { | 182 if (blitter) { |
177 blitter->setup(dst, left, top, paint); | 183 blitter->setup(dst, left, top, paint); |
178 } | 184 } |
179 return blitter; | 185 return blitter; |
180 } | 186 } |
OLD | NEW |