| 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 "SkData.h" | 10 #include "SkData.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 p = (uint32_t*)((char*)p + rowBytes); | 200 p = (uint32_t*)((char*)p + rowBytes); |
| 201 } | 201 } |
| 202 break; | 202 break; |
| 203 } | 203 } |
| 204 default: | 204 default: |
| 205 return false; // no change, so don't call notifyPixelsChanged() | 205 return false; // no change, so don't call notifyPixelsChanged() |
| 206 } | 206 } |
| 207 return true; | 207 return true; |
| 208 } | 208 } |
| 209 | 209 |
| 210 #include "SkNx.h" |
| 211 #include "SkHalf.h" |
| 212 |
| 213 static void sk_memset64(uint64_t dst[], uint64_t value, int count) { |
| 214 for (int i = 0; i < count; ++i) { |
| 215 dst[i] = value; |
| 216 } |
| 217 } |
| 218 |
| 219 bool SkPixmap::erase(const SkColor4f& origColor, const SkIRect* subset) const { |
| 220 SkPixmap pm; |
| 221 if (subset) { |
| 222 if (!this->extractSubset(&pm, *subset)) { |
| 223 return false; |
| 224 } |
| 225 } else { |
| 226 pm = *this; |
| 227 } |
| 228 |
| 229 const SkColor4f color = origColor.pin(); |
| 230 |
| 231 if (kRGBA_F16_SkColorType != pm.colorType()) { |
| 232 Sk4f c4 = Sk4f::Load(color.vec()); |
| 233 SkColor c; |
| 234 (c4 * Sk4f(255) + Sk4f(0.5f)).store(&c); |
| 235 return pm.erase(c); |
| 236 } |
| 237 |
| 238 const uint64_t half4 = color.premul().toF16(); |
| 239 for (int y = 0; y < pm.height(); ++y) { |
| 240 sk_memset64(pm.writable_addr64(0, y), half4, pm.width()); |
| 241 } |
| 242 return true; |
| 243 } |
| 244 |
| 210 #include "SkBitmap.h" | 245 #include "SkBitmap.h" |
| 211 #include "SkCanvas.h" | 246 #include "SkCanvas.h" |
| 212 #include "SkSurface.h" | 247 #include "SkSurface.h" |
| 213 #include "SkXfermode.h" | 248 #include "SkXfermode.h" |
| 214 | 249 |
| 215 bool SkPixmap::scalePixels(const SkPixmap& dst, SkFilterQuality quality) const { | 250 bool SkPixmap::scalePixels(const SkPixmap& dst, SkFilterQuality quality) const { |
| 216 // Can't do anthing with empty src or dst | 251 // Can't do anthing with empty src or dst |
| 217 if (this->width() <= 0 || this->height() <= 0 || dst.width() <= 0 || dst.hei
ght() <= 0) { | 252 if (this->width() <= 0 || this->height() <= 0 || dst.width() <= 0 || dst.hei
ght() <= 0) { |
| 218 return false; | 253 return false; |
| 219 } | 254 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (!fStorage) { | 313 if (!fStorage) { |
| 279 return nullptr; | 314 return nullptr; |
| 280 } | 315 } |
| 281 | 316 |
| 282 const SkData* data = SkData::NewFromMalloc(fStorage, this->getSafeSize()); | 317 const SkData* data = SkData::NewFromMalloc(fStorage, this->getSafeSize()); |
| 283 fStorage = nullptr; | 318 fStorage = nullptr; |
| 284 this->INHERITED::reset(); | 319 this->INHERITED::reset(); |
| 285 | 320 |
| 286 return data; | 321 return data; |
| 287 } | 322 } |
| OLD | NEW |