| 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 "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
| 9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
| 10 #include "SkMask.h" | 10 #include "SkMask.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 156 } |
| 157 break; | 157 break; |
| 158 } | 158 } |
| 159 case kARGB_4444_SkColorType: | 159 case kARGB_4444_SkColorType: |
| 160 case kRGB_565_SkColorType: { | 160 case kRGB_565_SkColorType: { |
| 161 uint16_t* p = this->writable_addr16(area.fLeft, area.fTop); | 161 uint16_t* p = this->writable_addr16(area.fLeft, area.fTop); |
| 162 uint16_t v; | 162 uint16_t v; |
| 163 | 163 |
| 164 // make rgb premultiplied | 164 // make rgb premultiplied |
| 165 if (255 != a) { | 165 if (255 != a) { |
| 166 r = SkAlphaMul(r, a); | 166 r = SkMulDiv255Round(r, a); |
| 167 g = SkAlphaMul(g, a); | 167 g = SkMulDiv255Round(g, a); |
| 168 b = SkAlphaMul(b, a); | 168 b = SkMulDiv255Round(b, a); |
| 169 } | 169 } |
| 170 | 170 |
| 171 if (kARGB_4444_SkColorType == this->colorType()) { | 171 if (kARGB_4444_SkColorType == this->colorType()) { |
| 172 v = pack_8888_to_4444(a, r, g, b); | 172 v = pack_8888_to_4444(a, r, g, b); |
| 173 } else { | 173 } else { |
| 174 v = SkPackRGB16(r >> (8 - SK_R16_BITS), | 174 v = SkPackRGB16(r >> (8 - SK_R16_BITS), |
| 175 g >> (8 - SK_G16_BITS), | 175 g >> (8 - SK_G16_BITS), |
| 176 b >> (8 - SK_B16_BITS)); | 176 b >> (8 - SK_B16_BITS)); |
| 177 } | 177 } |
| 178 while (--height >= 0) { | 178 while (--height >= 0) { |
| 179 sk_memset16(p, v, width); | 179 sk_memset16(p, v, width); |
| 180 p = (uint16_t*)((char*)p + rowBytes); | 180 p = (uint16_t*)((char*)p + rowBytes); |
| 181 } | 181 } |
| 182 break; | 182 break; |
| 183 } | 183 } |
| 184 case kBGRA_8888_SkColorType: | 184 case kBGRA_8888_SkColorType: |
| 185 case kRGBA_8888_SkColorType: { | 185 case kRGBA_8888_SkColorType: { |
| 186 uint32_t* p = this->writable_addr32(area.fLeft, area.fTop); | 186 uint32_t* p = this->writable_addr32(area.fLeft, area.fTop); |
| 187 | 187 |
| 188 if (255 != a && kPremul_SkAlphaType == this->alphaType()) { | 188 if (255 != a && kPremul_SkAlphaType == this->alphaType()) { |
| 189 r = SkAlphaMul(r, a); | 189 r = SkMulDiv255Round(r, a); |
| 190 g = SkAlphaMul(g, a); | 190 g = SkMulDiv255Round(g, a); |
| 191 b = SkAlphaMul(b, a); | 191 b = SkMulDiv255Round(b, a); |
| 192 } | 192 } |
| 193 uint32_t v = kRGBA_8888_SkColorType == this->colorType() ? | 193 uint32_t v = kRGBA_8888_SkColorType == this->colorType() |
| 194 SkPackARGB_as_RGBA(a, r, g, b) : SkPackARGB_as_BGRA(a, r, g, b); | 194 ? SkPackARGB_as_RGBA(a, r, g, b) |
| 195 | 195 : SkPackARGB_as_BGRA(a, r, g, b); |
| 196 |
| 196 while (--height >= 0) { | 197 while (--height >= 0) { |
| 197 sk_memset32(p, v, width); | 198 sk_memset32(p, v, width); |
| 198 p = (uint32_t*)((char*)p + rowBytes); | 199 p = (uint32_t*)((char*)p + rowBytes); |
| 199 } | 200 } |
| 200 break; | 201 break; |
| 201 } | 202 } |
| 202 default: | 203 default: |
| 203 return false; // no change, so don't call notifyPixelsChanged() | 204 return false; // no change, so don't call notifyPixelsChanged() |
| 204 } | 205 } |
| 205 return true; | 206 return true; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 this->reset(info, pixels, rb); | 265 this->reset(info, pixels, rb); |
| 265 fStorage = pixels; | 266 fStorage = pixels; |
| 266 return true; | 267 return true; |
| 267 } | 268 } |
| 268 | 269 |
| 269 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) { | 270 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) { |
| 270 if (!this->tryAlloc(info)) { | 271 if (!this->tryAlloc(info)) { |
| 271 sk_throw(); | 272 sk_throw(); |
| 272 } | 273 } |
| 273 } | 274 } |
| OLD | NEW |