| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkMipMap.h" | 8 #include "SkMipMap.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 #include "SkNx.h" | 11 #include "SkNx.h" |
| 12 | 12 |
| 13 // | 13 // |
| 14 // ColorTypeFilter is the "Type" we pass to some downsample template functions. | 14 // ColorTypeFilter is the "Type" we pass to some downsample template functions. |
| 15 // It controls how we expand a pixel into a large type, with space between each
component, | 15 // It controls how we expand a pixel into a large type, with space between each
component, |
| 16 // so we can then perform our simple filter (either box or triangle) and store t
he intermediates | 16 // so we can then perform our simple filter (either box or triangle) and store t
he intermediates |
| 17 // in the expanded type. | 17 // in the expanded type. |
| 18 // | 18 // |
| 19 | 19 |
| 20 struct ColorTypeFilter_8888 { | 20 struct ColorTypeFilter_8888 { |
| 21 typedef uint32_t Type; | 21 typedef uint32_t Type; |
| 22 #if defined(SKNX_IS_FAST) | 22 #if defined(SKNX_IS_FAST) |
| 23 static Sk4h Expand(uint32_t x) { | 23 static Sk4h Expand(uint32_t x) { |
| 24 return SkNx_cast<uint16_t>(Sk4b::Load((const uint8_t*)&x)); | 24 return SkNx_cast<uint16_t>(Sk4b::Load(&x)); |
| 25 } | 25 } |
| 26 static uint32_t Compact(const Sk4h& x) { | 26 static uint32_t Compact(const Sk4h& x) { |
| 27 uint32_t r; | 27 uint32_t r; |
| 28 SkNx_cast<uint8_t>(x).store((uint8_t*)&r); | 28 SkNx_cast<uint8_t>(x).store(&r); |
| 29 return r; | 29 return r; |
| 30 } | 30 } |
| 31 #else | 31 #else |
| 32 static uint64_t Expand(uint32_t x) { | 32 static uint64_t Expand(uint32_t x) { |
| 33 return (x & 0xFF00FF) | ((uint64_t)(x & 0xFF00FF00) << 24); | 33 return (x & 0xFF00FF) | ((uint64_t)(x & 0xFF00FF00) << 24); |
| 34 } | 34 } |
| 35 static uint32_t Compact(uint64_t x) { | 35 static uint32_t Compact(uint64_t x) { |
| 36 return (uint32_t)((x & 0xFF00FF) | ((x >> 24) & 0xFF00FF00)); | 36 return (uint32_t)((x & 0xFF00FF) | ((x >> 24) & 0xFF00FF00)); |
| 37 } | 37 } |
| 38 #endif | 38 #endif |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 return nullptr; | 360 return nullptr; |
| 361 } | 361 } |
| 362 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); | 362 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); |
| 363 // Try to catch where we might have returned nullptr for src crbug.com/49281
8 | 363 // Try to catch where we might have returned nullptr for src crbug.com/49281
8 |
| 364 if (nullptr == srcPixmap.addr()) { | 364 if (nullptr == srcPixmap.addr()) { |
| 365 sk_throw(); | 365 sk_throw(); |
| 366 } | 366 } |
| 367 return Build(srcPixmap, fact); | 367 return Build(srcPixmap, fact); |
| 368 } | 368 } |
| 369 | 369 |
| OLD | NEW |